-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
pashap9990 - claim_fee will be reverted because of insufficient balance #68
Comments
Need more input to see whether the attack is valid. |
@toprince
require!(
@>>> woopool.unclaimed_fee > 0 && token_vault.amount as u128 > 0,
ErrorCode::ProtocolFeeNotEnough
); Consider create a new file in test directory and place this test in that and then run Coded PoCimport * as anchor from "@coral-xyz/anchor";
}); const getReturnLog = (confirmedTransaction) => {
|
#4 isn’t a dup of this issue becuase that states
which is intended design and they want to be sure pool has enough reserve to pay swap fee #6 isn’t dup of this issue because that states
which is intened design and also they don’t need to directly send swap fee to vault sponsor comment:
|
Then explain how will your attack vector described in this issue happen ? |
root cause in this issue and #73 is same and also u can run provided PoC to be sure |
it does not look like it's a duplicate of what you say in your finding. In your poc that's exactly what happens - token vault has not enough funds when user tries to claim and you fail to explain why this happens |
I do not consider this issue as a duplicate for #73. The root cause mentioned in this report is
This report does not mention anything that's related to the issue in #73. I would even consider this report to be invalid. The checks of minimum reserve only serve as sanity checks. I agree that doing these separately on the The report considers condition where the
The report says that after the transfer of The report completely ignores the deduction of Under the mentioned conditions in this report:
The above code snippet would have reverted. If the reserve is not sufficient for woopool_quote.sub_reserve(swap_fee).unwrap(); Anyone following the textual PoC would not agree with the issue after considering the above code snippet. The coded PoC only works because of the issue #73. If #73 is not present then the coded PoC would have reverted because of the deduction from the reserves. This report was the exact reason I had the following conversation with the judge @WangSecurity : In conclusion:
|
@S3v3ru5 I agree with u my issue isn't valid because I haven't mentioned root cause in my issue |
pashap9990
High
claim_fee will be reverted because of insufficient balance
Summary
woopool_to'reserve and woopool_quote'reserve will be checked in every swap to has enough balance for user's swap and fee the protocl but mailicious user can bypass this constraints
Root Cause
swap_fee and to_amount compare with woopool_quote'reserve and woopool_to'reserve seperately which can be problematic
Internal pre-conditions
woopool_to's reserve = 990
fee_rate = 1%
price=$1
user's from_amount = 1000
PoC
user calls swap function with this parameters
[
woopool_from : woopool_usdt
woopool_to : woopool_usdc
woopool_quote: woopool_usdc
from_amount: 1000 usdt
min_to_amount:990 usdc
]
quote_amount = base_amount * price
= 1000 * 1 = 1000 usdcfee_swap = quote_amount * fee_rate
= 1000 * 1/100 = 10 usdcquote_amount = quote_amount - fee_swap
= 1000 - 10 = 990 usdcboth constraints will be passed because 990 is greater than 10 and also is greater and equal 990
finally 990 usdc sent to user from usdcpool its mean woopool_to reserve become 0 and after that, the admin calls claim_fee but his transaction will be reverted becuase token vault balance is zero[pool_reserve = 0, unclaimed_fee = 10 usdc,token_value_amount = 0]
Code Snippet
https://github.com/sherlock-audit/2024-08-woofi-solana-deployment/blob/main/WOOFi_Solana/programs/woofi/src/instructions/swap.rs#L156
https://github.com/sherlock-audit/2024-08-woofi-solana-deployment/blob/main/WOOFi_Solana/programs/woofi/src/instructions/swap.rs#L183
https://github.com/sherlock-audit/2024-08-woofi-solana-deployment/blob/main/WOOFi_Solana/programs/woofi/src/instructions/admin/claim_fee.rs#L41
Impact
claim_fee will be reverted because of insufficient balance
Mitigation
The text was updated successfully, but these errors were encountered: