Skip to content
DoS Audit finding Intermediate

Malicious WASM program can cause denial of service attack against SEDA validators through unbounded stdout/stderr

The SEDA protocol's WASM runtime lacks size limits on stdout/stderr output, allowing a malicious WASM module to generate excessive output (up to 8GB per request) and exhaust validator memory. An attacker could submit multiple such requests to cause denial of service.

tallo Follow

Originally disclosed on Sherlock

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

Found by

tallo

Summary

The absence of size limits on WASM stdout/stderr outputs will cause a denial of service vulnerability for SEDA validators as attackers can exhaust node memory by creating data requests with WASM modules that generate excessive terminal output.

Root Cause

In runtime.rs there is no size limit enforcement for stdout/stderr buffers, unlike the explicit limit that exists for VM execution results:

Rust
// Add size check for execution result
if execution_result.len() > MAX_VM_RESULT_SIZE_BYTES {
    stderr.push(format!(
        "Result size ({} bytes) exceeds maximum allowed size ({} bytes)",
        execution_result.len(),
        MAX_VM_RESULT_SIZE_BYTES
    ));
    return Err(VmResultStatus::ResultSizeExceeded);
}

Internal Pre-conditions

  1. Attacker needs to submit a data request with a custom WASM program that writes excessive amounts of data to stdout/stderr

External Pre-conditions

None

Attack Path

  1. Attacker creates a malicious WASM module that repeatedly writes large chunks of data to stdout and stderr, potentially using a loop to generate several gigabytes of output
  2. Attacker submits this module as part of a legitimate data request to the SEDA network with sufficient gas limit
  3. When validators process this request during the tally phase in endblock.go, the WASM module executes and generates excessive stdout/stderr output
  4. These outputs are collected without size limits and passed through multiple layers of memory allocation and copying
  5. The outputs are then included in blockchain events, and written to consuming substantial memory and processing resources
  6. Validator nodes experience memory exhaustion, potentially causing crashes and significant performance degradation

Impact

To cause the most impact a malicious user can submit multiple data requests to the same malicious program, these can all be processed in the same batch. Each stdout/stderr will be stored in memory: https://github.com/sherlock-audit/2024-12-seda-protocol/blob/main/seda-chain/x/tally/keeper/endblock.go#L80

Go
tallyResults := make([]TallyResult, len(tallyList))
dataResults := make([]batchingtypes.DataResult, len(tallyList))

for i, req := range tallyList {
    // [...]
    _, tallyResults[i] = k.FilterAndTally(ctx, req, params, gasMeter)
    // [...]
}

And allows for a max of u32 (4gb) according to the wasmer fd_write syscall: https://github.com/wasmerio/wasmer/blob/475f335cb5a84ef6a8179699d322ca776c1bd26b/lib/wasix/src/syscalls/wasi/fd_write.rs#L11C1-L32C32

Rust
/// ### `fd_write()`
/// Write data to the file descriptor
/// Inputs:
/// - `Fd`
///     File descriptor (opened with writing) to write to
/// - `const __wasi_ciovec_t *iovs`
///     List of vectors to read data from
/// - `u32 iovs_len`
///     Length of data in `iovs`
/// Output:
/// - `u32 *nwritten`
///     Number of bytes written
/// Errors:
///
#[instrument(level = "trace", skip_all, fields(%fd, nwritten = field::Empty), ret)]
pub fn fd_write<M: MemorySize>(
    mut ctx: FunctionEnvMut<'_, WasiEnv>,
    fd: WasiFd,
    iovs: WasmPtr<__wasi_ciovec_t<M>, M>,
    iovs_len: M::Offset,
    nwritten: WasmPtr<M::Offset, M>,
) -> Result<Errno, WasiError> {

meaning a single data request with stderr/stdout of 8gb total will be copied across rust strings, converted to Vec<string>, serialized to C-compatible FFI structures, copied to Go data structures via CGO, formatted and joined for event attributes all while being stored in tallyResults. Since this is all executed in Endblocker, and multiple malicious data requests can be submitted, all validators will face extremely degraded performance and OOM crashes

Mitigation

Implement size limits for stdout and stderr similar to those already in place for execution results

Discussion

sherlock-admin2

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

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 WASM runtime does not enforce a size limit on stdout/stderr buffers, unlike the limit that exists for execution results.

Impact

Validator nodes could experience memory exhaustion, potentially causing crashes and significant performance degradation, especially if multiple malicious requests are submitted in the same batch.

What the attacker needed

Ability to submit data requests; sufficient gas limit

The fix

The protocol team fixed this issue by implementing size limits for stdout and stderr similar to those already in place for execution results.

How it was found

  1. Attacker creates a malicious WASM module that repeatedly writes large chunks of data to stdout and stderr, potentially using a loop to generate several gigabytes of output
  2. Attacker submits this module as part of a legitimate data request to the SEDA network with sufficient gas limit
  3. When validators process this request during the tally phase in endblock.go, the WASM module executes and generates excessive stdout/stderr output
  4. These outputs are collected without size limits and passed through multiple layers of memory allocation and copying
  5. The outputs are then included in blockchain events, and written to consuming substantial memory and processing resources
  6. Validator nodes experience memory exhaustion, potentially causing crashes and significant performance degradation

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 blockchain validator runs programs (WASM modules) submitted by users. This report found that a malicious program could produce a huge amount of output text, which the validator stores in memory without any limit. By sending many such programs, an attacker could use up all the validator's memory and crash 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 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.