Fix off-by-one bounds check in layout layer facade#308
Merged
jabrown85 merged 1 commit intoJul 15, 2026
Merged
Conversation
Signed-off-by: Arpit Jain <arpitjain099@gmail.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #308 +/- ##
==========================================
+ Coverage 34.66% 34.78% +0.12%
==========================================
Files 39 39
Lines 3359 3359
==========================================
+ Hits 1164 1168 +4
+ Misses 2000 1998 -2
+ Partials 195 193 -2 🚀 New features to boost your workflow:
|
pull Bot
pushed a commit
to Spencerx/BuildPackLifecycle
that referenced
this pull request
Jul 15, 2026
Picks up buildpacks/imgutil#308, which fixes an index-out-of-range panic in the layout layer facade when an OCI layout image's manifest and config disagree on layer count.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The two bounds checks in
newLayerOrFacadeFromuse>where they should use>=, so whenlayerIndexequals the slice length the guard doesn't fire and we fall straight through toconfigFile.RootFS.DiffIDs[layerIndex]/manifestFile.Layers[layerIndex]. That's an index out of range panic instead of the error the guard was there to return.It's reachable through the layout facade:
newImageFacadeFromranges overoriginal.Layers()and hands each index tonewLayerOrFacadeFrom, which then indexes into the config's diff_ids. Config and manifest get parsed independently and nothing cross-checks the counts, so an OCI layout image whose manifest lists more layer descriptors than the config has diff_ids (or the other way round) loads fine and then panics when it's used as a base or previous image. Only affects the facade path, so data-less/sparse layers.Changing
>to>=gets you the intended "failed to find layer for index N" error. Valid images are unaffected since a valid index never equals the array length.Added
layout/v1_facade_test.gocovering both directions of the mismatch plus an in-bounds case. It's an in-package test sincenewLayerOrFacadeFromisn't exported. Panics before the change, passes after, andgo test ./layout/...is green.