Putting a credential in the CI provider's secret store is the start of the job, not the end of it. Once injected it is available to the whole job, not the one step that needs it — which means the logs, the artifacts, the cache, and every process any build tool happens to start. Log masking helps only with the exact string and misses anything encoded or split on the way out. The two changes worth making first: short-lived federated credentials instead of stored cloud keys, and scope per environment instead of one key that can reach everything.
Most pipelines were not designed. They grew — a deploy step here, a published package there, a credential added at four in the afternoon because the build was red and somebody needed it working.
None of that is negligence; it is how working software gets delivered. It does mean the set of things your CI system can reach is usually larger than anyone has looked at recently, and that is worth an hour.
Masking is narrower than it looks
Every major provider masks secret values in build output, which is genuinely useful and quietly misunderstood.
Masking works by scanning output for the literal value it was given. An accidental echo is caught. What is not caught is the same secret in a different shape: base64 encoded for a header, URL encoded into a connection string, JSON escaped inside a payload, wrapped across lines by a formatter, or printed character by character because someone turned on a shell trace to debug the build.
So masking is a safety net for the obvious case. It is not a reason to be relaxed about what the pipeline prints, and a build log is a document with a long life and a wide audience.
The five surfaces
Logs. Covered above, with one addition: tools print more than you expect when a verbose flag is set, and verbose flags get added during incidents and left behind.
Artifacts. The surface that gets forgotten. If the build writes a configuration file with credentials rendered into it, assembles an environment file for integration tests, or caches a directory where a tool stored its login, and any of that sits inside the path being archived, it is uploaded with the artifact. Artifacts are typically downloadable by anyone with read access to the repository and they persist for weeks. Write generated credential files outside the artifact path, and exclude them explicitly rather than trusting a glob.
Every process in the job. Environment variables belong to the job, not to the command you set them for. Any process started inside it can read them, including build tools, test runners, and whatever those bring along. This is not a reason for alarm, but it is a solid argument for two habits: give each step only what it needs, and prefer credentials that expire in minutes to ones valid for a year.
Builds of unreviewed code. A pipeline step is code, and a pull request can change it. Providers withhold secrets from forked pull request builds by default precisely for this reason, and that default is doing real work. The care is needed when a workflow is deliberately configured to run with repository credentials against an incoming change — sometimes necessary, always worth a second reader, and best arranged so the privileged part runs separately from anything the contributor can edit.
Blast radius. Not a leak, but what turns one into an incident. A single deploy credential that can reach production, staging and the artifact registry means any exposure anywhere is an exposure everywhere. Separate credentials per environment cost an afternoon and change the size of the worst day considerably.
The change that beats the rest
Everything above is tightening. The structural fix is to stop storing the valuable credential at all.
The major CI platforms can prove their identity to a cloud provider directly, and receive a credential that is valid for that run and expires shortly after. No cloud key sits in the secret store, nothing needs rotating on a calendar, and an exposed build log from last March contains nothing usable today.
That removes the most valuable item on the list and converts rotation from a task somebody forgets into a property of the system. Where the platforms support it — and the common combinations do — it is the highest-value change available, and it is usually half a day of configuration rather than a project.
The same logic applies to anything else that can be made short-lived: registry tokens, database credentials issued per run, signing credentials held in a service rather than a variable. The ones that resist are typically third-party API keys with no federation story, which is exactly where the remaining effort belongs. For mobile work the signing material is its own case, with constraints that come from the platform rather than from you.
An hour well spent
- List every secret the pipeline holds and what each one can do. This step alone usually finds one credential with far more access than any step requires.
- Move cloud access to short-lived federated credentials. Highest value, lowest drama.
- Separate credentials per environment so production is not reachable from a staging build.
- Download your own artifact and look inside it. This finds things nothing else will.
- Check which jobs run on unreviewed changes and what they hold while doing it.
- Turn on the provider's secret scanning for the repository, since the other common path is a credential committed rather than injected.
None of this is sophisticated and none of it needs a new tool, which is rather the point. The pipeline accumulated access one reasonable decision at a time, and it comes back the same way — the same operational weight that comes with running your own CI, paid down in an afternoon rather than discovered during an incident.
Questions we get asked
Does the CI provider's log masking protect us?
Only against the exact string. Masking works by scanning output for the literal value it was given, so it covers a straight echo and misses anything transformed on the way out — base64 encoded, URL encoded, JSON escaped, split across lines, or printed one character per line by a debug flag. Treat masking as a safety net for the obvious case, not as the control that lets you be relaxed about what gets printed.
Why are builds from forked pull requests treated differently?
Because the code in them has not been reviewed yet, and a build step is code that runs with whatever the job holds. Providers withhold secrets from fork builds by default for that reason. The risk appears when a workflow is deliberately configured to run with repository credentials in the context of an incoming change, which is occasionally necessary and should be a reviewed decision with the privileged part kept separate from anything the contributor can alter.
Can a dependency read our pipeline secrets?
If they are in the environment, yes — environment variables belong to the job, not to one command, so every process started inside it can read them. That includes build tools, test runners and whatever those pull in. It is an argument for giving each step only the credentials it needs, and for preferring credentials that expire in minutes over ones that stay valid for a year.
What is OIDC federation and why does it matter here?
It lets the CI system prove its identity to a cloud provider and receive a short-lived credential for that run, so no long-lived cloud key is stored in the pipeline at all. It removes the most valuable secret from the list of things that can leak, and it makes rotation automatic rather than a task someone forgets. Where the platforms support it, it is the single highest-value change available.
Do build artifacts and caches carry secrets?
They can, and this is the surface teams forget. A config file written during the build with credentials rendered into it, a .env assembled for tests, or a cache directory containing a tool's saved login will all be uploaded if they sit inside the path being archived. Artifacts are often downloadable by anyone with repository read access and live for weeks, so write generated credential files outside the artifact path and exclude them explicitly.
Where should we start if the pipeline was never reviewed?
List every secret the pipeline holds and what each one can do, which usually surfaces one credential with far more access than any step requires. Then move cloud access to short-lived federated credentials, scope what remains per environment, and check what the artifacts contain. That sequence removes most of the exposure before anyone has to argue about tooling.
If nobody has listed what your pipeline can reach in the last year, that list is the most useful hour available. It is where we start on DevOps engagements, and it is usually shorter to fix than to discuss.