Excessive Token Withdrawal in ERC20 Bridging Finalization
Summary
The finalizeBridgeERC20 function in the StandardBridge abstract contract lacks sufficient checks on the deposit balance before decrementing it. This could allow malicious actors to withdraw more tokens than they have deposited, leading to significant financial losses.
Vulnerability Detail
The vulnerability arises from the lack of a proper balance check before decrementing the deposits[_localToken][_remoteToken] mapping.
The line deposits[_localToken][_remoteToken] = deposits[_localToken][_remoteToken] - _amount; does not verify if the current deposit balance is sufficient to cover _amount. If _amount exceeds the available balance, a malicious actor could manipulate this to withdraw more tokens than they have actually deposited.
A malicious actor could exploit this vulnerability by triggering a call to finalizeBridgeERC20 with an _amount greater than the available deposit balance. Without proper checks, the attacker could withdraw more tokens than they have deposited, leading to unauthorized token transfers.
Impact
Unauthorized withdrawal of tokens could lead to significant financial losses for the contract's stakeholders.
Implement Balance Check: Ensure that the deposit balance is sufficient before performing the subtraction. Add a check to prevent excessive withdrawals.
JuggerNaut63
High
Excessive Token Withdrawal in ERC20 Bridging Finalization
Summary
The
finalizeBridgeERC20
function in theStandardBridge
abstract contract lacks sufficient checks on the deposit balance before decrementing it. This could allow malicious actors to withdraw more tokens than they have deposited, leading to significant financial losses.Vulnerability Detail
The vulnerability arises from the lack of a proper balance check before decrementing the
deposits[_localToken][_remoteToken]
mapping.The line
deposits[_localToken][_remoteToken] = deposits[_localToken][_remoteToken] - _amount;
does not verify if the current deposit balance is sufficient to cover_amount
. If_amount
exceeds the available balance, a malicious actor could manipulate this to withdraw more tokens than they have actually deposited.A malicious actor could exploit this vulnerability by triggering a call to
finalizeBridgeERC20
with an_amount
greater than the available deposit balance. Without proper checks, the attacker could withdraw more tokens than they have deposited, leading to unauthorized token transfers.Impact
Unauthorized withdrawal of tokens could lead to significant financial losses for the contract's stakeholders.
Code Snippet
https://github.com/sherlock-audit/2024-08-tokamak-network/blob/main/tokamak-thanos/packages/contracts-bedrock/src/universal/StandardBridge.sol#L278-L305
Tool used
Manual Review
Recommendation
Implement Balance Check: Ensure that the deposit balance is sufficient before performing the subtraction. Add a check to prevent excessive withdrawals.