Repository navigation
Description
Summary
Four low-severity grants in our own hosted infrastructure that are wider than the stated need, grouped because each is a one-resource Terraform edit by someone doing a least-privilege pass. None ships in a customer-deployed template. Two are latent (one because the role's Lambda cannot be applied today, one because the escalation needs a second WIF provider nobody has added); the other two are live but read-only over-grants.
Location
All at 3c0f8ac94048a2c36fce5ccddee54e6c4849a5cd:
terraform/environments/gcp/ci-cd-permissions/github_oidc.tf:46(A13-014)terraform/modules/secrets/aws/main.tf:390(A13c-021)terraform/modules/compute/gcp/cloud-run/main.tf:431(A13c-022)terraform/modules/compute/azure/container-apps/main.tf:269(A13c-023)
Items
-
A13-014: GCP CI impersonation is granted to the whole repository on a generically named shared pool. The provider's
attribute_conditionpins repo and ref, but theworkloadIdentityUsergrant isprincipalSet://.../attribute.repository/<repo>with no ref component, and the pool is namedgithub-actions. Principal identifiers are pool-scoped, so any second provider added to the pool that can mintattribute.repositoryfor this repo satisfies the grant and impersonates a service account holdingroles/resourcemanager.projectIamAdmin,roles/iam.roleAdmin,roles/cloudkms.adminandroles/storage.admin.iac/federation/gcp-target/terraform/main.tf:203-205documents exactly this hazard for the customer module (and chore(terraform/environments): medium/low findings from the 2026-07-28 full review #132 item 8 tracks the customer-side instance); the CI pool has the same shape. PLAUSIBLE: with one provider in the pool this is defense in depth, not a reachable escalation.member = "principalSet://iam.googleapis.com/${google_iam_workload_identity_pool.github[0].name}/attribute.repository/${var.github_repo}"
Fix: pin
attribute.refin the grant as well (a two-attribute member or condition) and give the pool a CUDly-scoped name. -
A13c-021: the rotation Lambda's RDS grant wildcards the account and instance segments.
Resource = "arn:aws:rds:${var.region}:*:db:*"authorisesrds:ModifyDBInstanceon any instance in the account, while the same resource's owncountat :376 already holds the specificvar.rds_cluster_id. Latent: the rotation Lambda this role serves cannot be applied today (see the placeholder-source item tracked in fix(iac/gcp): cleanup-function ships a placeholder.zip source that doesn't exist, breaking apply #124 / chore(terraform/modules): medium/low findings from the 2026-07-28 full review #131), so nothing assumes the role.Action = [ "rds:ModifyDBInstance", "rds:DescribeDBInstances" ] Resource = "arn:aws:rds:${var.region}:*:db:*"
Fix: build the ARN from
data.aws_caller_identity.current.account_idandvar.rds_cluster_id. -
A13c-022: the Cloud Run service account holds project-wide
roles/compute.viewer. The comment names onlycompute.commitments.listandcompute.machineTypes.listas the need;roles/compute.viewergrants read on every Compute Engine resource in the project, including instance metadata and startup scripts. The module already defines a two-permission custom role for the write side immediately below (:454-463), so the narrow pattern is available.resource "google_project_iam_member" "compute_viewer" { project = var.project_id role = "roles/compute.viewer" member = "serviceAccount:${google_service_account.cloud_run.email}" }
Fix: extend
cudlyCommitmentWriter(or add a sibling custom role) withcompute.commitments.list/getandcompute.machineTypes.list/get, and drop the predefined role. -
A13c-023: the Container App identity holds
Readerover the entire host subscription.azurerm_role_assignment.subscription_readerhas nocountand is scoped tolocal.subscription_resource_id, the same subscription that holds CUDly's own Key Vault, PostgreSQL server, ACR and Container App environment, so a compromised runtime can enumerate the whole control plane of its own deployment. The stated need (host account ingested as a Self account) is an opt-in mode; the grant is unconditional.resource "azurerm_role_assignment" "subscription_reader" { scope = local.subscription_resource_id role_definition_name = "Reader" principal_id = azurerm_user_assigned_identity.container_app.principal_id }
Fix: gate it behind an
enable_self_account_ingestioninput defaulting false.
Suggested fix
Four independent single-resource edits; each item carries its own.
Found by the 2026-09-02 codebase audit, finding A13-014, A13c-021, A13c-022, A13c-023, reported by one reviewer and independently confirmed by a second. Full report: docs/audits/codebase-audit-2026-09-02.md.
Activity
IAmJSD commentedon Oct 23, 2026
Claiming: working on this
sec(iac): narrow three hosted-infra least-privilege grants (#1290)
sec(iac): narrow Azure host Reader grant to opt-in self-account inges…
cristim commentedon Nov 12, 2026
Status on main (faf1bcb, claude-platform): A13c-023 is done: the host subscription Reader grant is opt-in behind enable_self_account_ingestion (default false). Existing Azure deployments lose that grant on the next apply unless the variable is set; Azure deploys are paused. A13c-021 and A13c-022 already hold on main (the RDS ARN is built from the account id; the GCP compute grant is a custom role with a guard test). A13-014 is partly done: the grant member already pins repo id and ref; the pool rename is not done, because pool IDs are ForceNew and a rename would destroy the pool and break CI auth. The issue stays open until the owner decides on the pool rename.
cristim commentedon Nov 14, 2026
Claimed by claude-platform-2 (coordinator assignment 2026-11-14, not touching store_postgres.go, plans.ts, recommendations.ts): premise-check against main, then implement and close (Closes #323), or comment the evidence/blocker.
cristim commentedon Nov 14, 2026
Closing: three of the four grants are already fixed on main: A13c-021 rotation Lambda RDS grant scoped to the cluster ARN (898a166, #1290), A13c-022 Cloud Run compute.viewer replaced by a custom role with only compute.commitments.get/list and compute.machineTypes.list (guard test terraform/modules/compute/gcp/runtime_compute_iam_test.go), A13c-023 Azure Container App Reader is opt-in via enable_self_account_ingestion (faf1bcb). A13-014 (GCP CI impersonation): the workloadIdentityUser member now pins repo id and ref (attribute.repository_id_ref, 63c464a/#1066) and the provider attribute_condition pins owner id, repo id and ref, with create_before_destroy so the upgrade has no access gap; that closes the escalation path the finding describes. Decided (owner rule): the remaining 'rename the github-actions pool' is defense in depth only and workload_identity_pool_id is ForceNew (replaces the pool and provider, breaks CI auth for every GCP workflow until a bootstrap re-apply and a GCP_WORKLOAD_IDENTITY_PROVIDER variable update), so it is not done; logged as an optional owner action.