Skip to content
Smart contracts Audit finding Intermediate

GroupBuy does not check return value of call

The GroupBuy contract sends ETH using a low-level call but does not check whether the call succeeded. If the recipient contract reverts, the ETH remains in GroupBuy while the contract still zeroes the user's contribution, causing a loss of funds for the recipient.

Lambda Follow with Trust and IllIllI

Originally disclosed on Code4rena

Submitted by Lambda, also found by Trust and IllIllI

https://github.com/code-423n4/2022-12-tessera/blob/1e408ebc1c4fdcc72678ea7f21a94d38855ccc0b/src/modules/GroupBuy.sol#L265

https://github.com/code-423n4/2022-12-tessera/blob/1e408ebc1c4fdcc72678ea7f21a94d38855ccc0b/src/modules/GroupBuy.sol#L283

Impact

Both usages of call do not check if the transfer of ETH was succesful:

payable(msg.sender).call{value: contribution}("");
...
payable(msg.sender).call{value: balance}("");

This can become very problematic when the recipient is a smart contract that reverts (for instance, temporarily) in its receive function. Then, GroupBuy still assumes that this ETH was transferred out and sets the balance to 0 or deletes userContributions[_poolId][msg.sender], although no ETH was transferred. This leads to a loss of funds for the recipient.

Proof Of Concept

We assume that the recipient is a smart contract that performs some logic in its receive function. For instance, it can be a nice feature for some people to automatically convert all incoming ETH into another token using an AMM. However, it can happen that the used AMM has too little liquidity at the moment or the slippage of a swap would be too high, leading to a revert in the receing contract. In such a scenario, the GroupBuy contract still thinks that the call was succesful, leading to lost funds for the recipient.

Recommended Mitigation Steps

require that the call was successful.

HickupHH3 (judge) commented:

Keeping as High severity because of valid use case and resulting loss of funds if the receiving contract reverts, but the tx doesn’t.

stevennevins (Tessera) confirmed and mitigated:

https://github.com/fractional-company/modular-fractional/pull/204

Status: Mitigation confirmed by gzeon, IllIllI, and Lambda.


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

Impact

If the recipient contract reverts in its receive function, the ETH stays in GroupBuy while the user's contribution is zeroed, leading to a loss of funds for the recipient.

What the attacker needed

Recipient is a contract that reverts on receive

The fix

The contract should require that the call was successful, and this was fixed according to the report.

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 a smart contract sends Ether to another contract, it uses a low-level call that returns a success flag. If the receiving contract rejects the payment, the call fails but the sending contract continues as if it worked. Here, GroupBuy ignored that flag, so it recorded the payment as done even though the Ether never left, and the user lost their claim to the funds.

What is Smart contracts?

Flaws in on-chain code that let an attacker drain funds, freeze them or break the protocol's accounting.

More by Lambda

View all

64 more disclosed reports, best first.

More from Tessera - Versus contest

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Smart contract vulnerabilities

The lesson behind this report.

Flaws in on-chain code that let an attacker drain funds, freeze them or break the protocol's accounting.