The getFeesForAssetsAmountOut function in the StabilityBranch contract is vulnerable due to its reliance on the external priceX18 parameter without sufficient validation which can lead to excessive fees or denial of service.
The function calculates fees based on the priceX18 parameter, which is externally provided. If priceX18 is manipulated to be extremely low, the calculation baseFeeX18 = ud60x18(tokenSwapData.baseFeeUsd).div(priceX18) can result in an excessively high baseFeeX18, disproportionately increasing the fees charged for swaps. This could make swaps prohibitively expensive or cause the contract to revert transactions due to arithmetic overflow; if priceX18 is set to zero, it would cause a division by zero error, leading to a denial of service by halting swap operations.
The priceX18 is sourced from an untrusted input and manipulating priceX18 to be extremely low or zero.
Implement validation checks for the priceX18 parameter to ensure it's within a reasonable range and not zero before performing calculations.
Define MIN_PRICE and MAX_PRICE constants to set acceptable bounds for priceX18 and ensure priceX18 is greater than zero to prevent division by zero errors.
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.