It seems you can give arbitrary _data while calling depositTransaction function in OptimismPortal.sol. This means you can spoof a call to l2 bridge with sender as l1 bridge and thus withdraw/steal all funds as shown
This calls OTHER_MESSENGER contract's relayMessage function with _sender as L1StandardBridge and target as L2StandardBridge (as shown in step 1 payload)
Thus xDomainMsgSender is set to L1StandardBridge
xDomainMsgSender = _sender;
Now L2StandardBridge is called with args (finalizeBridgeERC20, WETH,WETH_REMOTE, ANY_ADDR, ATTACKER_ADDR, WETH_AMOUNT, "")
csanuragjain
high
Steal funds using Portal
Summary
It seems you can give arbitrary
_data
while callingdepositTransaction
function in OptimismPortal.sol. This means you can spoof a call to l2 bridge with sender as l1 bridge and thus withdraw/steal all funds as shownVulnerability Detail
depositTransaction
with below argsThis deposit transaction is recorded and executed
This calls OTHER_MESSENGER contract's
relayMessage
function with _sender as L1StandardBridge and target as L2StandardBridge (as shown in step 1 payload)Thus xDomainMsgSender is set to L1StandardBridge
Impact
Attacker can steal user and contract funds
Code Snippet
https://github.com/sherlock-audit/2023-01-optimism/blob/main/optimism/packages/contracts-bedrock/contracts/L1/OptimismPortal.sol#L358
Tool used
Manual Review
Recommendation
If
depositTransaction
function is directly called then do not allow _to address to be OTHER_MESSENGER