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.
Submitted by WatchPug
gate.priceIncreaseDenominator = priceIncreaseDenominator;
If priceIncreaseDenominator is set to 0 when addGate(), in passThruGate() the tx will revert at L72 because of div by 0.
// 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.
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.