Skip to content
DoS Audit finding Intermediate

Potential DoS when removing keeper gauge

Removing a keeper gauge in the InflationManager does not check whether a TopUpActionFeeHandler still references it, so the killed gauge makes fee reporting revert. Any top-up execution then fails until governance points the fee handler at a new gauge, which the text says could delay or block top-ups during volatile markets.

shenwilly Follow

Originally disclosed on Code4rena

Submitted by shenwilly

https://github.com/code-423n4/2022-05-backd/blob/2a5664d35cde5b036074edef3c1369b984d10010/protocol/contracts/tokenomics/InflationManager.sol#L609-L618

https://github.com/code-423n4/2022-05-backd/blob/2a5664d35cde5b036074edef3c1369b984d10010/protocol/contracts/tokenomics/KeeperGauge.sol#L82

https://github.com/code-423n4/2022-05-backd/blob/2a5664d35cde5b036074edef3c1369b984d10010/protocol/contracts/actions/topup/TopUpActionFeeHandler.sol#L95-L98

https://github.com/code-423n4/2022-05-backd/blob/2a5664d35cde5b036074edef3c1369b984d10010/protocol/contracts/actions/topup/TopUpAction.sol#L807

https://github.com/code-423n4/2022-05-backd/blob/2a5664d35cde5b036074edef3c1369b984d10010/protocol/contracts/actions/topup/TopUpAction.sol#L653

Impact

When _removeKeeperGauge is called, there is no guarantee that the keeper gauge isn’t currently in use by any TopUpActionFeeHandler. If it’s still in use, any top up action executions will be disabled as reporting fees in KeeperGauge.sol will revert:

function reportFees(
    address beneficiary,
    uint256 amount,
    address lpTokenAddress
) external override returns (bool) {
    ...
    require(!killed, Error.CONTRACT_PAUSED); // gauge is killed by InflationManager
    ...
    return true;
}

If this happened during extreme market movements, some positions that require a top up will not be executed and be in risk of being liquidated.

Proof of Concept

  • Alice registers a top up action.
  • Governance calls InflationManager.removeKeeperGauge, replacing an old keeper gauge. However, governance forgot to call TopUpActionFeeHandler.prepareKeeperGauge so TopUpActionFeeHandler.getKeeperGauge still points to the killed gauge.
  • Market moved and Alice’s position should now be executed by keepers, however any attempt to execute will revert: > Keeper calls TopUpAction.execute(); > _payFees(); > IActionFeeHandler(feeHandler).payFees(); > IKeeperGauge(keeperGauge).reportFees(); > reverts as gauge is already killed
  • Governance noticed and calls prepareKeeperGauge with a 3 days delay.
  • Alice’s position got liquidated before the change is executed.

Recommended Mitigation Steps

Consider adding an on-chain check to ensure that the keeper gauge is not in use before removing them.

danhper (Backd) confirmed

Alex the Entreprenerd (judge) commented:

I believe the warden has shown a situation in which calling _removeKeeperGauge can cause payFees to revert, making it impossible (for a time) for fees to be paid.

I do not believe the impact will extend beyond:

  • Potential loss of yield (or delay)
  • Need for governance to set a new gauge

I disagree with the statement: Alice's position got liquidated before the change is executed. as no liquidation should be contingent on fees being paid from this function.

Because the finding shows how the system for fees can be stopped due to external conditions, I agree with Medium Seveirty


The original report as published on Code4rena, by shenwilly. Images and videos are our own copies; raw HTML is shown as text. View it on Code4rena.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

How it worked

Root cause

Likely the removal function does not verify that no fee handler still references the gauge being killed, leaving a stale pointer to a disabled contract.

Impact

Top-up executions could be disabled for a period, which the reporter says may put positions at risk of liquidation during extreme market movements, though the judge disputed that liquidation would follow and rated it medium.

What the attacker needed

Governance removes a gauge still in use; fee handler not updated in time

The fix

The text recommends adding an on-chain check that the keeper gauge is not in use before it is removed.

How it was found

  1. Alice registers a top up action.
  2. Governance removes the old keeper gauge without updating the fee handler, so it still points at the killed gauge.
  3. The market moves and keepers try to execute Alice's top up, but the fee payment reverts because the gauge is killed.
  4. Governance notices and schedules a fee handler update with a three day delay.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

A gauge is a contract that records and pays out fees. When governance swaps it for a new one, the old gauge is switched off, but another contract can still be pointing at it. Because the switched-off gauge refuses to accept fee reports, the whole top-up action fails until someone updates the pointer.

What is DoS?

A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.

More by shenwilly

View all

12 more disclosed reports, best first.

More from Backd Tokenomics contest

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Denial of service

The lesson behind this report.

A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.