Skip to content

fix(common): bound RLP transaction allocations - #1028

Merged
curryxbo merged 1 commit into
mainfrom
fix/batch-rlp-allocation-bound
Jul 27, 2026
Merged

fix(common): bound RLP transaction allocations#1028
curryxbo merged 1 commit into
mainfrom
fix/batch-rlp-allocation-bound

Conversation

@curryxbo

Copy link
Copy Markdown
Contributor

Summary

  • reject RLP transaction lengths larger than the remaining decoded batch payload before allocating
  • preserve all valid batch behavior while preventing a malformed length prefix from requesting multi-gigabyte memory
  • cover both oversized declarations and valid payload decoding

Security impact

A malformed committed batch can encode a four-byte RLP length such as 0xffffffff with almost no payload. Without this check, derivation attempts the declared allocation before the subsequent read fails. The check uses the exact remaining bytes.Reader length rather than an arbitrary protocol cap.

Test plan

  • go test ./batch -run '^TestExtractInnerTxFullBytes' -count=1 -timeout=30s

Made with Cursor

Reject transaction lengths that exceed the remaining batch payload before allocating memory, preventing malformed committed data from exhausting derivation nodes.

Co-authored-by: Cursor <cursoragent@cursor.com>
@curryxbo
curryxbo requested a review from a team as a code owner July 27, 2026 07:37
@curryxbo
curryxbo requested review from dylanCai9 and removed request for a team July 27, 2026 07:37
@coderabbitai

coderabbitai Bot commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

@curryxbo, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 17 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

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 reviews.

How do review 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 refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 4e25d813-c4df-4e13-9918-c6dd79b4d531

📥 Commits

Reviewing files that changed from the base of the PR and between 5ae47e4 and 7445e95.

📒 Files selected for processing (2)
  • common/batch/blob.go
  • common/batch/blob_test.go
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/batch-rlp-allocation-bound

Warning

Billing warning: we have not been able to collect payment for this subscription for more than 72 hours. Please update the payment method or pay any pending invoices in Billing to avoid service interruption.


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.

@curryxbo
curryxbo merged commit 615824e into main Jul 27, 2026
7 checks passed
@curryxbo
curryxbo deleted the fix/batch-rlp-allocation-bound branch July 27, 2026 08:32
curryxbo pushed a commit that referenced this pull request Aug 11, 2026
extractInnerTxFullBytes sized the full-tx buffer with
1+uint32(sizeByteLen)+size, which wraps when the declared RLP size is
near MaxUint32 (e.g. a 0xffffffff length prefix), producing a buffer
shorter than the slice copies below and panicking. The remaining-length
guard added in #1028 already bounds size to the available input on the
batch-decode path, so this only wraps for an out-of-band reader; computing
the length in uint64 removes the panic unconditionally as defense in depth.

Co-authored-by: Cursor <cursoragent@cursor.com>
curryxbo pushed a commit that referenced this pull request Aug 11, 2026
End-to-end analysis shows the uint32 length wrap at blob.go is unreachable:
the compressed batch input is hard-capped by the L1 blobs-per-tx limit, the
#1028 size>remaining guard already bounds the declared length to the
decompressed stream, and reaching a ~4.29 GiB stream would OOM inside zstd
decompression before the RLP decoder runs. The #1028 guard on main is the
sufficient defense; the extra hardening addressed a condition the real data
flow cannot produce, so revert it and keep this PR to the oracle fix.

Co-authored-by: Cursor <cursoragent@cursor.com>
curryxbo pushed a commit that referenced this pull request Aug 11, 2026
size is a uint32, so 1+sizeByteLen+size can exceed MaxUint32 and wrap to a
tiny buffer length, leaving fullTxBytes shorter than the copies that follow
and panicking. The #1028 remaining-bytes guard keeps this unreachable on the
current decode path, but compute the length in uint64 and reject the
overflow before allocating so the decoder stays safe if the size type or the
upstream length bounds ever change.

Co-authored-by: Cursor <cursoragent@cursor.com>
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.

2 participants