In the deposit
function in PerpetualVault
users can make a deposit to get shares. However, if the user makes a direct transfer, the user will not get shares.
The deposit
function records the deposit information in the depositInfo
mapping, adds the deposit ID to the userDeposits
mapping, and grants shares via the _mint
function. However, if someone transfers tokens directly to the contract (because the deposit
function is marked as external payable
), then the tokens will go to the contract but there is no record in depositInfo
which means the user will not get shares.
Users who transfer directly will not get any shares.
Add this to PerpetualVault.t.sol
and run it forge test --match-test test_DirectTransferVulnerability --rpc-url arbitrum -vvvv
.
Result:
Transfer of 1000 was successfully made from Alice to the vault.
Balance vault now shows 1000000000.
Total shares remain 0 even though there are tokens in the vault.
The deposits array for Alice is empty, indicating no deposits were recorded.
Manual review
Foundry
Only accept deposits via the proper deposit
function.
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.
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.
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.
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.
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.