Skip to content
Business logic Audit finding Beginner

fillAsk() Allows for msg.value to be larger than require locking the excess in the contract

The fillAsk() function only checks that msg.value is at least the required amount, not exactly equal, so any excess Ether sent is permanently locked in the contract. An attacker could deliberately overpay to trap funds, or a user might accidentally lose money.

AuditsAreUS Follow

Originally disclosed on Code4rena

Submitted by AuditsAreUS, also found by 0xSky, arcoun, bin2chen, cccz, CertoraInc, codexploder, cryptonue, dipp, GimelSec, GiveMeTestEther, Green, horsefacts, jayphbee, joestakey, Lambda, minhquanym, obront, peritoflores, rbserver, reassor, rotcivegaf, Ruhum, RustyRabbit, scaraven, Treasure-Seeker, Twpony, and ych18

GolomTrader.sol#L217

It is possible to send a higher msg.value than is required to fillAsk(). The excess value that is sent will be permanently locked in the contract.

Proof of Concept

There is only one check over msg.value and it is that it’s greater than o.totalAmt * amount + p.paymentAmt. As seen in the following code snippet from #217.

        require(msg.value >= o.totalAmt * amount + p.paymentAmt, 'mgmtm');

The issue here is that the contract will only ever spend exactly o.totalAmt * amount + p.paymentAmt. Hence if msg.value is greater than this then the excess value will be permanently locked in the contract.

Recommended Mitigation Steps

To avoid this issue consider enforcing a strict equality.

        require(msg.value == o.totalAmt * amount + p.paymentAmt, 'mgmtm');

0xsaruman (Golom) confirmed

0xsaruman (Golom) disagreed with severity and commented:

Resolved: https://github.com/golom-protocol/contracts/commit/366c0455547041003c28f21b9afba48dc33dc5c7#diff-63895480b947c0761eff64ee21deb26847f597ebee3c024fb5aa3124ff78f6ccR217

Disagree with severity cause it’s user choice to send more.

LSDan (judge) commented:

I agree with this being a medium. It opens up the potential for griefing attacks and all sorts of other issues that may be beyond the scope of “the user decided to send excess funds”. Further, it’s common for contracts to return excess funds, so the user may reasonably expect this behaviour.


The original report as published on Code4rena, by AuditsAreUS. 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

The contract uses a greater-than-or-equal check on msg.value instead of requiring exact equality, and it never refunds the excess.

Impact

Excess Ether sent to fillAsk() is permanently locked in the contract, which could be used for griefing or cause accidental loss of funds.

What the attacker needed

User sends more Ether than required

The fix

The issue was fixed by changing the check to require strict equality between msg.value and the required amount.

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.

When you call a function that accepts Ether, you send some amount of Ether along with the call. This contract only checks that you sent at least enough, not exactly enough. If you send more than needed, the extra Ether stays stuck in the contract forever because there is no way to withdraw it.

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.

More by AuditsAreUS

View all

9 more disclosed reports, best first.

More from Golom contest

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Business logic flaws

The lesson behind this report.

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.