call opcode’s return value not checked.
The contract's low-level call to return leftover ETH did not check whether the call succeeded, so if the recipient contract could not receive ETH the funds stayed stuck in the aggregator. An attacker or unlucky user could lose the returned ETH, which would later be paid to another caller.
Submitted by jayphbee, also found by V_B, Decurity, gz627, joestakey, 0xc0ffEE, corerouter, SinceJuly, carlitox477, rbserver, Vadis, 0x52, chaduke, and aviggiano
Impact
The call opcode’s return value not checked, which could lead to the originator losing funds.
Proof of Concept
The caller of LooksRareAggregator.sol::execute could be a contract who may not implement the fallback or receive function, when a call to it with value sent, it will revert, thus failed to receive the ETH.
Let’s imagine the contract calls the execute function to buy multiple NFTs with ETH as the payout currency and make the isAtomic parameter being false. Since the batch buy of NFTs is not atomic, the failed transactions in LooksRare or Seaport marketplace will return the passed ETH. The contract doesn’t implement the fallback/receive function and the call opcode’s return value not checked, thus the ETH value will be trapped in the LooksRareAggregator contract until the next user call the execute function and the trapped ETH is returned to him. The originator lose funds.
function _returnETHIfAny(address recipient) internal {
assembly {
if gt(selfbalance(), 0) {
let status := call(gas(), recipient, selfbalance(), 0, 0, 0, 0) // @audit-issue status not checked.
}
}
}
Recommended Mitigation Steps
Check the return value on the call opcode.
function _returnETHIfAny() internal {
bool status;
assembly {
if gt(selfbalance(), 0) {
status := call(gas(), caller(), selfbalance(), 0, 0, 0, 0) // @audit-issue [MED] status not checked
}
}
if (!status) revert ETHTransferFail();
}
function _returnETHIfAny(address recipient) internal {
bool status;
assembly {
if gt(selfbalance(), 0) {
status := call(gas(), recipient, selfbalance(), 0, 0, 0, 0) // @audit-issue status not checked.
}
}
if (!status) revert ETHTransferFail();
}
function _returnETHIfAnyWithOneWeiLeft() internal {
bool status;
assembly {
if gt(selfbalance(), 1) {
status := call(gas(), caller(), sub(selfbalance(), 1), 0, 0, 0, 0)
}
}
if (!status) revert ETHTransferFail();
}
0xhiroshi (LooksRare) confirmed
Picodes (judge) decreased severity to Medium and commented:
Medium severity as only the dust is impacted.
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 low-level call used to return ETH ignored its success status, so a failed transfer left funds in the contract instead of reverting.
Impact
The originator could lose the returned ETH, though the judge noted that only dust amounts are affected.
What the attacker needed
Caller is a contract without receive/fallback; isAtomic set to false; some marketplace purchases fail
The fix
The return value of the call should be checked and the transaction reverted if the ETH transfer fails.
How it was found
- A contract calls execute to buy NFTs with ETH and sets isAtomic to false.
- Some marketplace purchases fail and the aggregator tries to return the leftover ETH to the calling contract.
- The calling contract cannot receive ETH because it has no fallback or receive function, so the transfer fails.
- The failed call's status is ignored, so the ETH remains trapped in the aggregator.
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, the receiving contract must have a way to accept it. If it does not, the transfer fails, but the sending code here ignored that failure. So the Ether was not returned and stayed in the aggregator contract, where someone else could later receive it.
What is Smart contracts?
Flaws in on-chain code that let an attacker drain funds, freeze them or break the protocol's accounting.