GitHub Actions can log in to HashiCorp Vault with its own short-lived OIDC token through Vault's JWT auth method, so no Vault token or AppRole secret ever needs to sit in a GitHub secret. The security of that design rests almost entirely on one thing: the bound claims on each Vault role. Get them right and only the intended repository, branch or environment can read the intended secrets. Get them wrong and any workflow that GitHub signs for, including one in a stranger's repository, may be able to log in.
This guide walks through the setup end to end: the JWT auth mount, bound claims and audiences, roles and policies per repository and environment, token lifetimes, the workflow side with hashicorp/vault-action, migrating away from stored Vault tokens, and logging. For Vault as a whole, read our HashiCorp Vault Guide; for the GitHub side of OIDC trust across clouds, see the GitHub Actions OIDC Federation Hardening Guide.
This is an independent guide from NHI Mgmt Group, based on HashiCorp's public Vault documentation and GitHub's public OIDC documentation as of November 2026. It is not sponsored or reviewed by HashiCorp or GitHub. Product features change, so confirm settings against each vendor's current documentation.
Key takeaways
- Use a Vault role with
role_typeset tojwt. Vault simply validates the JWT the runner presents; no browser flow is involved. - Point the mount at GitHub's issuer,
https://token.actions.githubusercontent.com, for bothoidc_discovery_urlandbound_issuer. - Every role needs bound claims. GitHub's own guidance says at least one condition is required so untrusted repositories cannot request tokens. In practice, bind the repository by immutable ID plus the branch or environment.
- GitHub tokens always carry an
audclaim, and since Vault 1.17 a JWT role must havebound_audiencesthat exactly matches it. Set a dedicated audience in the workflow and bind it. - Keep Vault token TTLs to minutes, attach one narrow policy per role, and do not export the Vault token to later steps unless a step truly needs it.
- Once JWT login works, delete the stored
VAULT_TOKENor AppRole secret ID from GitHub and revoke it in Vault.
How JWT auth works for GitHub Actions
When a job has the id-token: write permission, the runner can request an OIDC token signed by GitHub. The token describes the run: the repository, the owner, the ref, the environment, the workflow and the event. GitHub's OIDC reference lists the claims and the issuer, https://token.actions.githubusercontent.com.
The job sends that token to Vault's JWT auth method with the name of a role. Vault then:
- Verifies the signature using keys found through OIDC discovery on the configured issuer.
- Checks the issuer, the expiry and the audience.
- Checks that every claim listed in the role's
bound_claims(andbound_subject, if set) matches. - Issues a Vault token carrying the role's policies and lifetime.
The job uses the Vault token to read secrets or request dynamic credentials, and the token expires shortly afterwards. Nothing long-lived is stored in GitHub. The trade-off is that authorisation moves from "who holds the secret" to "which claims does this role accept", so the role definition becomes the security boundary.
The Vault JWT/OIDC documentation distinguishes two role types. OIDC roles drive a browser login through an identity provider and are for humans. JWT roles validate a token the client already holds and are the right choice for CI.
Configure the JWT auth mount
Enable the method and point it at GitHub. Using a dedicated mount path for GitHub keeps its roles separate from any other JWT issuers you trust, which matters because a mount can only use one signature verification method.
1 Sample only, based on the public documentation cited. Assess it independently against the current official documentation, test outside production and back up first.
vault auth enable -path=github-actions jwt
vault write auth/github-actions/config \
oidc_discovery_url="https://token.actions.githubusercontent.com" \
bound_issuer="https://token.actions.githubusercontent.com"This mirrors the commands in GitHub's Vault configuration how-to, which uses the default jwt path. Points to settle at this stage:
- Leave client ID and secret empty. For JWT-only validation, Vault's documentation says to leave
oidc_client_idandoidc_client_secretblank. - Do not set a permissive
default_role. If a workflow forgets to name a role, it should fail, not fall back to something broad. - Keep
verbose_oidc_loggingoff. HashiCorp warns that it logs received claims verbatim and should not be used in production. - Network reach. GitHub-hosted runners must reach Vault over the internet. If Vault is private, GitHub's how-to suggests a self-hosted runner, which brings its own hardening needs.
Who can change auth/github-actions/* is now a privileged question: anyone who can edit a role can widen its bound claims. Restrict write access to that path to the platform team and audit it, as described in How to audit HashiCorp Vault tokens, policies and auth methods.
Bound claims: deciding which GitHub identity can log in
A role's bound_claims is a map of claim names to required values. Every listed claim must be present and match; if a value is a list, the claim matches any item in it. With bound_claims_type left at its default of string the match is exact; setting it to glob allows wildcards. Prefer exact strings and reach for globs only where you genuinely need them, because a careless pattern such as repo:my-org/* trusts every repository in the organisation, including ones created next year.
Which claims to bind
| Claim | What it identifies | Use |
|---|---|---|
repository_id | The repository's numeric ID | Bind always; it does not change on rename |
repository_owner_id | The owning organisation's ID | Bind always; stops a look-alike organisation |
repository | owner/name | Readable, but names can be reused after deletion |
sub | Repository plus environment, pull request, branch or tag | Bind with bound_subject or in bound_claims |
environment | The GitHub environment of the job | Bind for production roles |
ref | The triggering git ref | Bind to a protected branch or tag |
job_workflow_ref | The reusable workflow and its ref | Bind when a central deploy workflow is the only path |
runner_environment | github-hosted or self-hosted | Bind if a role must only run on one kind of runner |
GitHub's reference notes that the sub claim changes shape with context. If the job references an environment, sub is repo:ORG/REPO:environment:NAME. Otherwise pull request runs use repo:ORG/REPO:pull_request, and branch and tag runs use repo:ORG/REPO:ref:refs/heads/BRANCH or refs/tags/TAG. A role that binds a branch subject will therefore stop working the day someone adds an environment to the job, which is a common source of confusing failures.
Immutable subjects
GitHub's reference explains that repositories created after 15 July 2026, and repositories renamed or transferred after that date, use an immutable sub format that includes owner and repository IDs, for example repo:octo-org@123456/octo-repo@456789:ref:refs/heads/main. Older repositories keep the old format unless they opt in. GitHub also recommends conditions on repository_id or repository_owner_id for stable identification, and notes that immutable claims are not available on GitHub Enterprise Server. Check which format each repository uses before you write bound_subject, and bind the ID claims in all cases.
Audience
GitHub sets the default aud to the URL of the repository owner. Vault's documentation says that if a JWT has an aud claim, bound_audiences is required on JWT roles and, since Vault 1.17, must exactly match one of the token's audiences. Rather than binding the owner URL, which any workflow in the organisation produces, choose a dedicated value per Vault cluster, such as https://vault.example.com, request it in the workflow with the jwtGithubAudience input, and bind it on every role. That stops a token minted for another relying party being replayed against Vault.
Roles and policies per repository and environment
Create one role per trust decision, not one role per organisation. A typical pattern is a read-only role for build jobs on any branch of a repository, and a separate role for production deploys that requires the protected production environment.
vault policy write payments-api-prod - <<EOF
path "secret/data/payments-api/prod/*" {
capabilities = ["read"]
}
EOF
vault write auth/github-actions/role/payments-api-prod -<<EOF
{
"role_type": "jwt",
"user_claim": "repository",
"bound_audiences": ["https://vault.example.com"],
"bound_claims_type": "string",
"bound_claims": {
"repository_id": "456789",
"repository_owner_id": "123456",
"environment": "production",
"ref": "refs/heads/main"
},
"claim_mappings": {
"workflow": "workflow",
"run_id": "run_id",
"actor": "actor"
},
"token_policies": ["payments-api-prod"],
"token_ttl": "10m",
"token_max_ttl": "15m",
"token_no_default_policy": true
}
EOFNotes on the fields:
user_claimsets the identity alias in Vault. GitHub's example usesactor, which creates an alias per human who triggers a run. Usingrepositoryorrepository_idgives one stable entity per repository, which suits a machine identity and keeps entity counts down. Choose deliberately; it shapes your audit trail and client counts.claim_mappingscopies claims into token metadata so they appear in audit logs. Vault fails authentication if a mapped claim is missing, so map only claims that are always present. The keyroleis reserved.- Policies should grant the narrowest paths and capabilities. Prefer dynamic secrets engines (database, cloud) where possible so even the secret the job reads is short-lived.
token_no_default_policyremoves the default policy so the token can do only what the role grants.
Pair the production role with GitHub environment protection rules, as GitHub's how-to recommends, so a reviewer must approve before the job that can obtain the token runs. Our guide on How to Scope CI OIDC Trust to Branch and Environment covers the branch and environment design in more depth.
Pull requests and forks
Do not give any role that a pull request run can satisfy access to deploy credentials. Pull request code is untrusted until merged. If tests need secrets, give them a separate role bound to repo:ORG/REPO:pull_request with a policy that reaches only test fixtures.
Token lifetime and limits
The JWT auth API reference lists the token parameters a role can set. The ones that matter for CI:
token_ttlandtoken_max_ttl: both default to 0, which means the mount or system default applies, often far longer than a job. Set them explicitly. GitHub's example uses a 10-minute TTL.token_explicit_max_ttl: a hard ceiling that renewals cannot exceed.token_num_uses: defaults to 0 (unlimited). A small number can suit a job that reads one secret, but it breaks easily when an action makes extra lookups, so test it.token_bound_cidrs: useful for self-hosted runners with known egress addresses; impractical for GitHub-hosted runners whose addresses vary.token_type: batch tokens are lightweight and cannot be renewed, which suits short CI jobs that do not need child tokens.
The API reference also documents leeway settings for JWT roles: clock_skew_leeway (60 seconds when set to 0), and expiration_leeway and not_before_leeway (150 seconds when set to 0), with -1 disabling each. Leave them at defaults unless you have clock problems; widening them extends the window in which a stolen GitHub token can be replayed.
The workflow side with vault-action
On the GitHub side, grant the job permission to request a token and call the action. Scope permissions at the job level so only the job that needs Vault can mint a token.
jobs:
deploy:
runs-on: ubuntu-latest
environment: production
permissions:
id-token: write
contents: read
steps:
- name: Read secrets from Vault
uses: hashicorp/vault-action@<full-commit-sha>
with:
url: https://vault.example.com
method: jwt
path: github-actions
role: payments-api-prod
jwtGithubAudience: https://vault.example.com
secrets: |
secret/data/payments-api/prod/db password | DB_PASSWORD ;
secret/data/payments-api/prod/api key | API_KEYPoints from the vault-action README and GitHub's how-to:
id-token: writelets the job fetch an OIDC token and grants no write access to repository contents. Once you set apermissionsblock, unspecified scopes get no access, which is whycontents: readis listed.pathnames a custom auth mount, heregithub-actions.secretstakes requests separated by;in the form path, key, then|and an output or environment variable name.exportEnvdefaults to true, so secrets become environment variables for later steps. Every later step, including third-party actions, can read them. Keep the secret-consuming steps in the same job and avoid untrusted actions after the Vault step.exportTokenandoutputTokendefault to false. Leave them off unless a later step must call Vault directly; if you enable them, revoke the token in a final step that runsif: always().tlsSkipVerifydefaults to false and should stay that way. UsecaCertificatefor a private CA.- The README notes that masking only obscures secrets in logs. It does not stop a step from sending a secret elsewhere.
Pin the action to a full commit SHA, as you would any third-party action, because the action handles your secrets. For namespaces in HCP Vault or Vault Enterprise, add the namespace input.
Removing Vault tokens from GitHub secrets
Many estates start with a long-lived Vault token or an AppRole role ID and secret ID stored as GitHub secrets. Those are exactly the credentials that leak through workflow logs, compromised actions and forked runs. A safe migration:
- Inventory. List every repository and organisation secret that holds a Vault token or AppRole secret ID, and map each to the Vault policies it carries. Our guide on How to audit Vault AppRole and secret ids helps find the Vault side.
- Create JWT roles with the same or narrower policies, bound to the repository IDs and environments that actually use them.
- Switch the workflow to
method: jwt, run it, and confirm in Vault's audit log that logins come through the new mount. - Delete the GitHub secret and revoke the old token or destroy the secret ID in Vault. Deleting only on the GitHub side leaves a valid credential wherever it was copied.
- Block regression. Add a secret scanning rule or policy check that flags new
VAULT_TOKENstyle secrets.
Logging and detection
With claim mappings in place, each Vault audit entry for a GitHub login carries the workflow, run and actor metadata, so a secret read can be traced back to a specific run. Useful detections:
- Login failures on the GitHub mount, grouped by role. A burst often means a changed
subformat or a missing environment, but it can also mean someone probing roles. - Successful logins from a repository ID that is not in your expected list, which signals an over-broad glob.
- Changes to
auth/github-actions/role/*orauth/github-actions/config, alerted to the platform team. - Production role logins outside deployment windows or without a matching approved deployment in GitHub.
When login fails, Vault's error usually names the claim that did not match. Our HashiCorp Vault Permission Denied Troubleshooting Guide covers the policy side, and the GitHub Actions OIDC Errors Troubleshooting Guide covers token request failures.
Framework mapping
- NIST SP 800-53 IA-5 (Authenticator Management): replaces stored static authenticators with short-lived, issuer-signed ones.
- NIST SP 800-53 SC-12 (Cryptographic Key Establishment and Management): signing keys stay with GitHub and are discovered, not copied.
- MITRE ATT&CK T1552.001 (Credentials In Files): removes Vault tokens from repository and workflow configuration.
- MITRE ATT&CK T1528 (Steal Application Access Token): short TTLs and audience binding narrow the value of a stolen token.
Common failure patterns
- A role with no bound claims, or only an audience, so any GitHub workflow anywhere that requests that audience can log in.
- Glob patterns on
suborrepositorythat match a whole organisation or a name prefix. - Binding repository names only, so a deleted and recreated repository, or a transferred one, inherits access.
- One shared role for build and deploy, so a pull request run can read production secrets.
- Leaving
token_ttlat 0 so the mount default (often hours or more) applies. - Exporting the Vault token to the environment and then running untrusted actions in the same job.
- Keeping the old
VAULT_TOKENsecret "just in case" after migration. - Binding a branch
suband then adding an environment to the job, breaking login without anyone understanding why.
Practitioner checklist
- Mount a dedicated JWT auth path for GitHub with
oidc_discovery_urlandbound_issuerset to GitHub's issuer. - Set a dedicated audience in workflows and bind it with
bound_audienceson every role. - Bind
repository_idandrepository_owner_idon every role, plus environment or ref for production. - Use exact string bound claims; review any glob.
- Create separate roles for pull request, build and deploy jobs.
- Set
token_ttl,token_max_ttlandtoken_no_default_policyexplicitly. - Add claim mappings for workflow, run and actor, and confirm they reach the audit log.
- Pin
hashicorp/vault-actionto a commit SHA and leaveexportTokenoff. - Remove stored Vault tokens and AppRole secret IDs from GitHub and revoke them in Vault.
- Alert on changes to the mount config and roles, and on logins from unexpected repositories.
Standards and references
- HashiCorp: Vault JWT/OIDC auth method
- HashiCorp: Vault JWT/OIDC auth method API
- HashiCorp: vault-action README
- GitHub Docs: Configuring OpenID Connect in HashiCorp Vault
- GitHub Docs: OpenID Connect reference
- IETF: RFC 7523 JWT Profile for OAuth 2.0 Client Authentication and Authorization Grants
- NIST: SP 800-53 Rev. 5
- MITRE ATT&CK: Steal Application Access Token
Related NHI Mgmt Group resources: HashiCorp Vault Guide · GitHub Actions OIDC Federation Hardening Guide · How to Scope CI OIDC Trust to Branch and Environment · How to audit Vault AppRole and secret ids