ERC20::approve allows a token holder to give permission to anyone to spend the token on their behalf. this is normal and follows ERC20 standard. however, the issue is on how the update is done on the approval.
ERC20::approve:
ERC20Internals::_approve:
Likelihood: Medium/Low
it requires the spender to know that the token holder he'll spend on behalf will update the allowance in next transaction
it also requires that the token holder is holding at least more than the current allowance amount (before updates)
Reason 2
Impact: High
the spender can unauthorizedly spend more token than the owner intended amount to spend
user1 and user2 has some tokens (e.g. both has 50 tokens each, though user2 having tokens is entirely optional)
user1 being the owner giving permission to user2 to spend 20 tokens on user1 behalf
after the transaction has successfully submitted and executed, user1 realized that the allowance should be 30 tokens, rather than 20 tokens
user1 updates the allowance to 30 tokens
here's the catch, user2 found out user1's mistake on incorrect allowance amount, and saw the transaction submitted, user2 hold the transaction (step 4) and frontrun it by calling transaferFrom to force transfer the available allowance amount to himself
after that, user1 transaction (step 4) starts to get executed
allowance does indeed gets updated from 20 tokens to 30 tokens, but during the updates, user2 has stolen the 20 tokens from user1
rather than updates the allowance by overriding the existing amount, consider using increase/decrease (e.g. increaseAllowance(), decreaseAllowance())
as such, user1 can update the allowance by calling increaseAllowance(user2, 10 ether) to increase the allowance by 10 tokens.
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.
The contest is complete and the rewards are being distributed.