Skip to content
Smart contracts Audit finding Beginner

Missing revert keyword

A helper function intended to ensure that a delegatecall target is a contract was missing the revert keyword, so the check did nothing. An attacker could pass a non-contract address, causing the delegatecall to silently succeed without executing any code.

PwnPatrol Follow

Originally disclosed on Sherlock

Source: https://github.com/sherlock-audit/2022-08-sentiment-judging/tree/main/097-M

Found by

PwnPatrol

Summary

Missing revert keyword in functionDelegateCall bypasses an intended safety check, allowing the function to fail silently.

Vulnerability Detail

In the helper function functionDelegateCall, there is a check to confirm that the target being called is a contract.

Solidity
if (!isContract(target)) Errors.AddressNotContract;

However, there is a typo in the check that is missing the revert keyword.

As a result, non-contracts can be submitted as targets, which will cause the delegatecall below to return success (because EVM treats no code as STOP opcode), even though it doesn't do anything.

Solidity
(bool success, ) = target.delegatecall(data);
require(success, "CALL_FAILED");

Impact

The code doesn't accomplish its intended goal of checking to confirm that only contracts are passed as targets, so delegatecalls can silently fail.

Code Snippet

https://github.com/sherlock-audit/2022-08-sentiment/blob/main/protocol/src/utils/Helpers.sol#L66-L73

Solidity
    function functionDelegateCall(
        address target,
        bytes calldata data
    ) internal {
        if (!isContract(target)) Errors.AddressNotContract;
        (bool success, ) = target.delegatecall(data);
        require(success, "CALL_FAILED");
    }

Tool used

Manual Review

Recommendation

Add missing revert keyword to L70 of Helpers.sol.

Solidity
if (!isContract(target)) revert Errors.AddressNotContract;

Sentiment Team

Fixed as recommended. PR here.

Lead Senior Watson

Confirmed fix.

The original report as published on Sherlock, by PwnPatrol. Images and videos are our own copies; raw HTML is shown as text. View it on Sherlock.

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 safety check lacked the revert keyword, so it evaluated an error value but did not halt execution.

Impact

The intended safety check was ineffective, allowing delegatecalls to non-contracts to silently succeed without executing code.

What the attacker needed

Ability to supply a target address

The fix

The missing revert keyword was added to the check, and the fix was confirmed.

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 smart contract can call another contract's code using a low-level operation called delegatecall. The code tried to check that the target is a real contract, but forgot to actually stop execution when the check failed. So the call went ahead and appeared to succeed even though nothing happened.

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 PwnPatrol

View all

4 more disclosed reports, best first.

More from Sentiment Update #3

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.