-
Notifications
You must be signed in to change notification settings - Fork 603
Add option to require explicit gpg key verification for image builds #15462
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add option to require explicit gpg key verification for image builds #15462
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
bef77fb to
4886492
Compare
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