Race condition on ERC20 approval #86
Labels
1 (Low Risk)
Assets are not at risk. State handling, function incorrect as to spec, issues with comments
bug
Something isn't working
duplicate
This issue or pull request already exists
sponsor acknowledged
Technically the issue is correct, but we're not going to resolve it for XYZ reasons
Handle
WatchPug
Vulnerability details
https://github.com/code-423n4/2021-12-nftx/blob/194073f750b7e2c9a886ece34b6382b4f1355f36/nftx-protocol-v2/contracts/solidity/token/ERC20Upgradeable.sol#L292-L298
Using approve() to manage allowances opens yourself and users of the token up to frontrunning.
Best practice, but doesn't usually matter.
Explanation of this possible attack vector
See also: 0xProject/0x-monorepo#850
A potential fix includes preventing a call to approve if all the previous tokens are not spent through adding a check that the allowed balance is 0:
require(allowed[msg.sender][_spender] == 0)
.The text was updated successfully, but these errors were encountered: