Skip to content
Business logic Audit finding Beginner

User’s may accidentally overpay in buyOption() and the excess will be paid to the vault creator

The buyOption() function only checked that the ETH sent was at least the premium, so a user could accidentally send more than required. Any excess was transferred to the vault creator rather than refunded, leaking value from the buyer.

BondiPestControl Follow

Originally disclosed on Code4rena

Submitted by BondiPestControl, also found by 0xf15ers, berndartmueller, cccz, csanuragjain, dipp, GimelSec, hake, horsefacts, IllIllI, jayjonah8, m9800, MadWookie, MiloTruck, pedroais, Ruhum, throttle, and VAD37

It is possible for a user purchasing an option to accidentally overpay the premium during buyOption().

Any excess funds paid for in excess of the premium will be transferred to the vault creator.

The premium is fixed at the time the vault is first created by vault.premiumIndex. Hence there is no need to allow users to overpay since there will be no benefit.

Proof of Concept

buyOption() allows msg.value > premium

        uint256 premium = getPremium(vaultId);
        require(msg.value >= premium, "Incorrect ETH amount sent");

Recommended Mitigation Steps

Consider modifying the check such that the msg.value is exactly equal to the premuim. e.g.

        uint256 premium = getPremium(vaultId);
        require(msg.value == premium, "Incorrect ETH amount sent");

outdoteth (Cally) confirmed and resolved:

this issue is fixed in: https://github.com/outdoteth/cally/pull/9

HardlyDifficult (judge) commented:

Agree with 2 (Medium) for this. The issue doesn’t really open the door for an attack, except for maybe via a malicious frontend. But it could potentially leak value in terms of over compensating the vault creator.

HickupHH3 (warden) commented:

QA report #182 should have its issue bumped up and marked as a duplicate IMO


The original report as published on Code4rena, by BondiPestControl. 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 payment check used a greater-than-or-equal comparison instead of requiring an exact match, so overpayment was accepted and the surplus was not refunded.

Impact

A buyer could lose funds by overpaying, with the excess going to the vault creator; the judge noted this does not really enable an attack except perhaps via a malicious frontend, but could leak value.

What the attacker needed

User calls buyOption(); user sends more ETH than the premium

The fix

The check should require the sent amount to equal the premium exactly; the report says this was fixed.

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 buy something, you normally pay the exact price. Here the contract only checked that you paid at least the price, not exactly the price. If you sent too much by mistake, the extra money went to the person who created the vault instead of coming back to you.

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 BondiPestControl

View all

2 more disclosed reports, best first.

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