Skip to content
DoS Audit finding Intermediate

Gas griefing is possible on external call

The Timelock contract copies all data returned by an external call into memory, so a malicious target can return a very large amount of data and force the multisig to pay excessive gas. This is a griefing attack with no direct profit for the attacker.

djxploit Follow

Originally disclosed on Immunefi

Informational View original
  • Disclosed after under an hour

28625 - [SC - Insight] Gas griefing is possible on external call

Submitted on Feb 22nd 2024 at 17:24:08 UTC by @djxploit for Boost | Puffer Finance

Report ID: #28625

Report type: Smart Contract

Report severity: Insight

Target: https://etherscan.io/address/0x3C28B7c7Ba1A1f55c9Ce66b263B33B204f2126eA#code

Impacts:

  • Griefing (e.g. no profit motive for an attacker, but damage to the users or the protocol)

Description

Brief/Intro

If an external calls returns large data, then storing it becomes costly. This will result in paying huge amount of gas for copying the returned data to memory, by the MULTISIGs

Vulnerability Details

In the function executeTransaction of Timelock.sol contract, when a transaction is executed through _executeTransaction function, it returns the status of the low-level call and any returned data.

(success, returnData) = _executeTransaction(target, callData);

The data returned by the target address, i.e returnData is copied to memory. Now if the size of the returnData is very large, then the msg.sender in our case the MULTISIGs, will have to pay a huge amount amount of gas for copying the returned data to memory

Impact Details

target addresses (malicious actors) can launch a gas griefing attack on MULTISIGs, by returning a huge size of data.

It is recommended to implement the low level call using assembly.

References

https://solodit.xyz/issues/m-03-gas-griefingtheft-is-possible-on-unsafe-external-call-pashov-none-zerem-markdown

Proof of Concept

In executeTransaction function of Timelock.sol contract

(success, returnData) = _executeTransaction(target, callData);
    function _executeTransaction(address target, bytes calldata callData) internal returns (bool, bytes memory) {
        // slither-disable-next-line arbitrary-send-eth
        return target.call(callData);
    }

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

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 uses a high-level call that automatically copies all returned data into memory without limiting its size.

Impact

A malicious target could cause the multisig to pay a large amount of gas, but the attack only wastes gas and does not steal funds.

What the attacker needed

Malicious target contract; multisig executes transaction

The fix

The low-level call should be implemented using assembly to avoid copying the returned data into memory.

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 calls another contract, the other contract can send back data. The Timelock contract copies all of that data into its own memory, which costs gas. A malicious contract can send back a huge amount of data, making the transaction very expensive for the multisig that sent it.

What is DoS?

A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.

More by djxploit

View all

4 more disclosed reports, best first.

More from Puffer Finance

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Denial of service

The lesson behind this report.

A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.