RebateFi Hook

First Flight #53
Beginner FriendlyDeFi
100 EXP
View results
Submission Details
Impact: low
Likelihood: medium
Invalid

State change without event

There are state variable changes in the ReFiSwapRebateHook::ChangeFee() but no event is emitted.

Description

  • The owner can change the fee using the ReFiSwapRebateHook::ChangeFee() function;

  • Off-chain systems cannot track parameter changes, because this function does not emit the event.

// Root cause in the codebase with @> marks to highlight the relevant section
function ChangeFee(bool _isBuyFee, uint24 _buyFee, bool _isSellFee, uint24 _sellFee) external onlyOwner {
if (_isBuyFee) buyFee = _buyFee;
if (_isSellFee) sellFee = _sellFee;
@>
}

Risk

Likelihood:

  • This will always occur when the owner changes the fee using the ReFiSwapRebateHook::ChangeFee() function.

Impact:

  • Impossible to track parameter changes through off-chain systems.

Proof of Concept

  1. Change buy and sell fees using the ReFiSwapRebateHook::ChangeFee() function. This function does not emit an event;
    2) Check whether the state variables have changed;\

  2. Check logs and find no events there (message: "Number of events: 0");

function test_PoC_StateChangeWithoutEvent() public {
uint24 newBuyFee = 2_000;
uint24 newSellFee = 5_000;
vm.recordLogs();
// Change buy and sell fees without emitting an event
rebateHook.ChangeFee(true, newBuyFee, true, newSellFee);
// Check that the state has changed
(uint24 buyFee, uint24 sellFee) = rebateHook.getFeeConfig();
assertEq(buyFee, newBuyFee, "Buy fee should be updated");
assertEq(sellFee, newSellFee, "Sell fee should be updated");
// Check logs
Vm.Log[] memory entries = vm.getRecordedLogs();
console.log("Number of events:", entries.length);
assertEq(entries.length, 0, "No events should be emitted");
}

Recommended Mitigation

Consider emitting an event to enable offchain indexers to track the changes.

+ event FeeChanged(bool isBuyFee, uint24 buyFee, bool isSellFee, uint24 sellFee);
// . . . .
function ChangeFee(bool _isBuyFee, uint24 _buyFee, bool _isSellFee, uint24 _sellFee) external onlyOwner {
if (_isBuyFee) buyFee = _buyFee;
if (_isSellFee) sellFee = _sellFee;
+ emit FeeChanged(_isBuyFee, buyFee, _isSellFee, sellFee);
}
Updates

Lead Judging Commences

chaossr Lead Judge
13 days ago
chaossr Lead Judge 12 days ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.

Give us feedback!