Skip to content
DoS Audit finding Intermediate

Mitigate Griefing Attacks Theft of Gas by Impl

The Timelock contract's executeTransaction function makes an external call without limiting the gas forwarded or protecting against large return data. A malicious target contract could return a huge payload, forcing the admin to pay excessive gas for memory allocation, or consume most of the forwarded gas for its own purposes.

Breeje Follow

Originally disclosed on Immunefi

Informational View original
  • Disclosed after under an hour

26529 - [SC - Insight] Mitigate Griefing Attacks Theft of Gas by Impl...

Submitted on Dec 4th 2023 at 14:47:40 UTC by @Breeje for Boost | DeGate

Report ID: #26529

Report type: Smart Contract

Report severity: Insight

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

Impacts:

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

Description

Description

There are couple of issues related to External Call in executeTransaction.

Solidity
File: Timelock.sol

102:     (bool success, bytes memory returnData) = target.call{value: value}(callData);
102:     require(success, "Timelock::executeTransaction: Transaction execution reverted.");

Checkout PoC for detail.

Recommendation

  • To address the issue to prevent potential Griefing Attacks, it is recommended to implement protection against Return Data Bombs. Consider using ExcessivelySafeCall when interacting with untrusted contracts. This solution aims to safeguard against excessive gas costs incurred during memory allocation for large return data payloads, enhancing the security of the Timelock contract.
  • To address the issue to prevent Gas Theft, cap the amount of gas used in the external call by passing it as a parameter.

Proof of concept

The Timelock functionality works as:

  1. The admin adds a transaction to a queue.
  2. After a specified eta, the transaction can be triggered by the admin using the executeTransaction function.
  3. A potential vulnerability arises when the Timelock is employed for an external target with specific execution, as it opens the door for a malicious return of a Gas Bomb via the fallback function.

In executeTransaction function, which interacts with an external contract (target), there is no protection against such large return data in the form of a Gas Bomb.

Actually, the way it works is the bytes memory returnData that was returned from the target will be copied to memory. Memory allocation becomes very costly if the payload is big, so this means that if a target implements a fallback function that returns a huge payload, then the msg.sender of the transaction, in our case the admin, will have to pay a huge amount of gas for copying this payload to memory.

Secondly, there is no cap on the amount of gas passed to the external call.

This means that the target address that has been called is now able to spend unbounded gas (up to 63/64% of the gas provided by the caller) on other activities like gas token minting.

If you are unfamiliar with gas token minting then I think this is a good article that talks about the topic in more depth: https://medium.com/hackernoon/potential-attack-on-ethereum-network-to-mint-gastokens-5cf05a7e0303

The original report as published on Immunefi, by Breeje. 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 external call in executeTransaction does not cap the gas forwarded and does not guard against large return data, allowing a malicious target to cause excessive gas costs.

Impact

The admin could pay excessive gas for memory allocation, and the target could consume up to 63/64 of the provided gas for its own activities, causing griefing and theft of gas.

What the attacker needed

Admin queues a transaction to a malicious target; malicious target has a fallback function

The fix

The contract should use a safe call library that limits return data size and should cap the gas passed to the external call.

How it was found

  1. The admin adds a transaction to a queue.
  2. After a specified eta, the admin triggers the transaction using executeTransaction.
  3. The target contract's fallback function returns a huge payload, causing high memory allocation costs for the admin.

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 and receive data back. If the called contract is malicious, it can send back a very large amount of data, which costs the caller extra fees to store temporarily. Also, the caller does not limit how much of its own gas allowance the called contract can use, so the called contract can waste 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 Breeje

View all

6 more disclosed reports, best first.

More from DeGate

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.