In normal behavior, the ChangeFee function allows the contract owner to update the buy and sell fees for the ReFiSwapRebateHook. These fees are used in _beforeSwap to calculate LP fee overrides, encoded with a bitmask in combination with the LPFeeLibrary.OVERRIDE_FEE_FLAG.
The issue is that there is no validation ensuring that the provided buyFee or sellFee values fit within safe numeric bounds. Without checks:
Fees exceeding the expected maximum can break LP fee encoding.
OR'ing the fee with the OVERRIDE_FEE_FLAG may unintentionally overwrite high bits, causing incorrect fee behavior or encoding invalid data that the Uniswap V4 pool cannot process.
Likelihood:
Medium, because the owner can directly call ChangeFee with arbitrary values.
Medium, if the function is misconfigured or automated scripts accidentally provide excessive values.
Impact:
The hook may encode fee values incorrectly, potentially causing swap computations to revert or misapply fees.
Users may be overcharged or undercharged, and pool invariants may break.
Explanation
By calling ChangeFee with a sellFee value larger than expected, the hook can produce an LP fee override that exceeds the bit-width of the LPFeeLibrary field. This can break swaps or result in undefined fee application.
Written explanation:
The test demonstrates that setting a fee larger than the safe maximum can break the swap due to invalid LP fee bit-packing.
This proves the absence of fee bounds validation is exploitable.
Define constants:
Validate fees in ChangeFee:
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.