Skip to content

core: ssz offset validation#4529

Merged
pinebit merged 1 commit into
mainfrom
pinebit/ssz-recovering
May 20, 2026
Merged

core: ssz offset validation#4529
pinebit merged 1 commit into
mainfrom
pinebit/ssz-recovering

Conversation

@pinebit
Copy link
Copy Markdown
Collaborator

@pinebit pinebit commented May 20, 2026

Fix SSZ offset validation panic in unsigned data decoding.

category: bug
ticket: none

@pinebit pinebit requested review from KaloyanTanev and aly-obol May 20, 2026 06:33
@sonarqubecloud
Copy link
Copy Markdown

@codecov
Copy link
Copy Markdown

codecov Bot commented May 20, 2026

Codecov Report

❌ Patch coverage is 78.57143% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 57.10%. Comparing base (2c42245) to head (7bcddb4).
⚠️ Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
core/proto.go 75.00% 2 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4529      +/-   ##
==========================================
+ Coverage   57.01%   57.10%   +0.08%     
==========================================
  Files         245      245              
  Lines       32971    33003      +32     
==========================================
+ Hits        18799    18845      +46     
+ Misses      11789    11783       -6     
+ Partials     2383     2375       -8     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes a panic when decoding malformed SSZ “versioned” payloads by validating that the decoded offset does not exceed the input buffer length, ensuring unsigned data decoding returns a proper error instead of panicking.

Changes:

  • Add upper-bound checks for SSZ offsets in unmarshalSSZVersionedBlinded and unmarshalSSZVersioned.
  • Add panic recovery to UnsignedDataSetFromProto and factor shared recovery logic into recoverPanicErr.
  • Add regression tests covering out-of-bounds SSZ offsets and recoverPanicErr behavior.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
core/ssz.go Prevents slice-bounds panics by rejecting SSZ offsets that exceed len(buf).
core/proto.go Ensures panics during unsigned data decoding are converted into errors; centralizes recovery formatting.
core/proto_internal_test.go Adds regression tests to confirm malformed SSZ offsets return ssz.ErrOffset and do not trigger panic recovery.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@pinebit pinebit enabled auto-merge (squash) May 20, 2026 08:00
@pinebit pinebit merged commit 20a6ef5 into main May 20, 2026
14 of 15 checks passed
@pinebit pinebit deleted the pinebit/ssz-recovering branch May 20, 2026 08:37
pinebit added a commit that referenced this pull request May 20, 2026
pinebit added a commit that referenced this pull request May 20, 2026
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.

3 participants