Skip to content

Strip control characters from contract read output - #2672

Open
fnando wants to merge 2 commits into
mainfrom
sanitize-contract-read-output
Open

Strip control characters from contract read output#2672
fnando wants to merge 2 commits into
mainfrom
sanitize-contract-read-output

Conversation

@fnando

@fnando fnando commented Aug 6, 2026

Copy link
Copy Markdown
Member

What

Sanitizes the key/value fields in stellar contract read's default (--output string) output so control and escape sequences can no longer reach the terminal unescaped. The per-entry record building is extracted into a small entry_record helper and the String branch now wraps soroban_spec_tools::to_string with soroban_spec_tools::sanitize. A regression test covers a top-level ScVal::Symbol carrying escape bytes.

Why

soroban_spec_tools::to_string returns raw, unescaped bytes for a top-level ScVal::Symbol, and the default output writes those straight to the terminal via the CSV writer. Every other output mode (JSON/XDR) already escapes its content, and the auth-entry signing prompt was hardened the same way in #2667. This applies the same defense-in-depth to the contract read display path so untrusted ledger content cannot smuggle terminal escape sequences into a user's terminal.

Known limitations

N/A

Copilot AI balanced review requested due to automatic review settings August 6, 2026 14:45
@github-project-automation github-project-automation Bot moved this to Backlog (Not Ready) in DevX Aug 6, 2026
@fnando fnando self-assigned this Aug 6, 2026
@fnando fnando moved this from Backlog (Not Ready) to Needs Review in DevX Aug 6, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Sanitizes contract read string output to prevent terminal control-sequence injection.

Changes:

  • Extracts ledger-entry formatting into entry_record.
  • Sanitizes string-formatted keys and values.
  • Adds a unit regression test for malicious symbols.

Comment thread cmd/soroban-cli/src/commands/contract/read.rs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Needs Review

Development

Successfully merging this pull request may close these issues.

2 participants