fix(swap): say "enable AdvancedMode" instead of "Action cancelled" - #417
Merged
Merged
Conversation
A relay swap died with a bare `Action cancelled` while the device sat there
having shown "Blocked". The reason existed and was thrown away.
## What actually happens
Relay routes are not in the firmware's pinned clear-sign allowlist, so the
device must blind-sign them — and blind-signing arbitrary contract data is
gated on AdvancedMode (ethereum.c). It renders "Blocked" and replies
Failure_ActionCancelled with the message "Blind signing disabled by policy".
hdwallet's transport then does:
throw new core.ActionCancelled(); // message discarded
if (response.message_type === FAILURE) throw response; // next line: kept
Only ActionCancelled is flattened; every other failure keeps its payload. And
firmware uses that same code for a genuine user cancel, so once the string is
gone Vault cannot tell "user pressed cancel" from "policy refused" — it has
nothing left to build a prompt from.
Clear-signing is not an escape hatch here. Metadata verification needs a
runtime-loaded signer and loading one ALSO requires AdvancedMode; there is no
built-in trust anchor (signed_metadata.c only ever returns loaded keys —
"deliberately rejects persistent trust anchors"). The delegation work that
would change this is docs-only, gated on an owner custody decision:
docs/security/clearsign-key-delegation-roadmap.md. So AdvancedMode is required
for relay today, by design, and it is documented in
docs/security/7.15.0-rc21-clearsign-release-control.md:
"runtime signer loading, and runtime metadata verification are usable only
while the user has enabled AdvancedMode"
## The fix
Check before prompting, not after failing — same shape as the Solana opaque
gate directly above it, using the `isAdvancedModeEnabled` hook that was already
on SwapContext for exactly that purpose but never applied to EVM.
Fires only when all of: EVM, real calldata, NOT in the firmware allowlist
(firmwareClearSigns), and the policy is known-disabled. `undefined` (features
not cached / policy not reported) deliberately does not fire — guessing would
block a swap the device would have signed.
The message names the blocker, says where to fix it, and warns that it turns
itself back off on reboot (#373 made AdvancedMode session-scoped, which is why
this went from rare to constant).
Not fixed here: hdwallet still destroys the reason string, so a cancel arriving
from any other path is still ambiguous. That is the real repair and it belongs
in hdwallet transport.ts; this makes the reported case actionable now.
## Tests
Wires __tests__/firmware-clearsign-gate.test.ts into make test-unit. It already
asserts the exact predicate this gate depends on — including "firmware-unknown
contracts → blind (Uniswap / 1inch / relay)" — and had never run in CI, the
third such file found this session.
make test-unit 480 pass, 0 fail across 32 files, +35 btc-backend, +10 cosmos
tsc --noEmit 627, unchanged, 2 below baseline 629
This was referenced Aug 15, 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.
A relay swap died with a bare
Action cancelledwhile the device sat therehaving shown "Blocked". The reason existed and was thrown away.
What actually happens
Relay routes are not in the firmware's pinned clear-sign allowlist, so the
device must blind-sign them — and blind-signing arbitrary contract data is
gated on AdvancedMode (ethereum.c). It renders "Blocked" and replies
Failure_ActionCancelled with the message "Blind signing disabled by policy".
hdwallet's transport then does:
Only ActionCancelled is flattened; every other failure keeps its payload. And
firmware uses that same code for a genuine user cancel, so once the string is
gone Vault cannot tell "user pressed cancel" from "policy refused" — it has
nothing left to build a prompt from.
Clear-signing is not an escape hatch here. Metadata verification needs a
runtime-loaded signer and loading one ALSO requires AdvancedMode; there is no
built-in trust anchor (signed_metadata.c only ever returns loaded keys —
"deliberately rejects persistent trust anchors"). The delegation work that
would change this is docs-only, gated on an owner custody decision:
docs/security/clearsign-key-delegation-roadmap.md. So AdvancedMode is required
for relay today, by design, and it is documented in
docs/security/7.15.0-rc21-clearsign-release-control.md:
"runtime signer loading, and runtime metadata verification are usable only
while the user has enabled AdvancedMode"
The fix
Check before prompting, not after failing — same shape as the Solana opaque
gate directly above it, using the
isAdvancedModeEnabledhook that was alreadyon SwapContext for exactly that purpose but never applied to EVM.
Fires only when all of: EVM, real calldata, NOT in the firmware allowlist
(firmwareClearSigns), and the policy is known-disabled.
undefined(featuresnot cached / policy not reported) deliberately does not fire — guessing would
block a swap the device would have signed.
The message names the blocker, says where to fix it, and warns that it turns
itself back off on reboot (#373 made AdvancedMode session-scoped, which is why
this went from rare to constant).
Not fixed here: hdwallet still destroys the reason string, so a cancel arriving
from any other path is still ambiguous. That is the real repair and it belongs
in hdwallet transport.ts; this makes the reported case actionable now.
Tests
Wires tests/firmware-clearsign-gate.test.ts into make test-unit. It already
asserts the exact predicate this gate depends on — including "firmware-unknown
contracts → blind (Uniswap / 1inch / relay)" — and had never run in CI, the
third such file found this session.
make test-unit 480 pass, 0 fail across 32 files, +35 btc-backend, +10 cosmos
tsc --noEmit 627, unchanged, 2 below baseline 629