Skip to content
Smart contracts Audit finding Beginner

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.

hansfriese Follow

Originally disclosed on Code4rena

Submitted by hansfriese, also found by 0xf15ers

https://github.com/Plex-Engineer/lending-market/blob/ab31a612be354e252d72faead63d86b844172761/contracts/WETH.sol#L104

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];

nivasan1 (Canto) confirmed

Alex the Entreprenerd (judge) increased severity to High and commented:

The warden has found a minor developer oversight, which will cause the view function allowance to 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.


The original report as published on Code4rena, by hansfriese. Images and videos are our own copies; raw HTML is shown as text. View it on Code4rena.

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.

More by hansfriese

View all

65 more disclosed reports, best first.

More from Canto

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Smart contract vulnerabilities

The lesson behind this report.

Flaws in on-chain code that let an attacker drain funds, freeze them or break the protocol's accounting.