You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Incorrect Approval Amount for WrsETH Withdrawal Leading to Potential Transaction Failures
Summary
In the transferFundsToGlobal function of the Treasury contract, there is a critical issue where the approval amount for WrsETH withdrawal uses the wrong index from the transferAmounts array. The function approves transferAmounts[1] (WeETH amount) instead of transferAmounts[2] (WrsETH amount) when handling WrsETH withdrawals, potentially leading to transaction failures or excessive approvals.
Root Cause
The root cause is a logical error in the approval call within the WrsETH handling block: Treasury.sol#L782-L783
functiontransferFundsToGlobal(uint256[4]memorytransferAmounts)externalonlyCoreContracts{// Loop through the array to transfer all amountsfor(uint8i=0;i<4;i++){if(transferAmounts[i]>0){addressassetAddress=borrow.assetAddress(IBorrowing.AssetName((i==3 ? 4 : i)+1));if(i!=0){if(i==2){
@>if(!IWrsETH(assetAddress).approve(assetAddress,transferAmounts[1]))revertTreasury_ApproveFailed();IWrsETH(assetAddress).withdraw(borrow.assetAddress(IBorrowing.AssetName.rsETH),transferAmounts[2]);assetAddress=borrow.assetAddress(IBorrowing.AssetName.rsETH);}boolsuccess=IERC20(assetAddress).transfer(msg.sender,transferAmounts[i]);if(!success)revertTreasury_TransferFailed();}else{(boolsent,)=payable(msg.sender).call{value: transferAmounts[i]}("");require(sent,"Failed to send Ether");}}}}
The code incorrectly uses transferAmounts[1] (WeETH amount) instead of transferAmounts[2] (WrsETH amount) for the approval.
The function must be called by a core contract (enforced by onlyCoreContracts modifier)
transferAmounts[2] (WrsETH amount) must be greater than 0
The contract must be processing index 2 in the loop (WrsETH handling)
External pre-conditions
The Treasury contract must have sufficient WrsETH balance
Attack Path
A core contract calls transferFundsToGlobal with different amounts for WeETH and WrsETH
When i == 2 (WrsETH processing):
If transferAmounts[1] (WeETH) < transferAmounts[2] (WrsETH)
The approval amount will be insufficient
The subsequent withdrawal will fail
Impact
If WeETH amount is less than WrsETH amount, withdrawals will fail
PoC
No response
Mitigation
// Replace this line:if(!IWrsETH(assetAddress).approve(assetAddress,transferAmounts[1]))revertTreasury_ApproveFailed();// With:if(!IWrsETH(assetAddress).approve(assetAddress,transferAmounts[2]))revertTreasury_ApproveFailed();
The text was updated successfully, but these errors were encountered:
Bitter Crepe Lizard
High
Incorrect Approval Amount for
WrsETH
Withdrawal Leading to Potential Transaction FailuresSummary
In the
transferFundsToGlobal
function of the Treasury contract, there is a critical issue where the approval amount forWrsETH
withdrawal uses the wrong index from thetransferAmounts
array. The function approvestransferAmounts[1]
(WeETH amount) instead oftransferAmounts[2]
(WrsETH amount) when handlingWrsETH
withdrawals, potentially leading to transaction failures or excessive approvals.Root Cause
The root cause is a logical error in the approval call within the
WrsETH
handling block:Treasury.sol#L782-L783
The code incorrectly uses
transferAmounts[1]
(WeETH amount) instead oftransferAmounts[2]
(WrsETH amount) for the approval.Internal pre-conditions
onlyCoreContracts
modifier)transferAmounts[2]
(WrsETH amount) must be greater than 0External pre-conditions
Attack Path
transferFundsToGlobal
with different amounts forWeETH
andWrsETH
Impact
If
WeETH
amount is less thanWrsETH
amount, withdrawals will failPoC
No response
Mitigation
The text was updated successfully, but these errors were encountered: