Skip to content

Secrets Doppler and OIDC

github-actions[bot] edited this page Oct 30, 2026 · 5 revisions

Secrets: Doppler and OIDC

What this is. How a CI job here gets a credential it needs (a Docker Hub token, a Snyk token, a GitHub App key) without that credential living in GitHub. It is the page most worth reading slowly, because the same idea (a job proves who it is instead of holding a password) shows up in PyPI Trusted Publishing, cosign signing, Codecov and build attestations too.

The model, for someone new to it

The old way: you copy a token into GitHub's "Secrets" page, and every workflow in that repository can read it. Three problems. You cannot read it back, so you cannot audit it. You copy it into every repository, so rotating it means finding every copy. And deleting the GitHub secret does not revoke the token that was in it.

The model here has four parts.

  1. Doppler holds the secrets. It is a secrets manager the maintainer's projects already used at runtime, so it already had an audit log.
  2. No long-lived secret is stored in GitHub. There is not one GitHub Actions secret in a calling repository once it is on this path. gh secret list should print nothing.
  3. The job proves who it is. When a job runs, GitHub can mint a short-lived signed token for it (OIDC; see the Glossary). The token says, in signed claims, which repository the job belongs to and which ref it runs on. The job posts it to Doppler.
  4. Doppler answers only if the identity matches. An identity in Doppler is a rule: "a token from GitHub's issuer, for this audience, whose subject is exactly this repository on this branch, may act as this service account". If the claims do not match, Doppler refuses. If they do, it returns a token that lives for the job and can read one config.
 GitHub job ──(id-token: write)──> GitHub mints a JWT: issuer, audience, subject
     │
     └── posts the JWT to Doppler /v3/auth/oidc
              │
              ├── issuer, audience and subject match an identity? ──no──> refused
              │
              └── yes ──> short-lived token for that service account
                              │
                              └── reads the one config it may read ──> masked env vars

Nothing static exists on either side. Doppler's log says which repository fetched.

Where it sits in the workflows

The workflows try, in order:

  1. OIDC when doppler-identity-id is set.
  2. A service token when the caller passes the GitHub secret DOPPLER_TOKEN: read-only, one config. Doppler still rotates it, but it is one static credential in GitHub per repository, which is what the design is trying to end, so it is the second choice for a Doppler plan without OIDC identities.
  3. Nothing, with a notice. A pipeline runs before Doppler is wired up; steps that need a secret then skip (Docker Hub publish) or fail naming the missing secret (Snyk).

The fetch is gated on a trusted ref: the default branch, a version tag (vN.N.N) or a schedule. A pull request from anywhere and a push to any other branch get a notice and nothing else. That is doppler-trusted-refs-only, on by default in every workflow. A pull_request from a fork never fetches whichever way the input is set, because GitHub mints no OIDC token for it and the step refuses it.

Which events. the event must be on a short list, push, workflow_dispatch or schedule; only listed events can be trusted when the gate is on, whatever the ref. A schedule run fetches; a push or workflow_dispatch fetches on the default branch or a release-shaped tag. The doppler-trusted-refs-only value is true or false in any casing; anything else (empty, a typo) stops the job and never means off.

Tags, and the residual risk. The step trusts a tag by its name (vN.N.N), and when the job has a checkout with the default branch's remote ref and a complete (not shallow) history, it also requires the tagged commit to be in that history; a tag that a clean ancestry check shows not to be is refused and flagged untrusted-tag. A job with no checkout, a shallow clone (for example the default actions/checkout depth) or no origin/<default branch> ref cannot show it, and then only the name is checked (a notice says so). The action holds no credential to ask GitHub whether a tag is protected, so anyone who can push a vN.N.N tag can still reach a fetch from a job that cannot verify it. Close that with a tag protection ruleset on v* in the repository, and check out with fetch-depth: 0 before the step if releases are cut from the default branch. A release cut from another branch is refused when the history is available.

pull_request_target is different. It runs the workflow file from the base branch with access to secrets, and the step computes its fork check for pull_request only. With doppler-trusted-refs-only: true (the default) a pull_request_target run fetches nothing. With false it selects OIDC, forks included, and tests/test_doppler_gate.py pins that behavior so nobody mistakes it for closed. Set false only in a workflow that never checks out or runs the pull request's code and never expands its text into a shell; project-sync is the one such caller here (README, "Why pull_request_target").

Which tags count. Only a ref shaped exactly refs/tags/vMAJOR.MINOR.PATCH (digits only, for example refs/tags/v1.2.3). Any other tag name, such as refs/tags/anything, refs/tags/v1, refs/tags/v1.2.3.4, refs/tags/V1.2.3 or refs/tags/v1.2.3-rc.1, and any branch spelled like a tag, gets no secrets. This repository's own tags are all that shape. A caller that releases from a pre-release tag does not fetch secrets on it; it fetches on the default branch or on a release tag.

