code-423n4 / 2022-10-thegraph-findings

0 stars 0 forks source link

`approve` is vulnerable to frontrunning attacks #229

Closed code423n4 closed 1 year ago

code423n4 commented 1 year ago

Lines of code

https://github.com/code-423n4/2022-10-thegraph/blob/main/contracts/gateway/BridgeEscrow.sol#L29

Vulnerability details

Impact

approve function is subject to a known front-running attack. A malicious attacker can scout for a change in approval and front-run that

Reference: https://blog.smartdec.net/erc20-approve-issue-in-simple-words-a41aaf47bca6

Proof of Concept

graphToken().approve(_spender, type(uint256).max);

https://github.com/code-423n4/2022-10-thegraph/blob/main/contracts/gateway/BridgeEscrow.sol#L29

Tools Used

Manual review

Recommended Mitigation Steps

Use safeincreaseallowance() and safedecreaseallowance()

0xean commented 1 year ago

dupe of #224 - wardens QA report.