There is a critical vulnerability in the PerpetualVault contract where execution fee refunds are processed using the wrong deposit ID (counter
instead of depositId
), which could lead to refunds being sent to incorrect users or transactions failing.
The vulnerability appears in two locations:
Key issues:
Uses global counter
variable instead of the specific depositId
counter
increments with each new deposit
depositId
and counter
may reference different deposits
Wrong Recipient: Execution fee refunds could be sent to incorrect users
Lost Funds: Users might not receive their rightful refunds
Failed Transactions: If counter
references a non-existent deposit
Financial Loss: Potential for users to lose execution fees
Trust Issues: Incorrect fund distribution affects protocol reliability
Manual code review
Static analysis
Replace counter
with depositId
in both locations:
Add input validation for deposit IDs
Implement an event for fee refunds
Consider adding a dedicated fee tracking system
Add test cases specifically for execution fee refund scenarios
Likelihood: Medium/High, when withdraw on a 1x vault. Impact: High, the fees will be distributed to the last depositor and not the withdrawer.
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.