Skip to content

fix(security): enforce non-zero L2 recipient in deposit handlers (FINDING-001) - #25

Open
mertcano wants to merge 1 commit into
starknet-io:SN-v0.14.2from
mertcano:mertcano-patch-1
Open

mertcano wants to merge 1 commit into
starknet-io:SN-v0.14.2from
mertcano:mertcano-patch-1

Conversation

@mertcano

Copy link
Copy Markdown

Summary of Changes

Resolves FINDING-001 (High Severity) from the Starknet security audit:

  • Zero-Address Validation in L2 Deposits:
    • Added an explicit assert(l2_recipient.is_non_zero(), Errors::INVALID_RECIPIENT); check to handle_deposit_common in TokenBridge.
    • Guards all entry points (handle_deposit, handle_token_deposit, and handle_deposit_with_message) against directing newly minted tokens to the zero address (0x0).
    • Prevents irrevocable token loss and avoids potential dispatcher panics when invoking on_receive on zero addresses during message-bearing deposits.
  • Test Coverage:
    • Added test_failed_handle_token_deposit_invalid_recipient unit test in TokenBridge::tests verifying that deposits addressed to 0x0 revert with 'INVALID_RECIPIENT'.

Affected Files

  • packages/bridge/src/token_bridge.cairo

Verification

scarb --release build
snforge test test_failed_handle_token_deposit_invalid_recipient
snforge test

…DING-001)

### Summary of Changes
Resolves **FINDING-001** (High Severity) from the Starknet security audit:

- **Zero-Address Validation in L2 Deposits:**
  - Added an explicit `assert(l2_recipient.is_non_zero(), Errors::INVALID_RECIPIENT);` check to `handle_deposit_common` in `TokenBridge`.
  - Guards all entry points (`handle_deposit`, `handle_token_deposit`, and `handle_deposit_with_message`) against directing newly minted tokens to the zero address (`0x0`).
  - Prevents irrevocable token loss and avoids potential dispatcher panics when invoking `on_receive` on zero addresses during message-bearing deposits.
- **Test Coverage:**
  - Added `test_failed_handle_token_deposit_invalid_recipient` unit test in `TokenBridge::tests` verifying that deposits addressed to `0x0` revert with `'INVALID_RECIPIENT'`.

### Affected Files
- `packages/bridge/src/token_bridge.cairo`

### Verification
```bash
scarb --release build
snforge test test_failed_handle_token_deposit_invalid_recipient
snforge test
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