WETH.allowance() returns wrong result
The WETH contract's allowance function is missing a return statement, so it always returns zero. This could cause other contracts that rely on it to incorrectly believe no allowance exists, potentially blocking legitimate transfers.
Originally disclosed on Code4rena
Submitted by hansfriese, also found by 0xf15ers
WETH.allowance() returns wrong result. I can’t find other contracts that use this function but WETH.sol is a base contract and it should be fixed properly.
Proof of Concept
In this function, the “return” keyword is missing and it will always output 0 in this case.
Tools Used
Solidity Visual Developer of VSCode
Recommended Mitigation Steps
L104 should be changed like below.
return _allowance[owner][spender];
Alex the Entreprenerd (judge) increased severity to High and commented:
The warden has found a minor developer oversight, which will cause the view function
allowanceto always return 0.Breaking of a core contract such as WETH is a non-starter.
Because I’ve already raised severity of #191 for similar reasons, I think High Severity is appropriate in this case.
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
Likely a missing return statement in the allowance function, causing it to always return the default value of zero.
What the attacker needed
None
The fix
The function should be fixed by adding a return statement that returns the stored allowance value.
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.
The allowance function is supposed to tell how much of your tokens someone else is allowed to spend. Because of a missing 'return' keyword, it always says zero, which could stop other programs from working properly.
What is Smart contracts?
Flaws in on-chain code that let an attacker drain funds, freeze them or break the protocol's accounting.