Skip to content

fix(wallet): refuse sends that would lose funds - #838

Open
kome12 wants to merge 2 commits into
mainfrom
fix/wallet-send-recipient-guards
Open

kome12 wants to merge 2 commits into
mainfrom
fix/wallet-send-recipient-guards

Conversation

@kome12

@kome12 kome12 commented Nov 16, 2026

Copy link
Copy Markdown
Contributor

nansen wallet send could move funds somewhere the user didn't intend. It now refuses these before signing:

  • a mixed-case EVM --to/--token address with an invalid EIP-55 checksum (all-lowercase and all-uppercase addresses still pass)
  • an ERC-20 sent to its own contract
  • a Solana recipient that isn't a wallet: any existing account not owned by the System Program, such as a token account, mint, program or program data. An address with no account yet passes, and the lookup fails closed.
  • --amount <number> combined with --max, which used to drop the amount and send the whole balance (now INVALID_INPUT)

The EIP-55 helper moves to crypto.js, and wallet generation uses it.

Before / after

before after
Base USDC's address with the last digit changed, as --to or --token accepted refused with a checksum error
--token USDC --to <USDC contract> broadcast refused
SPL token or SOL sent to a token account, mint or program broadcast refused
Sent to a normal wallet, or to a new address with no account sent sent
--amount 1 --max whole balance sent INVALID_INPUT, exit 1

Tests

New unit tests for each case; each fails on main with the bug's symptom. A shared test address had an invalid checksum and is replaced by its checksummed form, and the Solana mocks answer the new recipient lookup the way a real node does. The full suite and lint pass.

🤖 Generated with Claude Code

wallet send now refuses, before signing:
- a mixed-case EVM --to or --token address whose EIP-55 checksum does not
  match (all-lowercase and all-uppercase still pass)
- an ERC-20 sent to its own token contract
- a Solana recipient that is not a wallet: any existing account not owned
  by the System Program (token account, mint, program, program data). An
  address with no account yet passes. The lookup fails closed.
- --amount <number> together with --max (INVALID_INPUT), which used to
  drop the amount and send the whole balance

The EIP-55 helper moves to crypto.js and wallet generation uses it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Comment thread src/transfer.js Resolved
@nansen-pr-reviewer

nansen-pr-reviewer Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

nansen-pr-reviewer summary

The change adds EIP-55 validation, ERC-20 self-transfer protection, Solana recipient account checks, and rejects conflicting numeric amount/max CLI options. The earlier Solana System-owned account finding is addressed by rejecting accounts with non-empty data, and the new behavior is covered by mocked tests. No correctness or security issues were found in the reviewed diff.

Deterministic check: success — No issues found

Risk: 3/5 (Elevated) — raised by: security-sensitive paths (auth/crypto/token/session)

✅ Auto-approved — Deterministic gates passed: severity thresholds met, recommendation "approve", risk level 3/5 within threshold 3.


Token usage: 38,523 input, 2,223 output, 57,469 cache read | Usage Guide

Cooldown: for the next 10 minutes (counting from when this review finished), new pushes to this PR will not trigger another review — the next push after the window expires will. Need a fresh review sooner? Comment @nansen-pr-reviewer[bot] re-review.

nansen-pr-reviewer[bot]
nansen-pr-reviewer Bot previously approved these changes Nov 16, 2026

@nansen-pr-reviewer nansen-pr-reviewer Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

✅ Auto-approved by Nansen review

Deterministic gates passed: severity thresholds met, recommendation "approve_with_comments", risk level 3/5 within threshold 3.

  • The deterministic severity check passed: Found 1 finding(s) within acceptable thresholds
  • Risk level 3/5 (Elevated)
  • The model recommended: approve_with_comments

Approval was decided by deterministic gates, not by the model. The model's recommendation can block auto-approval but never cause it.

A durable nonce account (or any System account with data) is not a
wallet. Tokens sent to its associated token account can't be moved out.
Normal wallets and multisig vault addresses hold no data and still pass.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@nansen-pr-reviewer nansen-pr-reviewer Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

✅ Auto-approved by Nansen review

Deterministic gates passed: severity thresholds met, recommendation "approve", risk level 3/5 within threshold 3.

  • The deterministic severity check passed: No issues found
  • Risk level 3/5 (Elevated)
  • The model recommended: approve

Approval was decided by deterministic gates, not by the model. The model's recommendation can block auto-approval but never cause it.

@kome12 kome12 self-assigned this Nov 16, 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.

1 participant