The _transferToken
function in PerpetualVault contract has a critical reentrancy vulnerability combined with inconsistent state management that could lead to fund loss and incorrect accounting.
Key issues:
Multiple external calls before state changes
No reentrancy guard
Inconsistent use of SafeERC20 (mixes safeTransfer and transfer)
State changes occur after external calls
No zero-address validation for recipient
High severity - The vulnerability could lead to:
Reentrancy attacks through malicious tokens
Double withdrawals
Incorrect deposit amount accounting
Loss of funds through failed transfers
Inconsistent contract state
Manual code review
Static analysis
Add nonReentrant modifier
Use SafeERC20 consistently
Add comprehensive input validation
Consider implementing a withdrawal pattern
Add more detailed events for better tracking
Add comprehensive test coverage for edge cases
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.