Skip to content

fix: bind native placeholders to their chain (M-365); never replay writes after re-login (M-366) - #22

Merged
kuzane merged 1 commit into
mainfrom
fix/cli-bounty-dec03
Dec 3, 2026
Merged

kuzane merged 1 commit into
mainfrom
fix/cli-bounty-dec03

Conversation

@kuzane

@kuzane kuzane commented Dec 3, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes the two minara-cli v0.5.2 findings from the December 3 bounty batch. Both were confirmed against main (3d75b6f).

M-365: another chain's native placeholder accepted as a token on the requested chain

Before: lookupToken(…, { chain }) kept every EVM native placeholder (0x0…0 / 0xE…E) from any chain. It relabelled the entry as the requested chain but kept the entry's symbol and name, and assertTokenOnChain skipped placeholders. So swap -t '$POL' --chain base could be confirmed as POL and executed as Base ETH. Solana accepted EVM placeholders too.

Now:

  • A placeholder entry is kept only when its symbol is the requested chain's native coin (new NATIVE_SYMBOLS table). ETH listed on Ethereum may be used on Base; POL may not. Placeholders are never kept on Solana.
  • assertTokenOnChain enforces the same rule. It throws "$POL (0x0…0) would execute as the native token of Base ($ETH), not $POL".
  • Placeholder entries are ranked and labelled by the chain they execute on, so a foreign native entry no longer sorts ahead of a real token with the same symbol.
  • Typing the placeholder itself together with a chain resolves straight to that chain's native token. It is rejected on Solana.

M-366: blind replay after re-login; account check fails open

Before: after a 401, the interactive re-login replayed the original request with the new token, whatever the request was: a swap, a transfer, an order, a cancellation or an account change. Nothing was re-confirmed and no quote was refreshed. The same-account check only blocked a replay when both identities were known and differed.

Now:

  • Writes are never replayed. Only read-only requests are retried: GET, plus the POST endpoints marked replayable (swap quote, activities, statuses, price analysis). For anything else the user sees "Signed in again … NOT sent automatically. Run the command again to review and confirm it with current prices." and the command exits. The rejected request never executed, so nothing is lost.
  • The account check fails closed. It compares user ids, or failing that the emails returned by the server. The email typed or remembered locally doesn't count. If there is nothing to compare, the request is not retried.
  • After a renewal confirmed for the same account, later requests of the same command use the new token instead of prompting again. They are sent for the first time after the re-login and after any confirmation that follows it, so this is not a replay.

Testing

  • npx vitest run: 438 passed (425 on main). New tests cover:
    • M-365: foreign placeholders dropped, Solana rejected, a real token preferred over a foreign native entry, picker labels, a typed placeholder resolving to the chain's native token, and assertTokenOnChain.
    • M-366: writes not replayed; reads replayed only for a confirmed account; fail-closed checks (no identity on either side); different account; replayable POST keeps its body; renewed token reused by later requests and not carried over when the account is unconfirmed.
  • npx tsc --noEmit reports no errors, and the build succeeds.

Behavior changes

  • --chain X with a native ticker from another chain (for example $POL --chain base) now errors instead of trading the chain's native coin.
  • After re-login, a write command must be run again.

Generated by Claude Code

…er re-login

M-365: token lookup with a chain kept every EVM native placeholder
(0x0…0 / 0xE…E) from any chain, relabelled it as the requested chain
and kept its symbol, and assertTokenOnChain let placeholders through.
`$POL --chain base` could therefore be confirmed as POL and executed
as Base ETH; Solana accepted EVM placeholders too.
- a placeholder entry is only kept when its symbol is the requested
  chain's native coin (ETH listed on Ethereum may be used on Base, POL
  may not); never on Solana; assertTokenOnChain enforces the same rule
- placeholder entries are ranked and shown on the chain they execute
  on, so a foreign native entry no longer sorts ahead of real tokens
- typing the placeholder itself with a chain resolves directly to that
  chain's native token

M-366: after a 401 the interactive re-login replayed the original
request whatever it was, and the same-account check only blocked when
both identities were known and differed.
- only read-only requests are retried: GET, plus POST endpoints marked
  `replayable` (swap quote, activities, statuses, price analysis); a
  trade, transfer, order, cancellation or account change is never
  re-sent, and the user re-runs the command to confirm it with current
  prices
- the account check fails closed: user ids, else server-returned
  emails, must match; with nothing to compare there is no retry
- after a same-account renewal, later requests of the same command use
  the new token instead of prompting again (they are sent for the first
  time after the re-login, not replayed)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_0133E5DCA8sK7CJ7WWWrb2P7
@kuzane
kuzane merged commit 15050ca into main Dec 3, 2026
6 checks passed
@kuzane kuzane mentioned this pull request Dec 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants