Add option to require explicit gpg key verification for image builds#15462
Merged
dmcilvaney merged 4 commits intomicrosoft:3.0-devfrom Jan 19, 2026
Merged
Add option to require explicit gpg key verification for image builds#15462dmcilvaney merged 4 commits intomicrosoft:3.0-devfrom
dmcilvaney merged 4 commits intomicrosoft:3.0-devfrom
Conversation
Allow the tools to directly validate rpm signatures during production image builds instead of relying on external validation. Set VALIDATE_IMAGE_GPG=y to enable. Unlike the related VALIDATE_TOOLCHAIN_GPG option, it is not configured automatically since RPMs used in images may come from multiple sources and it is not feasible to automatically determine if they should all be signed (i.e. mix of official repos and locally built packages). Signed-off-by: Daniel McIlvaney <damcilva@microsoft.com>
c364181 to
593b989
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds optional GPG signature verification for RPM packages during image builds to provide defense-in-depth for production deployments. When VALIDATE_IMAGE_GPG=y is set, all packages fetched for image generation are validated against Microsoft GPG signing keys before being included in images.
Key changes:
- Added
VALIDATE_IMAGE_GPGandIMAGE_GPG_VALIDATION_KEYSbuild variables with corresponding CLI flags in imagepkgfetcher - Implemented GPG signature validation functions in the internal/rpm package (ImportGpgKeysToRpmDb, CheckRpmSignature, ValidateDirectoryRpmSignatures)
- Added documentation explaining production build recommendations and clarifying that --nogpgcheck is safe during installation since validation occurs at fetch time
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| toolkit/tools/internal/rpm/rpm.go | Adds three new functions for GPG signature validation: importing keys to RPM database, checking individual RPM signatures, and validating all RPMs in a directory |
| toolkit/tools/imagepkgfetcher/imagepkgfetcher.go | Adds --enable-gpg-check and --gpg-keys flags, validates downloaded packages after cloning if GPG checking is enabled |
| toolkit/tools/imagegen/installutils/installutils.go | Adds explanatory comments to clarify that --nogpgcheck is safe because validation happens during package fetching |
| toolkit/scripts/utils.mk | Adds VALIDATE_IMAGE_GPG to the list of watched variables for dependency tracking |
| toolkit/scripts/imggen.mk | Adds conditional logic to pass GPG validation flags to imagepkgfetcher when VALIDATE_IMAGE_GPG=y |
| toolkit/docs/security/production-builds.md | New documentation file explaining production build workflow and GPG validation variables |
| toolkit/docs/security/intro.md | Adds links to new production builds documentation |
| toolkit/docs/building/building.md | Documents the new VALIDATE_IMAGE_GPG, IMAGE_GPG_VALIDATION_KEYS, VALIDATE_TOOLCHAIN_GPG, and TOOLCHAIN_GPG_VALIDATION_KEYS variables |
| toolkit/Makefile | Defines VALIDATE_IMAGE_GPG and IMAGE_GPG_VALIDATION_KEYS variables with defaults, consolidates default GPG keys into shared variable |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
PawelWMS
reviewed
Jan 7, 2026
PawelWMS
reviewed
Jan 7, 2026
PawelWMS
reviewed
Jan 7, 2026
PawelWMS
reviewed
Jan 7, 2026
PawelWMS
reviewed
Jan 7, 2026
PawelWMS
reviewed
Jan 7, 2026
PawelWMS
reviewed
Jan 7, 2026
PawelWMS
reviewed
Jan 7, 2026
PawelWMS
reviewed
Jan 7, 2026
bef77fb to
4886492
Compare
PawelWMS
reviewed
Jan 8, 2026
PawelWMS
reviewed
Jan 8, 2026
PawelWMS
approved these changes
Jan 16, 2026
jslobodzian
approved these changes
Jan 19, 2026
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.
Allow the tools to directly validate rpm signatures during production image builds instead of relying on external validation. Set VALIDATE_IMAGE_GPG=y to enable.
Unlike the related VALIDATE_TOOLCHAIN_GPG option, it is not configured automatically since RPMs used in images may come from multiple sources and it is not feasible to automatically determine if they should all be signed (i.e. mix of official repos and locally built packages).
Merge Checklist
All boxes should be checked before merging the PR (just tick any boxes which don't apply to this PR)
*-staticsubpackages, etc.) have had theirReleasetag incremented../cgmanifest.json,./toolkit/scripts/toolchain/cgmanifest.json,.github/workflows/cgmanifest.json)./LICENSES-AND-NOTICES/SPECS/data/licenses.json,./LICENSES-AND-NOTICES/SPECS/LICENSES-MAP.md,./LICENSES-AND-NOTICES/SPECS/LICENSE-EXCEPTIONS.PHOTON)*.signatures.jsonfilessudo make go-tidy-allandsudo make go-test-coveragepassSummary
Adds optional GPG signature verification for RPM packages during image builds. When
VALIDATE_IMAGE_GPG=yis set, all packages fetched for image generation are validated against the Microsoft GPG signing keys (or custom keys viaIMAGE_GPG_VALIDATION_KEYS). This provides defense-in-depth for production builds by ensuring all packages have completed the signing process before being included in images.Change Log
VALIDATE_IMAGE_GPGandIMAGE_GPG_VALIDATION_KEYSbuild variables--enable-gpg-checkand--gpg-keysflags to imagepkgfetcher toolinternal/rpmpackage (ImportGpgKeysToRpmDb,CheckRpmSignature,ValidateDirectoryRpmSignatures)installutils.goexplaining that--nogpgcheckis safe because validation happens at fetch timeDoes this affect the toolchain?
NO
Associated issues
Test Methodology
VALIDATE_IMAGE_GPG=n-> passedVALIDATE_IMAGE_GPG=y-> failed (unsigned packages rejected)VALIDATE_IMAGE_GPG=y-> passedhttps://dev.azure.com/mariner-org/mariner/_build/results?buildId=1021073&view=results