-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
s_poolAssets
underflow in CollateralTracker.sol
will lead to protocol failure
#38
Comments
This is correct but what would be the impact? It seems that I'll downgrade to QA |
Picodes changed the severity to QA (Quality Assurance) |
Picodes marked the issue as grade-b |
Can confirm the PoC is valid, but we are also unable to find significant impact on our end (besides some potential confusion if frontends use the values returned by |
Agreed that the impact isn't correctly described in the report. Kudos to the judge @Picodes for pointing it out. However, the following problems still occur :
Again, as the judge pointed out, there are no funds directly at risk, which is why my initial conviction that this is a High severity issue is incorrect. However, given broken functionality, temporary loss of access to funds, and violations of ERC-4626, I would like to urge the judge to re-assess and see if this should be a I trust the judge to make the correct decision here. Thanks! |
@sammy-tm my view is that this issue could have been a Medium but when judging a report we're supposed to take into account only the impacts described by this report, and in this case there is none |
Per direction from the judge, staff have marked as 1st place. Also noting there was a tie for 1st/2nd place. |
Lines of code
https://github.com/code-423n4/2024-06-panoptic/blob/153f0d82440b7e63075d55b0659706531431145f/contracts/CollateralTracker.sol#L578
Vulnerability details
s_poolAssets
can underflow inCollateralTracker.sol
. This is because, in thewithdraw()
function, the assets that the user withdraws are deducted froms_poolAssets
; however, there is no check to ensures_poolAssets >= assets
. Moreover, the updation ofs_poolAssets
is handled in an unchecked block, which makes the underflow possible.s_poolAssets
can be less thanassets
, this is because when a short option is minted, assets are moved from the Panoptic pool to the Uniswap pool. i.e, assets are deducted froms_poolAssets
and incremented ins_inAMM
.So, the underflow is possible when a large share of the deposited liquidity is in the Uniswap pool.
Impact
This breaks the functionality and accounting of the entire protocol. A number of attacks can be performed to drain the pool due to this vulnerability. An example would be :
Proof of Concept
The following test demonstrates the underflow scenario :
To run the test:
CollateralTracker.t.sol
forge test --match-test test_POC_Underflow
Tools Used
Foundry
Recommended Mitigation Steps
Remove the unchecked block.
Alternatively, add this check in
withdraw()
:Assessed type
Under/Overflow
The text was updated successfully, but these errors were encountered: