chore(security): commit Terraform provider lockfiles and enforce in CI#8018
Open
jordanconway wants to merge 1 commit into
Open
chore(security): commit Terraform provider lockfiles and enforce in CI#8018jordanconway wants to merge 1 commit into
jordanconway wants to merge 1 commit into
Conversation
Provider lockfiles were previously gitignored via *.lock.hcl in
terraform-aws-github-runner/.gitignore. Without them, tofu init resolves
provider versions at runtime from the registry, meaning a compromised or
unexpected provider version could be silently installed.
Changes:
- Remove *.lock.hcl from terraform-aws-github-runner/.gitignore and add
a comment explaining that .terraform.lock.hcl must be tracked in VCS.
- Commit terraform-aws-github-runner/.terraform.lock.hcl with multi-platform
h1: hashes for linux_amd64, linux_arm64, darwin_amd64, darwin_arm64:
hashicorp/aws 5.100.0 (satisfies ~> 5.5)
hashicorp/random 3.4.3 (satisfies ~> 3.4.2)
- Commit modules/download-lambda/.terraform.lock.hcl (this module is not
called from the root module and acts as a standalone root module):
hashicorp/null 3.2.4 (satisfies ~> 3.2.1)
- Add 'Verify lockfile integrity' step to tflint.yml that runs
tofu init -backend=false -lockfile=readonly before linting.
This causes CI to fail if the lockfile is missing or stale, ensuring
the lockfile is always kept up to date.
To regenerate lockfiles after a version bump:
cd terraform-aws-github-runner
tofu providers lock -platform=linux_amd64 -platform=linux_arm64 -platform=darwin_arm64 -platform=darwin_amd64
See https://github.com/jordanconway/package-manager-hardening for the
full hardening methodology.
Signed-off-by: Jordan Conway <jconway@linuxfoundation.org>
|
@jordanconway is attempting to deploy a commit to the Meta Open Source Team on Vercel. A member of the Team first needs to authorize it. |
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.
Summary
Provider lockfiles (
.terraform.lock.hcl) were explicitly gitignored via*.lock.hclinterraform-aws-github-runner/.gitignore. This means everytofu initresolves provider versions live from the registry — a compromised or unexpected provider version (e.g. one matching the existing~> 5.5/~> 3.4.2loose constraints) could be silently installed with no diff ever appearing in this repo.Changes
1. Un-ignore
.terraform.lock.hclinterraform-aws-github-runner/.gitignoreRemoves the
*.lock.hclglob and replaces it with a comment explaining why the file must be tracked. The.tfstateand.terraform/patterns are untouched.2. Commit
terraform-aws-github-runner/.terraform.lock.hclGenerated with:
Providers locked (all signed with key
0C0AF313E5FD9F80):~> 5.5~> 3.4.23. Commit
modules/download-lambda/.terraform.lock.hclThis module is not called from the root module (it appears to be a standalone utility root module). It has its own
required_providersforhashicorp/nulland therefore needs its own lockfile.~> 3.2.14. Add
Verify lockfile integritystep totflint.ymlRuns
tofu init -backend=false -lockfile=readonlybefore linting. CI will now fail if the lockfile is missing, out of date, or inconsistent with the checked-in constraints — ensuring the lockfile is always kept current.Keeping lockfiles up to date
After a provider version bump (from a Dependabot PR or manual update), re-run:
cd terraform-aws-github-runner tofu providers lock \ -platform=linux_amd64 -platform=linux_arm64 \ -platform=darwin_arm64 -platform=darwin_amd64Commit the updated
.terraform.lock.hcl. The-lockfile=readonlyCI step will then verify it matches.This change is part of a broader supply-chain hardening effort following a repository audit. See https://github.com/jordanconway/package-manager-hardening for the full methodology.