Pre-check is not correct
A pre-check in the fillCriteriaBid function can revert a transaction even though the subsequent settlement logic would succeed. An attacker could cause a legitimate bid fill to fail under specific conditions, disrupting protocol functionality.
Submitted by 0xSky
fillCriteriaBid can be reverted due to the pre-check while it can work.
Proof of Concept
When refererrAmt > 0 and referrer address is not set (is 0), (o.totalAmt - protocolfee - o.exchange.paymentAmt - o.prePayment.paymentAmt) * amount - p.paymentAmt >= 0 and o.totalAmt < o.exchange.paymentAmt + o.prePayment.paymentAmt + o.refererrAmt can hold true at the same time.
It is when o.refererrAmt > (p.paymentAmt + protocolfee) / amount.
In that case, _settleBalances can work, but fillCriteriaBid will be reverted due to the check in line 342.
Recommended Mitigation Steps
I think require(o.totalAmt >= o.exchange.paymentAmt + o.prePayment.paymentAmt) is correct.
0xsaruman (Golom) confirmed, but disagreed with severity and commented:
Very small chance of both conditions happening,
o.refererrAmt > (p.paymentAmt + protocolfee) / amountand referrer address is 0.Resolved https://github.com/golom-protocol/contracts/commit/c15fa96271d8cf764274271eee649c79ca1b1f7d
Nice catch.
This tracks as a medium for me… it breaks protocol functionality given external factors.
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 pre-check required the total amount to cover exchange and pre-payment amounts plus the referrer fee, but the settlement logic only needed it to cover exchange and pre-payment amounts, so the check was stricter than necessary.
Impact
The function could revert when it should succeed, breaking protocol functionality under specific conditions, though the chance of both conditions occurring is very small.
What the attacker needed
RefererrAmt > 0; referrer address is zero; specific amount conditions hold
The fix
The issue was fixed by changing the pre-check to only require the total amount to cover the exchange and pre-payment amounts, not the referrer fee.
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.
Smart contracts often check conditions before doing work. Here, one check was too strict: it blocked a valid action that would have worked if allowed to continue. This meant some trades could not be completed even though they should have been.
What is Business logic?
The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.