GraphToken permit() function is vulnerable to approval double spending : #293
Labels
bug
Something isn't working
QA (Quality Assurance)
Assets are not at risk. State handling, function incorrect as to spec, issues with clarity, syntax
sponsor disputed
Sponsor cannot duplicate the issue, or otherwise disagrees this is an issue
Lines of code
https://github.com/code-423n4/2022-10-thegraph/blob/309a188f7215fa42c745b136357702400f91b4ff/contracts/l2/token/GraphTokenUpgradeable.sol#L98
Vulnerability details
Description
GraphTokenUpgradeable exports a standard permit() function. If the signature checks out, it calls
_approve(_owner, _spender, _value);
This is vulnerable to a well known issue where spender of the permit can now spend previous allowance + _value, instead of just _value token. He does this by frontrunning the permit() function and spending the existing approved funds.Impact
Spender of permit may double spend user's allowance.
Proof of Concept
Alice approves Bob access to 100 Graph tokens. After thinking about it, she wants to give Bob approval for 50 more tokens. She signs a permit for 150 Graph tokens. Seeing the Permit TX in the mempool, Bob frontruns it and spends his 100 Graph tokens. Therefore, he received access to 250 total tokens.
Tools Used
Manual audit
Recommended Mitigation Steps
Permit should only be allowed to toggle between zero and non zero allowance.
Note to judges: a very similar finding appeared in Olympus where HIGH was awarded.
The text was updated successfully, but these errors were encountered: