Skip to content

Refuse a plain value send to an address that holds code - #27

Merged
SaulBuilds merged 6 commits into
mainfrom
fix/plain-transfer-contract-recipient
Nov 30, 2026
Merged

SaulBuilds merged 6 commits into
mainfrom
fix/plain-transfer-contract-recipient

Conversation

@SaulBuilds

Copy link
Copy Markdown
Contributor

Refuse a plain value send to an address that holds code

CitrateClient._sign_and_send now checks the recipient of a plain value transfer (no calldata, value above zero) with eth_getCode before signing. If the address holds code, it raises CitrateError("This address is a contract. Use its deposit function instead.") (exported as CONTRACT_RECIPIENT). If the code cannot be read, it refuses as well. Calls that carry calldata, and sends to plain accounts, work as before.

Data source (Rule 7): eth_getCode on the client's rpc_url.

Tests (red first)

  • Red 6f392ab (CONTRACT_RECIPIENT missing). Green: tests/test_plain_transfer_recipient.py 5/5. These tests send value to the WrappedSALT and EntryPoint entries of the live 40204 book and expect a refusal with nothing signed. They also cover a plain account (sent as before), calldata (not checked), and unreadable code (refused).
  • Related suites: test_client, test_audit_rm_g_chainid, test_call_site_guard_pins, test_gap_guard_pins, test_hardening_round3/4 (182 passed). ruff and mypy are clean.

Review record

Money path: one independent review requested in the swarm review queue.

🤖 Generated with Claude Code

https://claude.ai/code/session_019cgBjEUXiPasw1yPyGXkXC

SaulBuilds and others added 3 commits November 30, 2026 00:57
_sign_and_send with empty calldata and a recipient that holds code (the
WrappedSALT and EntryPoint entries of the live 40204 book) must refuse
with "This address is a contract. Use its deposit function instead."
before signing; a plain account is sent as before; a call with calldata
is not checked; unreadable code is refused. Red: CONTRACT_RECIPIENT does
not exist yet.

Signed-off-by: Larry Klosowski <larryklosowski@proton.me>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019cgBjEUXiPasw1yPyGXkXC
_sign_and_send now reads eth_getCode for the recipient of a plain value
transfer (no calldata, value > 0) before signing: code present raises
"This address is a contract. Use its deposit function instead." (exported
as CONTRACT_RECIPIENT); code that cannot be read is refused. Calls with
calldata and sends to plain accounts are unchanged.

Signed-off-by: Larry Klosowski <larryklosowski@proton.me>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019cgBjEUXiPasw1yPyGXkXC
Signed-off-by: Larry Klosowski <larryklosowski@proton.me>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019cgBjEUXiPasw1yPyGXkXC
@SaulBuilds
SaulBuilds requested a review from a team as a code owner November 30, 2026 09:12
@SaulBuilds

Copy link
Copy Markdown
Contributor Author

Independent review (Claude R5) @5436f0ab: CHANGES (details in the private review packet)

@BerryManifold BerryManifold 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.

Automated Codex static review of 5436f0abd66078bd8bff43774ff0886b68f84854 is complete. Result: blockers; details retained privately. Details and coverage limits are recorded in the project's private review log. No tests were executed by this reviewer. Both account submissions represent the same Codex review, not independent reviews.

@Matr0xshka Matr0xshka 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.

Automated Codex static review of 5436f0abd66078bd8bff43774ff0886b68f84854 is complete. Result: blockers; details retained privately. Details and coverage limits are recorded in the project's private review log. No tests were executed by this reviewer. Both account submissions represent the same Codex review, not independent reviews.

SaulBuilds and others added 3 commits November 30, 2026 01:37
…5 B1)

A CitrateWalletFactory wallet is Solady's ERC1967 proxy whose implementation
slot holds the book's CitrateWallet (receive() is empty), so a plain transfer
credits it. The same proxy code for any other implementation, other code, or
an unreadable slot is still refused. Pins the proxy runtime, its codehash and
the ERC1967 slot as the definition Core shares. Message copy says why (R5 N2).

Signed-off-by: Larry Klosowski <larryklosowski@proton.me>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019cgBjEUXiPasw1yPyGXkXC
The recipient check allows exactly one kind of code: CitrateWalletFactory's
ERC1967 proxy runtime (Solady LibClone, the same bytes the address prediction
hashes) whose ERC1967 implementation slot holds the book's CitrateWallet. Any
other code, the same proxy for another implementation, or a slot that cannot
be read is refused. The runtime, its codehash and the slot are exported from
identity.wallet as the shared definition Core pins too. Message copy says why.

Signed-off-by: Larry Klosowski <larryklosowski@proton.me>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019cgBjEUXiPasw1yPyGXkXC
Signed-off-by: Larry Klosowski <larryklosowski@proton.me>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019cgBjEUXiPasw1yPyGXkXC
@SaulBuilds

Copy link
Copy Markdown
Contributor Author

Fixed after R5's review @5436f0ab (detail in the private packet): red e3bf33e, green 5db2778, golden pin 48fc6e2. 9/9 in the recipient suite, related suites 150 passed, ruff and mypy clean. Re-review queued.

@SaulBuilds

Copy link
Copy Markdown
Contributor Author

Independent review (Claude R5) @48fc6e25: APPROVE (details in the private review packet)

@BerryManifold BerryManifold 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.

Automated Codex static review of 48fc6e25cea6a6bda8c7cda7bf1407b1c4cf9d0b is complete. Result: blockers; details retained privately. Details and coverage limits are recorded in the project's private review log. No tests were executed by this reviewer. Both account submissions represent the same Codex review, not independent reviews.

@Matr0xshka Matr0xshka 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.

Automated Codex static review of 48fc6e25cea6a6bda8c7cda7bf1407b1c4cf9d0b is complete. Result: blockers; details retained privately. Details and coverage limits are recorded in the project's private review log. No tests were executed by this reviewer. Both account submissions represent the same Codex review, not independent reviews.

@SaulBuilds
SaulBuilds merged commit ec2a13f into main Nov 30, 2026
10 checks passed
@SaulBuilds
SaulBuilds deleted the fix/plain-transfer-contract-recipient branch November 30, 2026 10:02
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.

3 participants