Open code423n4 opened 1 year ago
JustDravee marked the issue as primary issue
JustDravee changed the severity to 2 (Med Risk)
mubaris marked the issue as sponsor confirmed
The frontrunning part isn't an issue on Optimism but the rest is valid
JustDravee marked the issue as selected for report
JustDravee changed the severity to 3 (High Risk)
Lines of code
https://github.com/code-423n4/2023-03-polynomial/blob/aeecafc8aaceab1ebeb94117459946032ccdff1e/src/LiquidityPool.sol#L264-L333
Vulnerability details
Impact
The preferred way for withdrawals of the Liquiditypool is to do this via a withdrawal queue. According to Polynomial
It is also stimulated to use
queueWithdraw()
overwithdraw()
by charging a withdrawalFee for direct withdrawals.QueuedWithdrawals work in two steps.
queueWithdraw()
. This burns theliquidityTokens
and adds the request to thewithdrawalQueue
.processWithdraws()
can be called to process requests in thewithdrawalQueue
that have passedminWithdrawDelay
to transfer the SUSD tokens to the user.If the processing of a
QueuedWithdraw
in thewithdrawalQueue
reverts, the queuedWithdrawalHead will never increase and further processing of the queue will be impossible. This means that any users that have placed a QueuedWithdraw after the reverting entry will have lost their liquiditytokens without receiving their SUSD.Proof of Concept
When calling the
queueWithdraw()
function, the user can provide an address of the receiver of funds. When processing the withdrawal queue, the contracts does all the required checks, and then transfers the SUSD to the provided user.If we look at the Synthetix sUSD token and it's target implementation we will find that the SUSD token transfer code is:
sUSD MultiCollateralSynth:L723-L739
This means any transfer to the SUSD proxy or implementation contract, will result in a revert. An attacker can use this to make
queueWithdraw()
request withuser=sUSDproxy
oruser=sUSD_MultiCollateralSynth
. Any user that request a Withdrawal viaqueueWithdraw()
after this, will lose their liquidity tokens without receiving their SUSD. The attacker can do this at any time, or by frontrunning a specific (large)queueWithdraw()
request.To test it, a check is added to the mock contract that is used for SUSD in the test scripts to simulate the SUSD contract behaviour:
In the test/LiquidityPool.Deposits.t.sol test file, the following was added. This results in a revert of the processWithdraws function and failing the test
Tools Used
Manual review, forge
Recommended Mitigation Steps
The processing of withdrawalQueue should have a mechanism to handle reverting QueuedWithdraw entries. Either by skipping them and/or moving them to another
failedWithdrawals
queue.