# ExecuteTallyVM has a memory leak which will lead to nodes eventually crashing

ExecuteTallyVM in seda-wasm-vm allocates a C string for LogDir each tally without freeing it, leaking memory every block until nodes crash.

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

**Target:** Go WASM VM tally execution (execute.go) via cgo
**Root cause:** configDirC is allocated with C.CString(LogDir) but never freed with C.free, unlike other C string allocations in the same function.
**Steps:**
1. Read seda-wasm-vm/tallyvm/execute.go line 27: `configDirC := C.CString(LogDir)`
2. Confirm no matching `defer C.free(unsafe.Pointer(configDirC))` while other C.CString allocations are freed
3. Trace call path: EndBlock -> ProcessTallies -> FilterAndTally -> ExecuteTallyVm, invoked per tally each block
4. Observe leak of len(LogDir)+1 bytes per execution accumulating over node lifetime
**How found:** Code review of cgo string allocations in execute.go; noticed configDirC lacked the free call present for sibling allocations.
**Insight:** In cgo code, audit every C.CString/C.malloc against its C.free; a single missing free in a per-block hot path becomes an unbounded leak.

