Skip to content

Prevent out-of-range slices in MigrationStorage#959

Open
roger2hk wants to merge 1 commit into
transparency-dev:mainfrom
roger2hk:fix-migration-storage
Open

Prevent out-of-range slices in MigrationStorage#959
roger2hk wants to merge 1 commit into
transparency-dev:mainfrom
roger2hk:fix-migration-storage

Conversation

@roger2hk
Copy link
Copy Markdown
Contributor

Problem
If the bundle fetched from storage is corrupted, incomplete, or simply shorter than what layout.Range expects for that index, bh will have fewer elements than ri.First + ri.N. This will trigger a slice bounds out-of-range panic.

Solution
This pull request adds a bounds check in fetchLeafHashes across AWS, GCP, and POSIX backends to prevent a potential slice out-of-bounds panic when processing truncated entry bundles during log migration.

@roger2hk roger2hk requested a review from a team as a code owner May 13, 2026 15:57
@roger2hk roger2hk requested review from AlCutter and mhutchinson May 13, 2026 15:58
Comment thread storage/aws/aws.go
if err != nil {
return fmt.Errorf("bundleHasherFunc for bundle index %d: %v", ri.Index, err)
}
if len(bh) < int(ri.First+ri.N) {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

if l := len(bh); l < ... {
   return fmt.Errorf(..., ..., l, ...)
}

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