Incorrect redeemAmount Is Accounted Due To Not Accounting For The Exchange Rate
The protocol incorrectly accounted for redemption assets (RA) when liquidating LP tokens, failing to apply the exchange rate between CT/DS and RA. This could lead to incorrect amounts of RA being reserved and withdrawn.
0x73696d616f Follow with 0xNirix, Ace-30 and 6 others
Originally disclosed on Sherlock
Source: https://github.com/sherlock-audit/2024-08-cork-protocol-judging/issues/119
Found by
0x73696d616f, 0xNirix, Ace-30, KupiaSec, Pheonix, korok, oxelmiguel, sakshamguruji, vinica_boy
Summary
When Liquidating LP , DS and CT are paired , then that amount is used to redeem RA . But the accounting for RA has been done incorrectly since it does not account for exchange rate.
Vulnerability Detail
1.) Inside Liquidate LP we empty out the DS reserve and pair it up with the CT amount returned from the AMM ->
This is the amount of CtDs being redeemed.
2.) This same amount has been accounted for the increment in RA ->
But this is incorrect , this is because redeemAmount is an amount in Ct/Ds not in RA , to make it into RA we need to apply the exchange rate over it(exchange rate is how many Redemption Assets you need to deposit to receive 1 Cover Token + 1 Depeg Swap and how many Redemption Assets you receive when redeeming 1 Pegged Asset + 1 Depeg Swap , read more in the Dealing with non-rebasing Pegged Assets section -> https://corkfi.notion.site/Cork-Protocol-Litepaper-f21a57d5c19d48209dfa0f0c2ab776c4).
3.) Therefore incorrect RA amount has been accounted and incorrect amount of RA would be reserved ->
meaning , incorrect amount of RA attributed to be withdrawn/redeemed.
4.) This inconsistency is found at multiple places , and instead of making separate reports im listing them here ->
The amount here is in RA and we are issuing DS/CT with it.
dsAttributed is in DS and we are depositing RA.
redeemAmount is in Ct/Ds here
Impact
Code Snippet
Tool used
Manual Review
Recommendation
Account for the exchange rate correctly.
Discussion
ziankork
This is valid, will fix
sherlock-admin2
The protocol team fixed this issue in the following PRs/commits: https://github.com/Cork-Technology/Depeg-swap/pull/81
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the code treated an amount denominated in CT/DS tokens as if it were already in RA tokens, without multiplying by the exchange rate.
Impact
Incorrect amounts of RA could be attributed and withdrawn, potentially causing loss of funds for the protocol or users.
What the attacker needed
None
The fix
The issue was fixed by the protocol team.
How it was found
- Liquidate LP tokens, which pairs DS and CT amounts.
- Use the paired amount to redeem RA without applying the exchange rate.
- Account the same amount as an increase in RA, leading to incorrect RA reserves.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
When users redeem assets, the protocol must convert between different token types using an exchange rate. Here, it forgot to apply that rate, so the recorded amount of redemption assets was wrong, potentially letting users withdraw more or less than they should.
What is Business logic?
The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.