Protocol is wrongly refunding too many funds in a swap #13
Labels
3 (High Risk)
Assets can be stolen/lost/compromised directly
bug
Something isn't working
duplicate-5
🤖_02_group
AI based duplicate group recommendation
satisfactory
satisfies C4 submission criteria; eligible for awards
sufficient quality report
This report is of sufficient quality
Lines of code
https://github.com/code-423n4/2024-10-superposition/blob/7ad51104a8514d46e5c3d756264564426f2927fe/pkg/seawater/src/lib.rs#L290-L297
Vulnerability details
Impact
AMM is providing excessive refunds for each swap, which may result in the funds being drained.
Proof of Concept
This previous issue wasn't fixed properly:
code-423n4/2024-08-superposition-findings#12
With the current new logic, users are refunded with an excessive amount of tokens:
https://github.com/code-423n4/2024-10-superposition/blob/7ad51104a8514d46e5c3d756264564426f2927fe/pkg/seawater/src/lib.rs#L290-L297
The issue was that an user was paying
original_amount
even if the actual swap was onlyamount_in
, but now:amount_in
(the actual swap amount)amount_out
(the actual swap amount)This can be abused to drain all the funds from the AMM.
Recommended mitigation steps
Consider removing the last transfer:
The text was updated successfully, but these errors were encountered: