Skip to content

fix(infra): scope task-runner Key Vault access to specific secrets#303

Merged
peteroden merged 1 commit intomainfrom
fix/297-kv-secret-scoping
Mar 16, 2026
Merged

fix(infra): scope task-runner Key Vault access to specific secrets#303
peteroden merged 1 commit intomainfrom
fix/297-kv-secret-scoping

Conversation

@peteroden
Copy link
Owner

What

Replace vault-wide Key Vault Secrets User role for the job (task-runner) identity with per-secret scoped RBAC assignments.

Why

The task-runner had access to all Key Vault secrets including controller-only ones (gitlab-token, jira-api-token). This violates least privilege — the task-runner only needs github-token or copilot-api-key.

Changes

  • infra/keyvault.tf: Replace single azurerm_role_assignment.job_kv (vault-wide) with two per-secret assignments:
    • job_kv_github_token → scoped to {vault}/secrets/github-token
    • job_kv_copilot_api_key → scoped to {vault}/secrets/copilot-api-key

Design decision

Both secrets are granted unconditionally regardless of copilot_auth mode. Only one secret exists in KV at a time, so granting access to a non-existent secret is harmless. This avoids conditional RBAC complexity for zero security benefit.

How to test

  1. cd infra && terraform init -backend=false && terraform validate
  2. After apply: verify task-runner can still read its secrets
  3. Verify task-runner gets 403 when attempting to read gitlab-token

Review notes

  • OWASP review: clean (no findings)
  • Cross-vendor code review: suggested conditional RBAC — declined as noted above

Closes #297

@peteroden peteroden added the security Security hardening label Mar 16, 2026
Replace vault-wide Key Vault Secrets User role for the job identity
with per-secret scoped assignments. The task-runner can now only read
github-token and copilot-api-key, not controller-only secrets like
gitlab-token and jira-api-token.

Closes #297

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@peteroden peteroden force-pushed the fix/297-kv-secret-scoping branch from 8de556f to d358354 Compare March 16, 2026 15:35
@peteroden peteroden merged commit 9bf8895 into main Mar 16, 2026
11 checks passed
@peteroden peteroden deleted the fix/297-kv-secret-scoping branch March 16, 2026 15:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

security Security hardening

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Scope task-runner Key Vault access to specific secrets

1 participant