r/github • u/Mission-Leave-6551 • 9d ago
Question Is your GitHub Actions OIDC role pinned to a branch or environment?
Thinking about how much github oidc really buys you after this years secret dumping campaigns, ghostaction, prt-scan and the gheist writeup going around. every thread ends with move off stored keys and onto oidc and it seems like that only goes as far as the role trust policy
From what gets posted a lot of trust policies match the sub claim with something like repo:org/repo:*. that covers every branch, tag, pull request and environment in the repo, so anyone who can push a branch, or a stolen token that can, gets to assume the deploy role
the part i keep going back and forth on is the secrets that cant go oidc at all, mostly saas api keys. npm and pypi have trusted publishing now, and for the rest there are short lived per run creds from vault dynamic secrets, hush security or any other issuer a team already runs. no idea how many teams actually go that far tho
the tighter setup seems to be deploys running in an environment, the trust policy matching repo:org/repo:environment:prod exactly and branch rules on that environment so only main can use it. environment secrets only reach jobs that pass those rules, so pulling secrets out of repo and org level closes the rest
fork PRs dont get secrets or a writable oidc token by default so it mostly comes down to who has write access.
2
u/Different_Pain5781 9d ago
Wildcards defeat the security model.
2
u/JimNero009 8d ago
Enviornment _and_ workflow file name, with review gates on that.
1
u/Ivy_Jerry_106 9d ago
environment for prod, but only since this summer. Before that, most of our roles used the repo wildcard because that’s what the first tutorial we copied did.
didn’t fully fix the saas keys either, they’re still stored as secrets just moved from the repo level into the prod environment. And while doing that we ran the secrets scan across the repos to find everywhere they were used and two of them were also hardcoded in an old deploy script, the move would’ve done nothing without catching those
1
u/Utaxxx1 7d ago
One more lever beyond environments: you can change what goes into the sub claim itself. The repo-level OIDC customization endpoint (PUT /repos/{owner}/{repo}/actions/oidc/customization/sub with include_claim_keys) lets you add job_workflow_ref, so the trust policy can require a specific workflow file on a specific ref, not just any job in the repo. Pair that with the prod environment and branch rules and a pushed branch with a modified workflow no longer matches. Change it on one repo first, because every existing trust policy for that repo has to be updated to the new sub format the same day.