Skip to content

fix: validate container input size before reading offsets - #561

Closed
GiHoon1123 wants to merge 1 commit into
ChainSafe:masterfrom
GiHoon1123:fix/container-short-input
Closed

GiHoon1123 wants to merge 1 commit into
ChainSafe:masterfrom
GiHoon1123:fix/container-short-input

Conversation

@GiHoon1123

Copy link
Copy Markdown

Motivation

Short container inputs can reach DataView.getUint32() before their size is checked, exposing a raw RangeError. In a larger buffer, the read can also extend past the container's input range before the input is rejected.

Description

Check the fixed section size before reading variable offsets in Container, ProgressiveContainer, StableContainer, and Profile. Check the active/optional-field bitmap length before creating its view.

Use the existing Error style with a size-specific message. Keep fixed-size checks and field validation unchanged once the required section is present.

Add regression tests for truncated input ranges, bitmap boundaries, Buffer inputs, and value/View/ViewDU decoding. Empty lists and absent optional fields remain valid.

Closes #502

Steps to test or reproduce

  • pnpm -r test:unit --coverage.enabled=false --reporter=dot — 3,268 passed, 3 skipped.
  • pnpm -r check-types
  • pnpm lint and pnpm lint:no-push-spread
  • pnpm --filter @chainsafe/ssz build
  • pnpm --filter @chainsafe/ssz exec vitest run --coverage.enabled=false test/spec/generic/index.test.ts -t 'container|profile' --reporter=dot — 1,146 passed; unrelated cases excluded by the filter.

@GiHoon1123
GiHoon1123 requested a review from a team as a code owner October 22, 2026 04:28
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-22T04:32:33.480809Z 37c8d0b PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@GiHoon1123

Copy link
Copy Markdown
Author

Could someone review this when they have a chance? Please let me know if anything needs changing. Thanks!

@GiHoon1123 GiHoon1123 closed this by deleting the head repository Nov 10, 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.

Container SSZ deserialize on short/empty inputs throws RangeError

1 participant