Skip to content

fix: validate root format in empty-range proof path of VerifyNamespace#324

Open
evan-forbes wants to merge 1 commit into
mainfrom
fix/verify-namespace-short-root-panic
Open

fix: validate root format in empty-range proof path of VerifyNamespace#324
evan-forbes wants to merge 1 commit into
mainfrom
fix/verify-namespace-short-root-panic

Conversation

@evan-forbes
Copy link
Copy Markdown
Member

Proof.VerifyNamespace panics (slice bounds out of range) on an empty-range proof with a root shorter than 2*nID.Size(), because the empty-range path slices the root without validating its format; this fix validates the root first and returns a verification failure instead.

This is strictly hardening: the only in-tree production caller (celestia-node's RowNamespaceData.Verify) is doubly guarded (it rejects empty proofs and derives the root from the validated DAH, not from the peer), so production accessibility is very limited; fixing because it is cheap and correct.

🤖 Generated with Claude Code

Proof.VerifyNamespace panics with "slice bounds out of range" on an
empty-range proof when the supplied root is shorter than 2*nID.Size().
The empty-range path sliced the root via MinNamespace/MaxNamespace
without first validating its format, unlike the non-empty path which
validates the root via nth.ValidateNodeFormat in VerifyLeafHashes.

Validate the root with nth.ValidateNodeFormat at the top of
isValidEmptyRangeProof so a malformed/short root returns a verification
failure instead of panicking. Adds a regression test.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@evan-forbes evan-forbes requested a review from a team as a code owner May 22, 2026 20:40
@evan-forbes evan-forbes requested review from mcrakhman and removed request for a team May 22, 2026 20:40
Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a validation check for the root format in isValidEmptyRangeProof to prevent a potential panic caused by slice bounds errors when the root is too short. Additionally, a regression test was added to ensure that empty range proofs with short roots are handled correctly without panicking. I have no feedback to provide.

@rootulp rootulp requested review from rach-id and removed request for mcrakhman May 27, 2026 21:58
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