Escape control characters in more terminal output - #2673
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Sanitizes attacker-influenced contract metadata and RPC event fields before terminal rendering.
Changes:
- Sanitizes event identifiers, metadata, and contract IDs.
- Sanitizes SDK version metadata used in upload diagnostics.
- Sanitizes generated clap value names and adds unit regressions.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
commands/events.rs |
Sanitizes event output fields. |
contract/upload.rs |
Sanitizes SDK version diagnostics. |
contract/arg_parsing.rs |
Sanitizes help value names. |
leighmcculloch
approved these changes
Aug 7, 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
Sanitizes three more attacker-influenceable strings before they reach the terminal, so control and ANSI escape sequences can no longer survive to a user's screen:
contractarg parsing — UDT struct field names are embedded into the clapvalue_nameshown in--help; the value name is now run throughsanitize().contract upload— the SDK version read from contract metadata (used in an error/warning line, including the release-candidate check) is now sanitized while still preservingrcdetection.events— the eventid,event_type,ledger_closed_at, and decodedcontract_idare now sanitized before being written to stdout.Each change comes with a test that feeds embedded escape sequences (e.g.
\x1b[2J,\x1b[H) and asserts no control characters survive in the rendered output.Why
Contract spec/metadata and RPC event data are not trusted input. Rendering them verbatim lets a malicious contract inject terminal escape sequences (screen clears, cursor moves, color resets) into CLI output. This continues the terminal-output sanitization sweep started in recent commits, closing the remaining unescaped paths in
--helpvalue names, upload warnings, and event listings.Known limitations
N/A