Skip to content
DoS Audit finding Intermediate

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

The ExecuteTallyVM function allocates a C string for the log directory but never frees it, causing a small memory leak each time it runs. Over time, as the node processes blocks, this leak accumulates and can eventually exhaust memory, leading to degraded performance and node crashes.

Boy2000 Follow with g, gxh191 and 2 others

Originally disclosed on Sherlock

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

Found by

Boy2000, g, gxh191, tallo, zxriptor

Summary

The continuous memory allocation without freeing in execute.go will cause a memory leak for node operators as each block will lose a small amount of memory, eventually depleting the node's resources over extended operation periods.

Root Cause

In execute.go the configDirC C string is allocated with C.CString(LogDir) but never freed with C.free(unsafe.Pointer(configDirC)), unlike all other C string allocations in the same function.

https://github.com/sherlock-audit/2024-12-seda-protocol/blob/main/seda-wasm-vm/tallyvm/execute.go#L27

Internal Pre-conditions

  1. The SEDA node is running and processing blocks
  2. The ExecuteTallyVm function is called from the EndBlock function
  3. The LogDir global variable is set to a non-empty string path

External Pre-conditions

None

Attack Path

  1. The Tally module's EndBlock function is called automatically at the end of each block
  2. This calls ProcessTallies which processes data requests ready for tallying
  3. For each tally operation, the FilterAndTally method is invoked
  4. This ultimately executes the ExecuteTallyVm function in execute.go
  5. Each execution allocates memory for configDirC without freeing it
  6. The allocated memory accumulates over time as each block is processed
  7. Eventually, after running for an extended period, the node will run out of memory

Impact

The SEDA node operators suffer a continuous memory leak that will eventually lead to degraded performance and potential node crashes. The amount of memory leaked per block is equal to the length of the LogDir string plus 1 byte (for the null terminator). For a typical path length of ~30 bytes, /home/seda/.seda/tally-logs\00, a default MaxTalliesPerBlock of 100, and an average of 20 data requests per block, this will add up to ~3gb of allocated memory that is leaked each year. Longer paths, more data requests per block will result in a faster leakage and result in an eventual crash for all systems. Systems with lower specs will crash sooner rather than later

Mitigation

just like with all the other C.Cstring initializations in the function, add the line:

Go
defer C.free(unsafe.Pointer(configDirC)

Discussion

sherlock-admin2

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

The original report as published on Sherlock, by Boy2000. 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 C string allocated for the log directory is not freed, unlike other similar allocations in the same function.

Impact

The memory leak could degrade performance and eventually crash nodes, with the leak rate depending on path length and request volume.

What the attacker needed

SEDA node running and processing blocks; LogDir set to a non-empty string path

The fix

The issue was fixed by adding a defer statement to free the allocated C string, as done for other similar allocations.

How it was found

  1. The Tally module's EndBlock function is called automatically at the end of each block
  2. This calls ProcessTallies which processes data requests ready for tallying
  3. For each tally operation, the FilterAndTally method is invoked
  4. This ultimately executes the ExecuteTallyVm function in execute.go
  5. Each execution allocates memory for configDirC without freeing it
  6. The allocated memory accumulates over time as each block is processed

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.

When a program asks the computer for memory, it should give it back when done. Here, a small piece of memory is requested every time a block is processed but never returned. Over many blocks, this adds up and can make the node run out of memory and crash.

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 Boy2000

View all

3 more disclosed reports, 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.