Skip to content

git: fix potential difference between cache and snapshot - #6281

Merged
crazy-max merged 1 commit into
moby:masterfrom
tonistiigi:git-cache-snapshot-check
Oct 13, 2025
Merged

crazy-max merged 1 commit into
moby:masterfrom
tonistiigi:git-cache-snapshot-check

Conversation

@tonistiigi

Copy link
Copy Markdown
Member

If content changes in the upstream Git repository, there is a theoretical race between computing the cache key for ref(based on commit SHA) and actually checking out that ref. If commit changes in between these operations then the content may be cached by wrong commit SHA and wrong commit SHA can also end up in the provenance attestation.

This fix detects this case. If the original commit from the cache computation is still available in upstream then that commit is used instead (it is not the correct commit anymore but it was in the start of the build so it can still be trusted). If upstream has removed the commit, then the build fails and needs to be restarted.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
@crazy-max crazy-max added this to the v0.26.0 milestone Oct 13, 2025
@crazy-max
crazy-max merged commit 62f34e8 into moby:master Oct 13, 2025
139 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants