GitHub Actions OIDC Keyless Cloud Auth Prompt
Replace long-lived cloud access keys in CI with GitHub Actions OIDC federation — trust policies scoped to repo/branch/environment, least-privilege roles, and verification that stolen credentials can't be reused.
- Target user
- DevOps engineers securing CI/CD cloud access
- Difficulty
- Intermediate
- Tools
- Claude, ChatGPT
The prompt
You are a CI/CD security engineer who has eliminated static cloud keys from GitHub Actions by moving every workflow to short-lived OIDC-federated credentials. I will provide: - My cloud(s): AWS, GCP, and/or Azure - The workflows that need cloud access and what they do (deploy, read state, push images) - My repo/branch/environment structure - Any static keys currently stored as GitHub secrets Your job — DEFENSIVE credential hardening only: 1. **Explain the trust model.** GitHub mints a short-lived OIDC token per job; the cloud's identity provider exchanges it for temporary credentials. No static key ever lives in a secret. Name what gets verified: issuer (`token.actions.githubusercontent.com`), audience, and the `sub` claim. 2. **Lock down the `sub` claim — this is the security boundary.** Write the cloud trust policy (AWS IAM role trust policy / GCP Workload Identity Federation / Azure federated credential) that restricts the assumable identity to a SPECIFIC repo AND ref/environment, e.g. `repo:org/name:ref:refs/heads/main` or `repo:org/name:environment:production`. Show why a wildcard `repo:org/*` or unscoped `sub` is dangerous (any fork/branch could assume it). 3. **Least-privilege role.** Define the cloud permissions the workflow actually needs — no `AdministratorAccess`, no `*` resources. Tie deploy roles to GitHub Environments with required reviewers so prod creds need approval. 4. **The workflow YAML** — set `permissions: id-token: write`, use the official auth action, and confirm `contents: read` stays minimal. Show the smallest correct example. 5. **Kill the old keys.** Inventory existing static secrets, cut workflows over one at a time, then DELETE the secrets and deactivate the IAM keys — and confirm builds still pass. 6. **Guard against confused-deputy / claim spoofing** — require the audience claim, pin the issuer thumbprint where applicable, and avoid trusting `actor`-based claims that PRs can influence. 7. **Verify it's actually scoped** — show how to prove a workflow on a non-allowed branch CANNOT assume the role. Output: (a) the cloud trust policy with a tightly scoped `sub`, (b) the least-privilege permission set, (c) the workflow YAML, (d) a static-key decommissioning checklist, (e) a negative test proving an unauthorized ref is denied. Bias toward: per-repo+ref scoping, environment-gated prod, zero static keys.
Run this prompt with AI
Test it, get an AI-improved version, or compare models — live in the Prompt Workspace. No copy-paste.
Related prompts
-
OAuth2 / OIDC Token Security Review Prompt
Review an OAuth2 / OpenID Connect integration for token-handling weaknesses — flow choice, scope creep, token storage, validation, and refresh — that lead to account takeover or token theft.
-
CI/CD Pipeline Supply-Chain Hardening Prompt
Harden a CI/CD pipeline against supply-chain attacks — pinned and least-privilege actions/runners, OIDC deploy auth, artifact signing and provenance (SLSA), and protected branches/environments.
-
Workload Identity & Service Account Hardening Prompt
Harden how non-human workloads authenticate to cloud and Kubernetes — replace long-lived keys with federated/workload identity, scope service accounts tightly, and kill standing credentials.
-
Cloud IAM Privilege-Escalation Path Review Prompt
Audit cloud IAM for privilege-escalation paths and missing permission boundaries — finding the chained permissions that let a low-privilege identity become admin — and harden them.
More DevOps Security & Hardening prompts & error guides
Browse every DevOps Security & Hardening prompt and troubleshooting guide in one place.
Reading prompts? Get all 500 in one free PDF
500 battle-tested, copy-paste AI prompts engineered by a senior systems engineer — every one with fill-in placeholders and safety/back-out notes. Drop your email and it's yours.
- 500 prompts: Linux · Kubernetes · Terraform · OpenStack · GitLab · Docker · Monitoring · Incident Response
- Instant PDF download — yours free, forever
- Plus one practical AI-workflow email a week (no spam)
Single opt-in · unsubscribe anytime · no spam.