The StabilityBranch.sol
contract lacks input validation for swap amounts in relation to base fees. Users can initiate swaps with amounts smaller than the required base fee, resulting in their funds becoming permanently trapped due to refund calculation underflows. A simple validation check should be added to prevent accepting swap requests with insufficient amounts.
StabilityBranch.sol:L197~490
In StabilityBranch.sol
, when users initiate swaps using the initiateSwap()
function, there is a critical validation missing that could lead to user funds becoming permanently trapped in the protocol.
The core issue lies in the relationship between swap amounts and base fees:
The initiateSwap()
function accepts swap requests without validating if the input amount is sufficient to cover the base fee
When users attempt to refund failed swaps via refundSwap()
, the function calculates the refund amount as:
If the original amountIn
was less than baseFeeUsd
, this calculation will revert due to underflow
This creates a scenario where:
Users can submit swap requests with amounts below the base fee
These requests cannot be fulfilled (due to insufficient funds for fees)
Users cannot refund them (due to underflow)
The funds become permanently trapped in the protocol
This vulnerability affects the protocol's user experience and could result in loss of user funds in edge cases where small amounts are swapped without proper validation.
Add an explicit validation in initiateSwap()
to ensure the input amount is sufficient to cover the base fee:
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.