Skip to content

Stop echoing a mistyped secret key given where an address is expected - #2785

Merged
fnando merged 1 commit into
mainfrom
token-conceal-secret-in-address-errors
Oct 2, 2026
Merged

fnando merged 1 commit into
mainfrom
token-conceal-secret-in-address-errors

Conversation

@fnando

@fnando fnando commented Oct 1, 2026

Copy link
Copy Markdown
Member

What

token commands that take an address (transfer --to, allowance --spender, balance --account, and the others sharing UnresolvedScAddress) echoed the raw input back in the "alias not found" error, in both text and JSON. A mistyped secret key or seed phrase pasted there printed a near-copy of the secret to the terminal, logs, and JSON consumers. The error is now a generic non-echoing invalid address or alias, matching the behaviour --from already has. A custom Debug impl also conceals the raw Alias value so it can't leak through an error chain.

Why

Fixes #2771. --from already hid the value (invalid signing key or identity name), but the address params echoed it, so a one-character typo of a real secret leaked it. This is the address-resolution counterpart to #2763, which fixed the signing path.

Known limitations

A genuine alias typo (e.g. --to myaccount) no longer names the alias in the error — the value is never echoed, by design, the same trade-off --from makes. A valid secret key or seed phrase in an address param still resolves to its derived account (existing behaviour); only inputs that fail to resolve reach this error.

Copilot AI lite review requested due to automatic review settings October 1, 2026 22:27

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.

Copilot review overview

🟢 Approval recommended

No unresolved blocking issues were identified.

Review effort: Lite
Findings: None

What changed in this PR

Prevents mistyped secrets in address parameters from appearing in errors, debug output, or JSON responses.

Changes:

  • Replaces echoed alias errors with invalid address or alias.
  • Redacts unresolved aliases in Debug output.
  • Adds unit and integration regression tests.
File Description
cmd/​soroban-cli/​src/​config/​sc_address.rs Redacts aliases and sanitizes address-resolution errors.
cmd/​crates/​soroban-test/​tests/​it/​config.rs Tests token address error redaction.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@fnando
fnando added this pull request to stack #2787 October 2, 2026 00:02

@leighmcculloch leighmcculloch left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

One concern as this degrades the UX more than it necessarily needs to, but regardless resolves the issue and defer to you on whether the UX issue mentioned inline is worth the additional complexity.

AccountAliasNotFound(String),
// The input is never echoed: a secret key or seed phrase mistyped where an
// address was expected must not reach the terminal, logs, or JSON output.
#[error("invalid address or alias")]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This also drops the alias name for the ordinary case of a mistyped alias. --account alise used to say Account alias "alise" not Found and now only says invalid address or alias, so the user can't tell which argument or value was wrong. This matters most for commands that take several address args (token transfer --from --to, --spender).

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

For a mistyped alias the value is still right there in the command the user just ran, so the only thing lost is which arg failed on a multi-address command — and that matches how --from already reports (invalid signing key or identity name). I'd keep it consistent and treat per-arg naming as a possible follow-up.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

the only thing lost is which arg failed on a multi-address command

That's the issue I'm concerned with.

that matches how --from already reports (invalid signing key or identity name). I'd keep it consistent and treat per-arg naming as a possible follow-up.

I think this is an issue with the change on --from too and in other places that behave this way, there's no way to tell what the error which field the error is referring to. Maybe we can attach the field name the error is arising from?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Followed up in #2795: concealment is now conditional — a genuine alias typo is named again (address alias 'nosuchalias' not found), so you can see which value was wrong, while only secret-shaped input is hidden. Same treatment extends to the contract-id path, which had the identical leak.

@fnando
fnando merged commit a9cb94a into main Oct 2, 2026
146 of 147 checks passed
@fnando
fnando deleted the token-conceal-secret-in-address-errors branch October 2, 2026 19:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

token commands echo a mistyped secret key given in the --to param back in the "alias not found" error

3 participants