Skip to content
Tech Interview Prep
Technical interview guide

Secrets Management in Pipelines

Keeping credentials and keys out of source control and pipeline logs, while still letting automation use them.

Minutes to read
4
Practice MCQs
25
Interview Q&A
25
Edition
v5
Editorial status
Reviewed

Scope: GitHub Actions, AWS IAM, Google Cloud IAM, HashiCorp Vault, OWASP, and NIST guidance current 2026-08-31.

Overview

Curated: · Written: · Reviewed:

Secrets Management in Pipelines

In one line

Give each pipeline job a short-lived, narrowly scoped credential issued after it proves its identity, never a long-lived key sitting in source, logs, workspaces or runner disks. Reach for OIDC federation or a dedicated secret service whenever a job can touch production.

Key definitions

  • OIDC federation: the CI platform signs a token describing the job, and the cloud checks issuer, audience and subject before issuing a session credential.
  • sub claim: the identity the trust policy matches, such as repo:acme/web:ref:refs/heads/main or repo:acme/web:environment:production.
  • Secret zero: the bootstrap identity a workload needs before it can fetch anything else.
  • Lease and TTL: how long a dynamic credential lives. Renewal extends it, revocation ends it early.
  • Response wrapping: a single-use token that unwraps once to the secret, so a copy of the wrapping token exposes it at most once.
  • Untrusted-to-trusted boundary: the point where attacker-influenced code (fork PR code, dependencies, package scripts) shares a context with privileged material.

Formulas and complexity

The exposure window after exfiltration ends at the earlier of expiry or revocation:

exposure=min⁡(tissue+TTL,  trevoke)−texfil\text{exposure} = \min(t_{issue} + TTL,\; t_{revoke}) - t_{exfil}

With issue at 10:00, TTL 15 min, exfiltration at 10:07 and revocation at 10:50, exposure is min(10:15, 10:50) minus 10:07 = 8 minutes.

How it works

The job asks the CI platform for an OIDC token. The cloud validates the token's aud and sub against the role's trust policy. A match returns a session credential that expires at its TTL. A mismatch returns AccessDenied. Nothing is stored in the repository, and the credential dies with the job.

aud and sub match mismatch Job requests OIDC token Token carries iss, aud, sub Cloud checks trust policy Short-lived scoped credential AccessDenied Job uses it until TTL

When to use and when not to

SituationUseAvoid
Production cloud deployOIDC with an exact sub, bound to an environment or protected branchStored access key, or a repo:acme/* wildcard
Database accessDynamic credentials fetched at use, with lease renewalStatic password in a Secret rotated by hand
Fork and PR testsNo secrets, no privileged tokenpull_request_target that checks out and runs head code
SigningKMS sign operationExporting the private key to a runner
Low-stakes valueCI-native secret storeAnything a production role can reach

Traps interviewers probe

  • Wildcard subject. repo:acme/*:* lets any repository in the org assume the prod role. Fix: StringEquals on the exact sub, ideally the environment form.
  • Branch sub after moving to an environment. Once a job runs under an environment, its sub becomes environment:production, so a ref:refs/heads/main match fails. Fix: update the trust policy to the environment sub.
  • Fetching once and holding forever. A service that reads a dynamic credential at startup breaks when the lease ends. Fix: fetch per lease, renew before expiry and reconnect on auth failure.
  • Rotating the wrong secret. Rotating database passwords while the Vault token that fetches them never changes leaves the attacker a way back in. Fix: rotate and revoke the bootstrap identity too.
  • Trusting the masker. Redaction matches exact registered values and misses encodings, splits and error dumps. Fix: keep secrets out of logs and treat redaction as defense in depth.
  • Passing secrets on the command line or into images. Process listings show arguments, and image layers outlive the job. Fix: pass secrets through a runtime fetch or a file the job removes.

Interview tips

Open with the threat, not the product: "Fork PRs and dependencies are attacker-controlled, so whatever the job can reach is the blast radius. I start by deciding what each job can reach."

Expect these follow-ups:

  • A malicious dependency runs in the build. It reads any token in the environment, so the answer is short TTL, a registry scope limited to one repo and deployment by digest, not tag.
  • The OIDC trust policy has a wildcard. Write the exact StringEquals sub and explain what the wildcard allowed.
  • A credential appeared in a build log. Revoke first, then review use in the audit log, then clean the log.
  • The CI issuer is compromised. Revoke trust in the issuer, rotate the trust relationship, and fail new privileged jobs closed.

30-second outline: "Untrusted code runs in the pipeline, so I give each job only what its stage needs. Production jobs get OIDC credentials whose subject is pinned to the protected environment and whose TTL covers only the deploy. Secrets never enter source, logs or images. Dynamic credentials are fetched at use and renewed before expiry. I audit issuance and use, and I rotate the bootstrap identity on a schedule so a leaked token cannot outlive its purpose."

Feedback on this overview

Log in free to save your progress and keep bookmarks and notes for a quick revision before your interview.