withdrawFromWETH always reverts
The withdrawFromWETH function incorrectly checks that the return data length is at least 32 bytes, but WETH.withdraw returns nothing, so the check always fails and the function reverts. This breaks unwrapWETH, causing all transactions that try to unwrap WETH through the router to revert.
Submitted by cmichel
The TridentHelper.withdrawFromWETH (used in TridentRouter.unwrapWETH) function performs a low-level call to WETH.withdraw(amount).
It then checks if the return data length is more or equal to 32 bytes, however WETH.withdraw returns void and has a return value of 0. Thus, the function always reverts even if success == true.
function withdrawFromWETH(uint256 amount) internal {
// @audit WETH.withdraw returns nothing, data.length always zero. this always reverts
require(success && data.length >= 32, "WITHDRAW_FROM_WETH_FAILED");
}
Impact
The unwrapWETH function is broken and makes all transactions revert. Batch calls to the router cannot perform any unwrapping of WETH.
Recommended Mitigation Steps
Remove the data.length >= 32 from the require and only check if success is true.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
The code incorrectly assumes WETH.withdraw returns data of at least 32 bytes, but it returns nothing, so the length check always fails.
Impact
The unwrapWETH function is broken, causing all transactions that attempt to unwrap WETH via the router to revert.
What the attacker needed
None
The fix
Remove the data.length >= 32 check and only require success to be true.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
This is a smart contract bug where a function checks for a return value that doesn't exist. The WETH withdraw function returns nothing, but the code expects some data back, so it always fails and undoes the transaction. As a result, users cannot unwrap their WETH through this router.
What is Business logic?
The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.