Repository navigation
Fix strict Base address validation - #5480
kekehanshujun wants to merge 2 commits into
Conversation
TJCurnutte
left a comment
There was a problem hiding this comment.
Verified this locally. The strict Base/EVM address validation looks good to me.
Validation run on detached head a7717c36b581:
git diff --check origin/main...HEAD -- bridge/bridge_api.py bridge/test_bridge_api.py node/beacon_x402.py node/rustchain_x402.py node/tests/test_base_evm_address_validation.py— passed.python3 -B -m py_compile bridge/bridge_api.py bridge/test_bridge_api.py node/beacon_x402.py node/rustchain_x402.py node/tests/test_base_evm_address_validation.py— passed.uv run --no-project --with pytest --with flask python -B -m pytest -q bridge/test_bridge_api.py node/tests/test_base_evm_address_validation.py --noconftest—45 passed in 0.33s.- Runtime probe:
bridge_api._is_base_evm_address()accepted canonical0x+ 40-hex addresses including mixed-case hex, and rejected0X..., short, non-hex, and non-string values. A Flask test-client probe for/wallet/link-coinbaseaccepted a valid mixed-case Base address and rejected short/non-hex/non-string addresses with HTTP 400 before the bad values could be written.
The important path is covered: /bridge/lock now rejects Base target_wallet values unless they are exactly 0x plus 40 hex characters before receipt verification/ledger insert, while the RustChain and Beacon x402 wallet-link routes enforce the same shape before persistence. Existing signed receipt and Solana bridge cases still pass in the focused bridge suite.
ZacharyZhang-NY
left a comment
There was a problem hiding this comment.
Reviewed PR #5480 at head a7717c3.
Blocking finding:
This PR says it fixes #5434, but the #5434 path remains vulnerable on the PR head. Issue #5434 specifically points to node/bridge_api.py::validate_chain_address_format(chain="base", address=...), and that function still only checks the 0x prefix and length 42. It does not verify that the remaining 40 characters are hexadecimal.
Reproduction on this PR head:
python import bridge_api bad = "0x" + "Z" * 40 ok, msg = bridge_api.validate_chain_address_format("base", bad) assert ok is True
Observed output:
ext {'ok': True, 'msg': '', 'bad': '0xZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ'}
The standalone bridge lock endpoint and x402 wallet endpoints look covered, but #5434 remains open until node/bridge_api.py also enforces exactly 0x plus 40 hex characters.
Validation performed:
- git fetch origin pull/5480/head:review-pr-5480 --force
- git diff --check origin/main...review-pr-5480 -- bridge/bridge_api.py bridge/test_bridge_api.py node/rustchain_x402.py node/beacon_x402.py node/tests/test_base_evm_address_validation.py -> passed.
- python -m py_compile bridge/bridge_api.py bridge/test_bridge_api.py node/rustchain_x402.py node/beacon_x402.py node/tests/test_base_evm_address_validation.py on extracted PR-head files -> passed.
- python -m pytest bridge/test_bridge_api.py node/tests/test_base_evm_address_validation.py -q --confcutdir= -> 45 passed.
- Checked issues #5432, #5434, and #5436.
- Ran the node/bridge_api.py validator probe above and confirmed #5434 still reproduces.
508704820
left a comment
There was a problem hiding this comment.
Fix strict Base address validation. Verify: (1) Address validation rejects both invalid checksum and wrong network prefix. (2) Validation is applied consistently across all Base chain endpoints. (3) Error message does not reveal expected address format to assist attackers. - Xeophon (security review)
LubuSeb
left a comment
There was a problem hiding this comment.
Reviewed the updated head 7d3b100 after the earlier #5434 blocker.
Validation performed:
git diff --check origin/main...HEAD -- bridge/bridge_api.py bridge/test_bridge_api.py node/bridge_api.py node/beacon_x402.py node/rustchain_x402.py node/tests/test_base_evm_address_validation.py-> passedpython -B -m py_compile bridge/bridge_api.py bridge/test_bridge_api.py node/bridge_api.py node/beacon_x402.py node/rustchain_x402.py node/tests/test_base_evm_address_validation.py-> passed- isolated venv with
pytest+flask, thenPYTEST_DISABLE_PLUGIN_AUTOLOAD=1 PYTHONPATH=node:. python -B -m pytest -q bridge/test_bridge_api.py node/tests/test_base_evm_address_validation.py --noconftest --tb=short-> 46 passed - direct node bridge validator probe:
validate_chain_address_format("base", "0x" + "Z" * 40)now returns(False, "Invalid Base address format"); canonical0x+ 40 hex still returns(True, ""); uppercase0Xremains rejected.
The follow-up commit applies strict 40-hex validation to node/bridge_api.py, so the issue called out in the previous review no longer reproduces. The standalone bridge route, node bridge validator, and x402 wallet-link paths are covered by the focused tests. Approving the current head.
Reviewer wallet/miner ID for bounty #73: RTC4a92ce8abb537f827b8b0dac456242f8697c1ad6
|
Security Review ✅ Strict Base/EVM address validation requiring 0x + exactly 40 hex chars. Previous loose validation (prefix or length only) could allow crafted addresses that bypass checks — e.g. 0xGGGG... with non-hex chars, or truncated addresses that match unintended accounts. Fix applies consistently across bridge locks and x402 wallet endpoints. Reviewed by Xeophon - Solana: Lt9nERv6VHsojw15LpFeiaabuphAggzfLF9sM9UXRrZ |
jaxint
left a comment
There was a problem hiding this comment.
LGTM! Great work on this PR. 🚀
|
Closing as stale branch — would cause destructive deletions if merged. Your branch was filed roughly 155 commits behind current main. Since then, many overlapping fixes from other contributors have landed via parallel PRs. GitHub's Bounty credit acknowledgedIf your fix addressed a real bug, the canonical version has very likely already shipped via a parallel contributor's PR over the past two weeks. Specific cases covered by today's audit:
If you want fresh reviewRebase against current main and verify your diff shows roughly the size of the changes you originally made: If the deletion count is significantly higher than what you added, the branch is still picking up stale assumptions — recreate from a fresh main. Thanks for the contribution work this week. |
Summary
0xplus exactly 40 hex characters instead of only checking prefix or lengthFixes #5432
Fixes #5434
Fixes #5436
Validation
python -m py_compile bridge/bridge_api.py bridge/test_bridge_api.py node/rustchain_x402.py node/beacon_x402.py node/tests/test_base_evm_address_validation.pypython -m pytest bridge/test_bridge_api.py node/tests/test_base_evm_address_validation.py -q --tb=short-> 45 passedgit diff --check -- bridge/bridge_api.py bridge/test_bridge_api.py node/rustchain_x402.py node/beacon_x402.py node/tests/test_base_evm_address_validation.pyRTC wallet:
RTC02811ff5e2bb4bb4b95eee44c5429cd9525496e7