Strip control characters from auth entry prompt - #2667
Merged
Conversation
mootz12
approved these changes
Aug 4, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Sanitize the attacker-influenced strings rendered by
format_auth_entryinlog/auth.rs. The function name (Fn:), each contract-function argument (Args:), and theCreateContractV2constructor arguments are now passed throughsoroban_spec_tools::sanitizebefore display, so terminal-escape and other control bytes are escaped rather than emitted verbatim.Why
Auth entries shown in the interactive signing prompt come from the RPC's
simulateTransactionresponse. A top-levelScVal::Symbolargument and the function name were printed raw, so control characters (e.g. ANSI escapes) reached the terminal unescaped and could distort what the user sees before approving a signature. The rest of the codebase already sanitizes attacker-influenced output at the display site —log/event.rs,commands/events.rs, andarg_parsing.rs— so this brings the auth prompt in line with that convention. Because the escaping lives insideformat_auth_entry, it covers all of its call sites at once (the prompt,--auto-sign, and both invalid-entry error messages). A regression test mirrors the existinglog/event.rstest, asserting no control characters survive.Known limitations
Sanitization is applied at the display site rather than at the boundary in
soroban_spec_tools::to_string. Boundary-level hardening (sanitizing the top-levelScVal::Symbolarm, capping the rendered argument count, and resetting terminal state before the decision line) is left as possible follow-up defence in depth.