chore(security): tighten Terraform provider constraints to exact pins#8019
chore(security): tighten Terraform provider constraints to exact pins#8019jordanconway wants to merge 1 commit into
Conversation
Replace all loose ~> and >= provider version constraints with = exact pins across all 7 modules. Exact pinning means only the one known-good version can be installed — no silent drift to a newer release that may not yet have been reviewed. Provider versions pinned (derived from current registry latest that satisfies each prior constraint, verified with tofu providers lock): hashicorp/aws ~> 5.5 → = 5.100.0 (6 modules) hashicorp/random ~> 3.4.2 → = 3.4.3 (root module) hashicorp/null ~> 3.2.1 → = 3.2.4 (modules/download-lambda) required_version (>= 1.5) is intentionally left unchanged — this governs the OpenTofu CLI binary version and changing it to an exact pin would break anyone running a different tofu version without a coordinated upgrade. A separate team decision is needed to align on a pinned CLI version across local dev and CI. Lockfiles (.terraform.lock.hcl) are regenerated to reflect the updated exact constraints. This PR includes the lockfiles via git add -f because the .gitignore fix (removing *.lock.hcl) is in a companion PR; once that PR merges, the force-add here becomes unnecessary for future updates. To update providers going forward: 1. Change the version to the desired = X.Y.Z in the relevant main.tf 2. Run: tofu init -upgrade 3. Run: tofu providers lock -platform=linux_amd64 -platform=linux_arm64 -platform=darwin_arm64 -platform=darwin_amd64 4. Commit both the updated main.tf and .terraform.lock.hcl 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. |
There was a problem hiding this comment.
Change LGTM, but I'm not sure why do you want to commit lock files, as they should not change across the runs, should they?
IMO one can have either strict constraints and no lockfiles (as they are redundant) or check in lockfiles but still have loose constraints, so that one can run an update command to change lockfile versions.
|
@malfet Ideally they wouldn't change but because they do contain hashes of the registry zip and the extracted binary and it can help prevent tag push style takeovers. I've got some more information documented here https://github.com/jordanconway/package-manager-hardening/blob/main/docs/terraform.md#lockfile |
Summary
Replace all loose
~>and>=provider version constraints across all 7 OpenTofu modules with exact= X.Y.Zpins. This eliminates silent provider drift — with loose constraints, everytofu initcould install a different version than the last run, and a compromised new release matching the range would be picked up automatically.Changes
Provider pins — all 7 modules
~> 5.5= 5.100.0~> 3.4.2= 3.4.3~> 5.5= 5.100.0~> 3.2.1= 3.2.4~> 5.5= 5.100.0~> 5.5= 5.100.0~> 5.5= 5.100.0~> 5.5= 5.100.0All versions were verified against the OpenTofu registry and confirmed as the latest that satisfied each prior constraint. All providers are signed with HashiCorp key
0C0AF313E5FD9F80.Intentionally unchanged:
required_versionThe
required_version = ">= 1.5"directive (which governs the OpenTofu CLI binary) is left as-is. Pinning it to a single exact version would break anyone running a differenttofurelease without a coordinated team upgrade. A separate decision is recommended to align CI (tflint.ymlcurrently installs1.5.7) with the version in active use locally.Lockfiles updated
Both
.terraform.lock.hclfiles are regenerated to reflect the updatedconstraints =field, keeping them consistent with the new exact pins.Keeping providers up to date going forward
When a Dependabot PR bumps a provider (or you want to upgrade manually):
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.