Skip to content

fix: limit Vec::with_capacity in binary calldata decoder to prevent OOM#320

Open
lau90eth wants to merge 2 commits into
genlayerlabs:v0.3-devfrom
lau90eth:fix/bin-oom-capacity
Open

fix: limit Vec::with_capacity in binary calldata decoder to prevent OOM#320
lau90eth wants to merge 2 commits into
genlayerlabs:v0.3-devfrom
lau90eth:fix/bin-oom-capacity

Conversation

@lau90eth

Copy link
Copy Markdown

Summary

Adds a maximum capacity guard in the binary calldata decoder to prevent OOM allocation via malicious input.

Root Cause

In executor/crates/calldata/src/bin.rs:214, Vec::with_capacity(full_size) is called where full_size comes directly from untrusted wire data with no upper bound check:

stack.push(Frame::Array {
    collected: Vec::with_capacity(full_size), // OOM if full_size is huge
    remaining: full_size,
});

A malicious calldata packet can set the array size field to a large value (e.g. 0xFFFFFFFF), causing the allocator to attempt a multi-GB allocation and crash the validator process.

Impact

Validator OOM crash — consensus liveness compromised. Introduced in commit 699ec88 (feat: add limit to calldata parsing) which rewrote the decoder in bin.rs without carrying over the original bounds check from de.rs.

Fix

Added MAX_ARRAY_CAPACITY = 1024 * 1024 guard before Vec::with_capacity, returning an error for oversized arrays.

PoC

https://github.com/lau90eth/genvm-bin-oom

Related

Finding originally submitted to GenLayer Builders Program portal.

lau90eth added 2 commits June 28, 2026 10:07
Fixes index-out-of-bounds panic when a malicious leader injects
Bytes::new() as a nondet result. data[0] would panic if data is empty.

Affected: executor/src/wasi/genlayer_sdk.rs ~L1305
PoC: https://github.com/lau90eth/genvm-nondet-panic
Adds MAX_ARRAY_CAPACITY guard before Vec::with_capacity(full_size)
in the binary calldata decoder. Without this check, a malicious
calldata packet with a large array size field causes OOM allocation.

Affected: executor/crates/calldata/src/bin.rs:214
PoC: https://github.com/lau90eth/genvm-bin-oom
@coderabbitai

coderabbitai Bot commented Jun 28, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

@lau90eth, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 55 minutes and 9 seconds. Learn how PR review limits work.

Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file).

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits.

🚦 How do rate limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 8792c3ef-5d5c-4409-8eab-fdd5acdf8e98

📥 Commits

Reviewing files that changed from the base of the PR and between abb71bf and 32dc8e7.

📒 Files selected for processing (2)
  • executor/crates/calldata/src/bin.rs
  • executor/src/wasi/genlayer_sdk.rs
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot changed the base branch from main to v0.3-dev June 28, 2026 08:13
@github-actions

Copy link
Copy Markdown
Contributor

👋 This PR targeted main, so I've retargeted it to the latest dev branch v0.3-dev.

main is protected and is only an alias of the latest release branch (v0.3-dev), kept in lockstep automatically. Active v0.3 work lands on v0.3-dev, which reaches v0.3.x through the standing release-gate PR once the cross-repo E2E matrix is green.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant