Approve race condition in FETH
The FETH token's approve function lacks protection against the known multiple withdrawal attack, where a spender can front-run an allowance change to spend both the old and new allowances. An attacker could exploit this to transfer more tokens than the owner intended.
Submitted by 0x1f8b
Front running attack in approve.
Proof of Concept
The contract of the FETH does not have any protection against the well-known “Multiple Withdrawal Attack” attack on the Approve/TransferFrom methods of the ERC20 standard.
Although this attack poses a limited risk in specific situations, it is worth mentioning to consider it for possible future operations.
There are solutions to mitigate this front running such as, to first reduce the spender’s allowance to 0 and set the desired value afterwards; another solution could the one that Open Zeppelin offers, where the non-standard decreaseAllowance and increaseAllowance functions have been added to mitigate the well-known issues involving setting allowances.
Recommended Mitigation Steps
Add increase and decrease allowance.
NickCuso (Foundation) acknowledged and commented:
Yes, this is a good best practice to be following. We will add these functions in the near future. In the meantime we’ve added an inline comment about the potential risk.
At first we don’t expect there will be much interest in using FETH outside of Foundation itself. Thanks to the trusted relationship with the market contract, approvals are not necessary. So this is not an issue that should come up in the near term.
We are not fixing this immediately because it introduces a risk associated with another contract our users have deployed, that contract was not part of the contest repo. We are looking to patch that vulnerability and then will add
increaseAllowanceto FETH.
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
Impact
An attacker could front-run an allowance change to spend both the old and new allowances, potentially transferring more tokens than the owner intended; however, the report notes this poses a limited risk in specific situations.
What the attacker needed
Token owner changes allowance; spender can front-run transaction
The fix
The project acknowledged the issue and plans to add increaseAllowance and decreaseAllowance functions in the near future, but has not fixed it immediately due to a risk with another contract.
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 about a token contract where the owner can approve someone else to spend tokens on their behalf. If the owner changes the approved amount, the spender can quickly spend the old amount before the change and then also spend the new amount, getting more than intended. The fix is to add functions that safely increase or decrease the allowance instead of setting it directly.
What is Race condition?
Parallel requests reach a state the code assumed could not happen: a coupon used twice, a limit overrun, a check skipped.