Skip to content

fix: enforce balance-delta accounting in StandardBridge#296

Open
MrShiroLu wants to merge 1 commit into
base:mainfrom
MrShiroLu:fix/standard-bridge-balance-delta
Open

fix: enforce balance-delta accounting in StandardBridge#296
MrShiroLu wants to merge 1 commit into
base:mainfrom
MrShiroLu:fix/standard-bridge-balance-delta

Conversation

@MrShiroLu
Copy link
Copy Markdown

Summary

Closes #289.

StandardBridge._initiateBridgeERC20 credited deposits[_localToken][_remoteToken] and forwarded _amount to the remote bridge without verifying that the escrow balance actually increased by _amount. Fee-on-transfer and rebasing tokens are documented as unsupported, but they were still accepted permissionlessly — leaving the local escrow short while the full _amount is minted/released on the remote chain, eventually breaking withdrawals once the escrow is drained.

This PR measures the bridge's balance before and after safeTransferFrom and requires the delta to equal _amount. Unsupported tokens now revert at deposit time (fail closed) rather than silently underfunding the bridge.

  • src/universal/StandardBridge.sol: balance-delta check around safeTransferFrom
  • src/L1/L1StandardBridge.sol: semver bump 2.8.0 → 2.9.0
  • src/L2/L2StandardBridge.sol: semver bump 1.13.0 → 1.14.0
  • snapshots/semver-lock.json: regenerated

Test plan

  • forge test --match-contract "L1StandardBridge|L2StandardBridge|StandardBridge" — 59 passed, 0 failed
  • forge build --force clean
  • just semver-lock regenerated
  • CI green

Fee-on-transfer and rebasing tokens are documented as unsupported, but
`_initiateBridgeERC20` credited `deposits[_localToken][_remoteToken]`
and forwarded `_amount` to the remote bridge without checking that the
escrow balance actually increased by `_amount`. With a fee-on-transfer
token this leaves the local escrow short while the full `_amount` is
minted/released on the remote chain, eventually breaking withdrawals.

Take the balance before and after `safeTransferFrom` and require the
delta to equal `_amount`. Unsupported tokens now revert at deposit
time (fail closed) rather than silently underfunding the bridge.

Bump L1StandardBridge to 2.9.0 and L2StandardBridge to 1.14.0 and
regenerate snapshots/semver-lock.json.
@cb-heimdall
Copy link
Copy Markdown
Collaborator

🟡 Heimdall Review Status

Requirement Status More Info
Reviews 🟡 0/1
Denominator calculation
Show calculation
1 if user is bot 0
1 if user is external 0
2 if repo is sensitive 0
From .codeflow.yml 1
Additional review requirements
Show calculation
Max 0
0
From CODEOWNERS 0
Global minimum 0
Max 1
1
1 if commit is unverified 1
Sum 2

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.

Unsupported fee-on-transfer/rebasing tokens are accepted without balance-delta accounting

2 participants