frontend: cross-validate route intermediate tokens vs submitted ops (#450) #987
No reviewers
Labels
No labels
agent:fix_bugfix
agent:fix_conflicts
agent:fix_security
agent:gap_analysis
agent:implement
agent:implement
agent:implement
agent:open_issues
agent:ready
agent:research
agent:security_audit
agent:verify
architecture
backend
blocker:hybrid
blocker:launch
blocker:limit-orders
blocker:v2
block:log_only
block:security
bug
ci
contracts
correctness
deploy
dev
devops
docs
documentation
duplicate
e2e
enhancement
epic
feature
frontend
functional-completion
gas
good first issue
governance
help wanted
high-risk
hooks
hybrid
indexer
infra
infrastructure
integrators
invalid
launch-blocker
limit-orders
localnet
localterra
low priority
missing-implementation
needs-design
ops
performance
priority
high
priority
medium
product
qa
QA
question
ready
ready
research
scripts
security
security-hardening
smartcontracts
tech-debt
testing
ux
UX
v2
verification
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
code/cl8y-dex-terraclassic!987
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "qa/450-route-intermediate-token-crosscheck"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
The Swap route display uses indexer
intermediate_tokenswhile submit is builtfrom
router_operations— both from the indexer, with no cross-check. Amalicious/compromised indexer could display one path and submit another within
slippage tolerance (SEC-I02 H09).
Add
swapRouteIntermediateTokensAligned(operations, intermediateTokens)—re-derives the token path from the submitted operations and compares it
(case-insensitive, address-normalized) against the displayed intermediate
tokens. Wired into the route-solve quote in SwapPage: a mismatch throws, so the
quote falls through to the pool-only path instead of signing an indexer-
substituted route. Aligned/empty paths are unaffected (token_in/token_out are
already matched separately).
Tests: 6 new cases (aligned, case-insensitive, substituted intermediate,
substituted terminal, length mismatch, nothing-to-check); swapRouteDisplay 11/0,
SwapPage suites 32/0, tsc clean.
Note: the signing-modal pair-address display side of the route-integrity work
(#449) still needs the browser/UI layer.
assigned to @Brouie
mentioned in issue #450
Security review — MR !987
Commit reviewed:
6b53f27fea3361e4a8b7804bc397fba5edadaeacScope:
swapRouteIntermediateTokensAlignedhelper + wiring in SwapPagegetRouteSolvequote path; unit tests (SEC-I02 H09 / #450).Outcome:
FINDINGS: 0medium+Summary
This MR closes the documented display/submit split for indexer CW20↔CW20 hybrid quotes:
computeSwapRouteDisplaycan renderintermediate_tokenswhile submit usesrouter_operations. The new helper re-derives the token path from operations viatokenPathFromSwapOperationsand compares it case-insensitively to the displayed intermediate list; mismatch throws and the quote falls through to pool-only fallback instead of signing a substituted route.Attack-path tracing (no exploitable gaps found on this diff):
intermediate_tokens, evilrouter_operations) — blocked: element-wise address compare fails; quote rejected.intermediate_tokens(falls back to hops-derived path) — still cross-checked against ops; hops vsrouter_operationsdisagreement is caught the same way.truewhen ops/intermediates absent — not exploitable on the wired path:intermediatesis always materialized fromtoken_in+ hops when the guard runs; empty ops cannot satisfyswapOperationsFromIndexerResponsefor multihop.enrichSwapOperationsWithHopMinReturns— only attachesmin_return; offer/ask assets unchanged, so validation onopsForQuotematches submit-time ops.postRouteSolvein SwapPage / TradeMarketOrderPanel) — unchanged and not a regression: they never setindexerIntermediateTokens; display already derives fromindexerOperationsonly (no split-trust surface this MR targets).useSubmitAlignedSimQuotekeepsindexerOperationsandindexerIntermediateTokenson the same debounced snapshot.Inline threads: none (no medium+ findings).
Security review: no medium+ findings on this diff.
mentioned in commit
2ae3372716mentioned in merge request !994