Skip to content
Business logic Audit finding Intermediate

Failed transfer with low level call could be overlooked

The `_call` function uses a low-level call and only checks the success flag, which can be true even if the target account does not exist. An attacker could cause ether to become stuck in the contract by interacting with a deleted contract.

harleythedog Follow

Originally disclosed on Code4rena

Submitted by harleythedog

Impact

The CallFacet.sol contract has the function _call :

function  _call(
	address  _target,
	bytes  memory  _calldata,
	uint256  _value
) internal {
	require(address(this).balance >= _value, "ETH_BALANCE_TOO_LOW");
	(bool success, ) = _target.call{value: _value}(_calldata);
	require(success, "CALL_FAILED");
	emit  Call(msg.sender, _target, _calldata, _value);
}

This function is utilized in a lot of different places. According to the [Solidity docs](https://code4rena.com/reports/2021-12-amun/%5Bhttps:/docs.soliditylang.org/en/develop/control-structures.html#error-handling-assert-require-revert-and-exceptions%5D(https://docs.soliditylang.org/en/develop/control-structures.html#error-handling-assert-require-revert-and-exceptions%29), “The low-level functions call, delegatecall and staticcall return true as their first return value if the account called is non-existent, as part of the design of the EVM. Account existence must be checked prior to calling if needed”.

As a result, it is possible that this call will not work but _call will not notice anything went wrong. It could be possible that a user is interacting with an exchange or token that has been deleted, but _call will not notice that something has gone wrong and as a result, ether can become stuck in the contract. For this reason, it would be better to also check for the contract’s existence prior to executing _target.call.

For reference, see a similar high severity reported in a Uniswap audit here (report # 9): https://github.com/Uniswap/v3-core/blob/main/audits/tob/audit.pdf

Proof of Concept

See _call here: CallFacet.sol L108.

Recommended Mitigation Steps

To ensure tokens don’t get stuck in edge case where user is interacting with a deleted contract, make sure to check that contract actually exists before calling it.

loki-sama (Amun) confirmed

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

Likely the contract does not check whether the target address actually contains code before making a low-level call, relying only on the success flag which is true for non-existent accounts.

Impact

Ether could become stuck in the contract if a user interacts with a deleted contract, as the call would appear successful but no transfer would occur.

What the attacker needed

User interacts with a deleted contract

The fix

The contract should check that the target address has code before making the call.

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.

A low-level call in Solidity returns true even if the target address has no code, so the contract thinks the call succeeded when it actually did nothing. This means funds sent to a non-existent contract can get stuck.

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 harleythedog

View all

14 more disclosed reports, best first.

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