Stealing Wrapped Manifest in WETH.sol
The WETH contract had an approve function that let any caller set an allowance on behalf of any token owner. An attacker could therefore approve themselves to spend another user's tokens and then use transferFrom to steal them.
Submitted by Soosh, also found by 0x52, 0xDjango, cccz, saian, TerrierLover, WatchPug, and zzzitron
Allows anyone to steal all wrapped manifest from the WETH.sol contract. Attacker can also withdraw to convert Wrapped Manifest to Manifest.
Issue in approve(address owner, address spender) external function. This allows an attacker to approve themselves to spend another user’s tokens.
Attacker can then use transferFrom(address src, address dst, uint wad) function to send tokens to themself.
Proof of Concept
See warden’s full report for further details.
Tools Used
VScode, hardhat
Recommended Mitigation Steps
I believe there is no need for this function. There is another approve(address guy, uint wad) function that uses msg.sender to approve allowance. There should be no need for someone to approve another user’s allowance.
Remove the approve(address owner, address spender) function.
Alex the Entreprenerd (judge) commented:
The warden has shown how, for whatever reason, an approve function which allows to pass the “approver” as parameter was present in the WETH contract.
This allows anyone, to steal all WETH from any other holder.
For that reason, High Severity is appropriate.
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 approve function took an arbitrary owner address instead of using msg.sender, so any caller could set an allowance for any token holder.
Impact
An attacker could steal all wrapped tokens from any holder and convert them to the underlying token.
What the attacker needed
None
The fix
The vulnerable approve function should be removed, leaving only the standard approve function that uses msg.sender.
How it was found
- Call the approve function, passing the victim's address as owner and the attacker's address as spender.
- Call transferFrom to move the victim's tokens to the attacker's address.
- Optionally withdraw to convert the wrapped tokens back to the underlying token.
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.
In many token contracts, an owner can let another address spend their tokens by calling an approve function. Here, the approve function also accepted the owner's address as a parameter, so anyone could pretend to be the owner and grant themselves permission to spend that person's tokens. They could then transfer those tokens to themselves.
What is Access control?
A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.