approve() function can be front run by the spender
Summary
in Pool.sol the approve() function can be front run by the spender to get more allowance to spend
Vulnerability Detail
The approve function can be front run to give the spender more allowance to spend on because if let's say person A calls the approve function to approve person B to spend 10 shares of pool token on behalf of person A. Then person A decides to lower the amount of allowance person B gets from 10 shares to 5 shares. person B, sees this on the mempool and then decides to front run person A's transaction by calling tranferFrom() to transfer 10 shares of pool tokens to an address. When person A's transaction is finished, person B then gets another 5 shares of allowance to transfer.
Handle
medium
approve() function can be front run by the spender
Summary
in Pool.sol the
approve()
function can be front run by the spender to get more allowance to spendVulnerability Detail
The
approve
function can be front run to give the spender more allowance to spend on because if let's say person A calls the approve function to approve person B to spend 10 shares of pool token on behalf of person A. Then person A decides to lower the amount of allowance person B gets from 10 shares to 5 shares. person B, sees this on the mempool and then decides to front run person A's transaction by callingtranferFrom()
to transfer 10 shares of pool tokens to an address. When person A's transaction is finished, person B then gets another 5 shares of allowance to transfer.Impact
person A will get more allowance to spend
Code Snippet
https://github.com/sherlock-audit/2023-02-surge/blob/main/surge-protocol-v1/src/Pool.sol#L299-L303
https://github.com/sherlock-audit/2023-02-surge/blob/main/surge-protocol-v1/src/Pool.sol#L284-L293
Tool used
Manual Review
Recommendation
Duplicate of #154