Skip to content
DoS Audit finding Advanced

Gas costs are severely underpriced for certain WASM instructions which can lead to network DoS

The gas metering for WebAssembly instructions in the SEDA Protocol charges a flat fee for most operations, including expensive ones like TableGrow and MemoryFill. An attacker could craft a malicious oracle program that repeatedly uses these underpriced instructions to consume excessive computational resources and potentially crash nodes, causing a network denial of service.

tallo Follow

Originally disclosed on Sherlock

Source: https://github.com/sherlock-audit/2024-12-seda-protocol-judging/issues/183

Found by

tallo

Summary

Insufficient gas pricing for complex WebAssembly operations will cause a denial of service vulnerability for the SEDA Protocol as malicious actors will exploit underpriced operations like TableGrow, MemoryFill, and complex math functions to consume disproportionate computational resources while paying minimal gas fees.

Root Cause

metering.rs uses a flat cost model for all instructions except for accounting operations and MemoryGrow. https://github.com/sherlock-audit/2024-12-seda-protocol/blob/main/seda-wasm-vm/runtime/core/src/metering.rs#L51

Rust
pub fn get_wasm_operation_gas_cost(operator: &Operator) -> u64 {
    if is_accounting(operator) {
        return GAS_PER_OPERATION * GAS_ACCOUNTING_MULTIPLIER;
    }

    match operator {
        Operator::MemoryGrow { mem, mem_byte: _ } => {
            GAS_MEMORY_GROW_BASE + ((WASM_PAGE_SIZE as u64 * *mem as u64) * GAS_PER_BYTE)
        }
        _ => GAS_PER_OPERATION,
    }
}

The absence of specific, higher gas costs for computationally expensive operations like TableGrow, MemoryFill, TableCopy, and complex mathematical functions creates a significant imbalance between the gas paid and computational resources consumed.

Internal Pre-conditions

  1. User oracle program needs to be registered with the blockchain
  2. A data request needs to be made which makes use of the oracle program

External Pre-conditions

None

Attack Path

  1. Attacker crafts a malicious Oracle Program that heavily utilizes underpriced operations (e.g., repeated TableGrow, MemoryFill, or computationally intensive mathematical functions)
  2. Attacker submits this Oracle Program to the SEDA Protocol through a data request
  3. Oracle Program executes on the SEDA Network, consuming disproportionate computational resources while paying minimal gas fees
  4. Each execution consumes only GAS_PER_OPERATION (115) gas units despite potentially requiring orders of magnitude more computational resources
  5. Multiple malicious requests can be submitted to amplify the attack's impact, causing significant resource exhaustion across the network

Impact

The impact changes depending on the instruction:

  1. TableGrow: this instruction will allocate new table entries in WebAssembly, a malicious program could call this with a large size parameter and force the host environment to allocate a large amount of memory until the node crashes
  2. MemoryFill/MemoryFill: These operations allows for filling a range of memory with a specific value. A malicious program could call this repeatedly call this to consume all computation resources and delay program execution termination indefinitely
  3. MemoryInit/TableInit: similar to MemoryFill
  4. Sin/cos/exp/log/div/sqrt: much more expensive than the more basic operations and should have a higher gas price

Considering that all these operations are done in the context of Endblock, each one of these can severely DoS the entire network and cause nodes to crash. At a price of 115 gas for each instruction, its essentially free for a malicious program to severely harm the network.

Tally WASM VM Robustness: The robustness of the Tally WASM VM is critical to ensuring uninterrupted operations. Possible denial-of-service (DoS) vectors or unexpected behavior could lead to operational disruptions, affecting data request execution and overall system stability.

Mitigation

Target each of the discussed wasm instructions and apply more granular gas cost measurements

Discussion

sherlock-admin2

The protocol team fixed this issue in the following PRs/commits: https://github.com/sedaprotocol/seda-wasm-vm/pull/59

The original report as published on Sherlock, by tallo. 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 gas metering function assigns a flat cost to all instructions except accounting operations and MemoryGrow, so computationally expensive instructions are underpriced.

Impact

Depending on the instruction, an attacker could force large memory allocations that crash nodes or consume all computation resources, potentially causing a network-wide denial of service, especially since these operations occur during Endblock.

What the attacker needed

User oracle program registered with the blockchain; A data request that uses the oracle program

The fix

The protocol team fixed this issue by applying more granular gas cost measurements for the discussed WebAssembly instructions.

How it was found

  1. Craft a malicious oracle program that heavily uses underpriced operations such as TableGrow, MemoryFill, or intensive math functions.
  2. Submit the oracle program to the SEDA Protocol via a data request.
  3. The program executes on the network, consuming disproportionate resources while paying minimal gas.
  4. Repeat submissions to amplify resource exhaustion across the network.

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.

In blockchain systems, users pay 'gas' to run programs, and each operation should cost gas roughly in line with how much work it takes. Here, many heavy operations were charged the same low flat fee as simple ones, so an attacker could run lots of expensive work cheaply and overwhelm the network.

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 tallo

View all

1 more disclosed report, best first.

More from SEDA Protocol

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.