Obedient Lava Monkey
Medium
withdrawETHWithPermit
bypasses user-specified approval limits, enabling unauthorized full withdrawals.
The missing validation of permit
for the actual amountToWithdraw
in withdrawETHWithPermit will cause unauthorized withdrawals for users as malicious actors will exploit mismatched approval limits to withdraw the user's full balance.
In WrappedTokenGatewayV3.sol
, the permit
function validates approval for amount
, but transferFrom
is called with amountToWithdraw
, potentially exceeding the user's intent.
When amount
is set to type(uint256).max
, the amountToWithdraw
value is overridden to the user's full balance, regardless of the initial amount
specified in the permit
. This creates a mismatch between the permit approval (which is for amount) and the actual amountToWithdraw
being processed.
- User signs a
permit
foramount
(e.g., limited approval). - User's
aWETH
balance is greater than or equal toamountToWithdraw
. - Function input sets
amount
to a lower value thanamountToWithdraw
ortype(uint256).max
.
No restrictions are placed on amountToWithdraw
being higher than the approved amount
.
- Attacker calls
withdrawETHWithPermit
with:
amount == permit-limited approval
.amountToWithdraw == user’s full aWETH balance
.
- Contract calls
permit
for the lesseramount
, successfully validating the signature. - Contract executes
transferFrom
withamountToWithdraw
, bypassing the intent of the user. - Excessive
aWETH
is withdrawn and unwrapped into ETH for the attacker.
The user suffers a loss of their entire aWETH
balance if amountToWithdraw
exceeds their intended withdrawal limit. The attacker gains control of the withdrawn ETH.
Validate the permit approval for amountToWithdraw instead of amount by modifying permit parameters in WrappedTokenGatewayV3.sol`
Validate the permit approval for amountToWithdraw
instead of amount
by modifying permit
parameters in WrappedTokenGatewayV3.sol