Open sherlock-admin3 opened 2 months ago
Good point. Need further investigation.
The protocol team fixed this issue in the following PRs/commits: https://github.com/woonetwork/WOOFi_Solana/pull/44
A min_swap_amount
is added to protect against zero-amount swaps.
Mansa11
Medium
Zero-Amount Swap Vulnerability in WOOFi Solana Protocol
Summary
This protocol's
swap
function allows for zero-amount swaps, potentially leading to unintended protocol behavior, unnecessary gas consumption, and possible exploitation of price oracle updates.Relevant links
https://github.com/sherlock-audit/2024-08-woofi-solana-deployment/blob/main/WOOFi_Solana/programs/woofi/src/instructions/swap.rs#L135-L149
Details
The
swap
function in the WOOFi Solana protocol does not explicitly check for zero-amount swaps. When a user initiates a swap with a zero amount, the following sequence of events occurs:swap_math::calc_quote_amount_sell_base
function processes the zero amount without error, returning zero for the quote amount.This behavior, while not causing panics or runtime errors, can lead to inconsistent protocol state and potential exploitation.
Impact
The impact of this vulnerability includes:
Code snippet
Recommendation
Implement a minimum swap amount check at the beginning of the swap handler function. This check should reject any swap attempts with zero or very small amounts that could lead to the identified issues. For example:
You may also deode to Define
MINIMUM_SWAP_AMOUNT
as a constant that represents the smallest acceptable swap amount for the protocol. This will prevent zero-amount swaps and their associated issues while maintaining the integrity of the protocol's operations.