A refused tag fails a job that asked for a secret. When a tag is not a vMAJOR.MINOR.PATCH release tag, the decide step fetches nothing and reports untrusted-tag=true. A job that was asked for a secret-backed feature then fails with an error naming the ref (ref is not a vMAJOR.MINOR.PATCH release tag: Doppler secrets are not fetched) instead of skipping it and staying green: security.yml with snyk: true, and container-release.yml with push: true and dockerhub: true. In container-release.yml the guard sits in the merge job, after the build job has already pushed the per-architecture images to GHCR: the run fails after per-architecture images were pushed to GHCR, and no index and no Docker Hub image is published. The orphaned per-architecture manifests remain until deleted. A GHCR-only release (dockerhub: false) is unaffected, and so are the default branch, schedules and pull requests, which still skip with a notice. A caller that triggers on a loose tag pattern such as v* and tags a pre-release (v1.2.3-rc.1) will see these jobs fail; to opt out, do not trigger the Doppler-backed jobs on such tags (for example tags: ['v*.*.*'] plus a branch filter, or an if: on the job).

What this does not do. It narrows which refs receive secrets; it does not remove the exposure. The check reads the name of the ref, and anyone with write access can still create a tag with a matching name on any commit. The Version tags are immutable ruleset in the baseline (see BASELINE.md) blocks deleting, moving and force-pushing a v* tag, so a published version cannot be reused. It does not restrict who may create one. Restricting creation needs a separate ruleset on the tag namespace that limits creation to chosen actors, and that is not part of the baseline today. Treat the Doppler identity as the control that holds: list only the subjects that must fetch (the default branch, and a tag subject only where a release job really reads a secret), never a pull request, and keep the Viewer role on the one config the repository needs.

Why: a pull request runs the code it proposes. A secret in that job is a secret the proposal can read. tests/test_doppler_gate.py runs the decision under bash for the event kinds and ref shapes it lists.

The Doppler steps are copied into each workflow that needs them rather than called as a shared action, because a reusable workflow cannot name the commit it runs from; a test holds the copies byte-identical to .github/actions/doppler-secrets, which is the source.

Keeping a production credential away from the rest of the job

