Skip to content
DoS Audit finding Beginner

SpeedBumpPriceGate.sol#addGate() Lack of input validation may casue div by 0 error

The addGate function in SpeedBumpPriceGate.sol does not validate that priceIncreaseDenominator is greater than zero. If set to zero, any call to passThruGate will revert due to division by zero, disrupting the gate's functionality.

WatchPug Follow

Originally disclosed on Code4rena

Submitted by WatchPug

https://github.com/code-423n4/2022-05-factorydao/blob/db415804c06143d8af6880bc4cda7222e5463c0e/contracts/SpeedBumpPriceGate.sol#L43

    gate.priceIncreaseDenominator = priceIncreaseDenominator;

If priceIncreaseDenominator is set to 0 when addGate(), in passThruGate() the tx will revert at L72 because of div by 0.

https://github.com/code-423n4/2022-05-factorydao/blob/db415804c06143d8af6880bc4cda7222e5463c0e/contracts/SpeedBumpPriceGate.sol#L71-L72

    // multiply by the price increase factor
    gate.lastPrice = (price * gate.priceIncreaseFactor) / gate.priceIncreaseDenominator;

Recommendation

Consider adding a check in addGate() to require priceIncreaseDenominator > 0.

illuzen (FactoryDAO) acknowledged, disagreed with severity and commented:

This is fine, we just add another gate, redeploy the tree and only harm done is we lost some gas.

Justin Goro (judge) commented:

While value is not leaked in this instance, this can cause functionality to be interrupted until fixed. Severity of issue will be maintained.


The original report as published on Code4rena, by WatchPug. 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 addGate function lacks a check to ensure priceIncreaseDenominator is greater than zero before assigning it.

Impact

The gate's functionality could be interrupted until fixed, but no funds are lost; the team can redeploy and only lose gas.

What the attacker needed

Ability to call addGate; set priceIncreaseDenominator to 0

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 smart contract has a function that sets a number used as a divisor. If that number is zero, any later calculation that divides by it will fail, causing the transaction to revert. This means the contract's feature stops working until the number is corrected.

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 WatchPug

View all

197 more disclosed reports, best first.

More from FactoryDAO 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.