Under extreme market conditions or when trading fees exhaust the vault's collateral, a withdrawal request will result in no collateral being transferred to the depositor. Instead of reverting, the system burns the depositor's shares, effectively depositors loose their funds permanenty. This vulnerability is classified as medium severity given the low-probability but high-impact nature of the issue.
During withdraw
and positionIsClosed=true
, if the vault’s collateral balance is zero, the code branch responsible for token transfers is bypassed because the calculated withdrawal amount equals zero. Instead of reverting or providing a more graceful handling, the user's shares are effectively burned.
In PerpetualVault.sol
, user starts from withdraw()
, code flow goes in _handleReturn()
:
Depositors who withdraw while the vault collateral is zero permanently lose their deposit assets.
Add test into test/PerpetualVault.t.sol
:
Run forge test --match-test test_POC_ZeroCollateralExploit --rpc-url https://arb1.arbitrum.io/rpc -vv --via-ir
Output:
its clear that even users shares burned, but no assets transferred.
Manual Review
Revert on Zero Collateral
Please read the CodeHawks documentation to know which submissions are valid. If you disagree, provide a coded PoC and explain the real likelihood and the detailed impact on the mainnet without any supposition (if, it could, etc) to prove your point.
There is no real proof, concrete root cause, specific impact, or enough details in those submissions. Examples include: "It could happen" without specifying when, "If this impossible case happens," "Unexpected behavior," etc. Make a Proof of Concept (PoC) using external functions and realistic parameters. Do not test only the internal function where you think you found something.
Please read the CodeHawks documentation to know which submissions are valid. If you disagree, provide a coded PoC and explain the real likelihood and the detailed impact on the mainnet without any supposition (if, it could, etc) to prove your point.
There is no real proof, concrete root cause, specific impact, or enough details in those submissions. Examples include: "It could happen" without specifying when, "If this impossible case happens," "Unexpected behavior," etc. Make a Proof of Concept (PoC) using external functions and realistic parameters. Do not test only the internal function where you think you found something.
Please read the CodeHawks documentation to know which submissions are valid. If you disagree, provide a coded PoC and explain the real likelihood and the detailed impact on the mainnet without any supposition (if, it could, etc) to prove your point.
There is no real proof, concrete root cause, specific impact, or enough details in those submissions. Examples include: "It could happen" without specifying when, "If this impossible case happens," "Unexpected behavior," etc. Make a Proof of Concept (PoC) using external functions and realistic parameters. Do not test only the internal function where you think you found something.
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.