The composite action .github/actions/doppler-secrets has two inputs the inlined workflow copies do not need:

  • export: env (the default, today's behavior) or outputs. Any other value fails the job.
  • names: an optional comma or whitespace separated allow-list of secret names. It narrows both modes; a name missing from the config fails the job, naming the secret and never a value. Required with export: outputs (an empty list would return the whole config); with export: env, empty means every secret.

The trade-off. env writes the whole config into the job's environment, so every later step and every action's post-run hook can read all of it. A compromised dependency or hook in a deploy job is then a way to a production credential. outputs writes nothing to the environment: the values are masked, returned as one JSON output ({} when nothing was fetched), and the caller passes each one to the step that needs it through env:, reading it with fromJSON(steps.<id>.outputs.secrets).NAME. export: outputs with names is the safe form for a job that holds a production credential. The README shows a worked step ("Handing a secret to one step"). The first callers are the no-php-no-cry and Reach-Around deploy workflows.

In outputs mode every non-empty value is masked whatever Doppler's visibility says, Doppler's own DOPPLER_PROJECT/CONFIG/ENVIRONMENT labels are never returned, a selected value that is empty fails the job (a missing credential must not come back as an empty string), a value shorter than 8 characters fails the job (masking a short or common-word value such as true or prod would redact that text from every later log line), and a value holding a NUL or a U+FFFD replacement character (which is what an escaped lone surrogate would silently become) fails the job. The Doppler reply must be valid UTF-8 and at most 4,000,000 bytes, and every stage of reading it (request builder, curl, head) must succeed. In OIDC mode the job's request URL and token are shape-checked and the token masked before any request is made. In export: env mode, values Doppler marked unmasked stay unmasked (compatibility with the pinned action), and outputs mode is the form to use for production credentials. GitHub caps a step output at about 1 MB, counted in UTF-16; the action refuses more than 500,000 UTF-16 code units, so list fewer names.

Caller rules. Pass one extracted value to one step through its env:. Never pass steps.<id>.outputs.secrets whole as an env value. Never put it, or a value from it, in GITHUB_ENV, GITHUB_STEP_SUMMARY, artifacts, caches, debug output or job outputs. add-mask protects logs only; it is not an authorization boundary. Any step that receives an extracted value, including a compromised dependency inside that step, can steal it.

What lives in the ci config

One Doppler project ci with environment ci and config ci, separate from every runtime project. Every caller reads that one config. It holds only what pipelines read:

Name Used by
DOCKERHUB_USERNAME, DOCKERHUB_TOKEN the container release, when dockerhub: true
SNYK_TOKEN security.yml, when snyk: true

Not in the table: Codecov (the upload authenticates with the coverage job's own OIDC token, so nothing is stored) and gitleaks (the binary needs no licence; the old action's GITLEAKS_LICENSE is gone, issue #90).

Every value in a Doppler config is exported into the job's environment. That is why the config is its own project: a runtime token placed beside the CI names would become a CI secret in every job of every repository. The trade is stated plainly: every CI job holds every CI credential while it runs, including a Docker Hub token in a repository that never publishes there. The credentials are account-wide at their providers, so one copy is one place to rotate, and Doppler's log still names which repository fetched.

scripts/doppler-ci-set.sh NAME sets one value, typed with echo off, never on a command line or in shell history. --from-file PATH takes a multi-line value such as a PEM key.

Setup, once per workplace and once per repository

Service Account Identities need a Doppler workplace on the Team or Enterprise plan. On a Developer plan use the service token path and skip the identity steps.

Once: create the ci project, environment and config, and set the names above with doppler-ci-set.sh.

Per repository:

  1. Service account. Create one per repository (for example gha-typo-sniper), granted Viewer on the ci project's ci environment and nothing else. Its workplace role is empty.
  2. Identity on that service account, type OIDC:
    • Issuer: https://token.actions.githubusercontent.com
    • Audience: GitHub's default, https://github.com/<owner>.
    • Subjects: see the next section.
  3. Repository variable DOPPLER_IDENTITY_ID set to the identity's UUID (Settings, Secrets and variables, Actions, Variables). It is an identifier, not a secret: the trust is the claim match, and a variable keeps the caller YAML free of per-repository values.
  4. Delete any old GitHub secrets (DOCKERHUB_*, CODECOV_TOKEN, SNYK_TOKEN) once a run has gone green through Doppler. Then rotate the values at the provider: moving a token does not change it. GITHUB_TOKEN is not a stored secret and stays.

scripts/new-repo.sh does the GitHub side and prints the Doppler steps.

The subject forms, including the immutable one

The sub claim names the repository and the ref. GitHub can send it in two forms, and which one a repository sends is its own setting (gh api repos/OWNER/REPO/actions/oidc/customization/sub, field use_immutable_subject):

Form Example
Plain repo:OWNER/REPO:ref:refs/heads/main
Immutable repo:OWNER@<owner-id>/REPO@<repo-id>:ref:refs/heads/main

The immutable form uses numeric ids, so a rename or a transfer cannot make a different repository match. Repositories created from mid-2026 send it by default; older ones send the plain form.

List both, each with its tag twin (:ref:refs/tags/*), and master instead of main where that is the default branch. Listing both means flipping the setting changes nothing.

Measured, 2026-10-03: eight repositories on the immutable default failed every Doppler fetch with claim "sub" does not match identity auth config until the second form was added; three of them from their first run with Snyk on. The audit cannot see Doppler's side, so a new repository's first push to main is the check. Doppler accepts several subjects per identity and has no update call: to change the list, create a new identity, point the repository variable at it, then delete the old one.

Why :pull_request is excluded, and the one place it is allowed

The identity for the ci config must never match repo:OWNER/REPO:pull_request. The workflows already refuse to fetch on a pull request, and the identity is the second lock on the same door. The broad repo:OWNER/REPO:* works but also matches pull-request tokens, so it would rely on the workflow-side gate alone.

There is exactly one place that needs the opposite: project-sync.yml, whose caller reacts to pull_request_target so that a pull request from a fork reaches the project board. On that event GitHub's subject is repo:OWNER/REPO:pull_request, and the ci identity correctly refuses it. Measured 2026-10-05 on the first live callers: every pull_request_target run failed at the Doppler step with the claim "sub" error, while issues, schedule and workflow_dispatch runs worked (issue #93). The same measurement found the second problem: the board App's private key sat in the shared ci config, so it was in the environment of every job of every repository.

The fix for issue #93 (landed in #103) is a separate Doppler project projects, config prd, holding exactly one secret (PROJECTS_APP_PRIVATE_KEY), its own service account and identity whose subjects include the :pull_request forms, and a separate repository variable PROJECTS_DOPPLER_IDENTITY_ID. Allowing :pull_request there is acceptable because the job has no checkout, the config holds one key, and the key can only write a board. The blast radius is stated in the issue: a fork's pull request event can mint a token that writes items and field values and reads issues and pull requests in the installed repositories; it cannot read any other secret or run any code. See Keeping a project board current.

The audit gets its own project

The weekly audit's GitHub App can read the settings of every repository, and the ci config is read by every caller's pipeline, so the App's key lives in a separate Doppler project audit, config prd, behind its own service account whose identity is scoped to main of this repository only. The audit mints one-hour installation tokens from it (one per owner) and stores no personal access token. See The baseline and the weekly audit.

What this refuses to do

  • It never stores a long-lived credential in GitHub on the OIDC path.
  • It never uses secrets: inherit; a caller passes DOPPLER_TOKEN by name, and may leave it unset.
  • It never fetches on a pull request or a branch that is not the default, unless a caller sets doppler-trusted-refs-only: false (only project-sync has a reason).
  • It never puts a runtime credential in the ci config.
  • It never uses a personal access token for a CI credential where a GitHub App can do the job (the maintainer's ruling, 2026-10-05).

Clone this wiki locally