Backd Tokenomics contest - shenwilly's results

Maximize the power of your assets and start earning yield

General Information

Platform: Code4rena

Start Date: 27/05/2022

Pot Size: $75,000 USDC

Total HM: 20

Participants: 58

Period: 7 days

Judge: GalloDaSballo

Total Solo HM: 15

Id: 131

League: ETH

Backd

Findings Distribution

Researcher Performance

Rank: 12/58

Findings: 2

Award: $2,852.35

🌟 Selected for report: 1

🚀 Solo Findings: 1

Findings Information

🌟 Selected for report: shenwilly

Labels

bug
2 (Med Risk)
sponsor confirmed

Awards

2732.5332 USDC - $2,732.53

External Links

Lines of code

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

Vulnerability details

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.

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

#0 - GalloDaSballo

2022-06-22T14:32:19Z

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

Awards

119.8232 USDC - $119.82

Labels

bug
QA (Quality Assurance)
resolved
sponsor confirmed

External Links

Low Risk Vulnerabilities

1. No function to remove gauge from whitelist

If governance mistakenly whitelisted a faulty/malicious gauge, there is no way to remove it. A malicious gauge could mint as much $BKD as it's currently available according to the inflation schedule, in detriment of other gauges' allocation.

Unless there's a reason not to, consider adding a function to remove gauge from whitelist in InflationManager.sol:

function blacklistGauge(address gauge) external override onlyRoles(Roles.GOVERNANCE) { gauges[gauge] = false; }

#0 - GalloDaSballo

2022-06-22T21:47:28Z

Agree with the finding, given other findings in the contest it would be ideal to be able to remove gauges

AuditHub

A portfolio for auditors, a security profile for protocols, a hub for web3 security.

Built bymalatrax © 2024

Auditors

Browse

Contests

Browse

Get in touch

ContactTwitter