Skip to content

fix(kona/protocol): bounds checks in read_tx_data for truncated/oversized payloads#19904

Merged
sebastianst merged 1 commit intodevelopfrom
seb/fix-read-tx-data-panic
Apr 2, 2026
Merged

fix(kona/protocol): bounds checks in read_tx_data for truncated/oversized payloads#19904
sebastianst merged 1 commit intodevelopfrom
seb/fix-read-tx-data-panic

Conversation

@sebastianst
Copy link
Copy Markdown
Member

@sebastianst sebastianst commented Apr 2, 2026

Summary

  • Adds a MAX_SPAN_BATCH_ELEMENTS size cap to read_tx_data, matching op-node's rlp.NewStream(r, MaxSpanBatchElementCount) behavior — prevents consensus divergence on oversized transaction payloads (Cantina Make CALLs Revert Properly #28 / optimism-private#488)
  • Adds a buffer length check before slicing, preventing panics on truncated span batch input (Cantina Refactor tests and test EXTCODECOPY Failure Behavior #25 item 4 / optimism-private#486)
  • Regression tests for both cases

Fixes https://github.com/ethereum-optimism/optimism-private/issues/486
Fixes https://github.com/ethereum-optimism/optimism-private/issues/488

Test plan

  • cargo test --package kona-protocol --all-features --lib -- test_read_tx_data — both new tests pass
  • cargo check --package kona-protocol — compiles cleanly
  • CI: just t in rust/kona/ (runs --all-features)

🤖 Generated with Claude Code

…nd oversized payloads

Add two bounds checks to `read_tx_data` before indexing into the slice:

1. Reject payloads exceeding `MAX_SPAN_BATCH_ELEMENTS` with
   `TooBigSpanBatchSize`, matching op-node's `rlp.NewStream(r,
   MaxSpanBatchElementCount)` behavior. Without this, kona accepts
   oversized transactions that op-node rejects, causing a consensus
   divergence. (Cantina finding #28)

2. Reject truncated payloads where `payload_length_with_header` exceeds
   the remaining buffer, preventing a panic on malformed input. (Cantina
   finding #25, item 4)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@sebastianst sebastianst requested a review from a team as a code owner April 2, 2026 17:20
@sebastianst sebastianst requested review from geoknee and theochap and removed request for geoknee April 2, 2026 17:20
@sebastianst sebastianst enabled auto-merge April 2, 2026 17:34
@sebastianst sebastianst added this pull request to the merge queue Apr 2, 2026
@codecov
Copy link
Copy Markdown

codecov bot commented Apr 2, 2026

Codecov Report

❌ Patch coverage is 95.23810% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 75.9%. Comparing base (f5cd6b3) to head (4f1f42d).
⚠️ Report is 2 commits behind head on develop.

Files with missing lines Patch % Lines
rust/kona/crates/protocol/protocol/src/utils.rs 95.2% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop   #19904      +/-   ##
===========================================
  Coverage     75.9%    75.9%              
===========================================
  Files          684      489     -195     
  Lines        73143    61816   -11327     
===========================================
- Hits         55532    46974    -8558     
+ Misses       17467    14842    -2625     
+ Partials       144        0     -144     
Flag Coverage Δ
cannon-go-tests-64 ?
contracts-bedrock-tests ?
unit 75.9% <95.2%> (+<0.1%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
rust/kona/crates/protocol/protocol/src/utils.rs 96.6% <95.2%> (-0.1%) ⬇️

... and 202 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Merged via the queue into develop with commit d2fdc04 Apr 2, 2026
167 checks passed
@sebastianst sebastianst deleted the seb/fix-read-tx-data-panic branch April 2, 2026 18:19
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