Secrets Exposed in CI/CD Logs or Configuration
Credentials used by build and deployment pipelines appear in job logs, pipeline definitions, unprotected variables or build artefacts readable by people who should not have them.
| Severity | High |
| CVSS 3.1 | 8.1 CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:N Open in the calculator |
| CVSS 4.0 | 8.6 CVSS:4.0/AV:N/AC:L/AT:N/PR:L/UI:N/VC:H/VI:H/VA:N/SC:N/SI:N/SA:N Open in the calculator |
| CWE | CWE-538: Insertion of Sensitive Information into Externally-Accessible File or Directory |
| OWASP Top 10 | A01:2025 Broken Access Control |
| MITRE ATT&CK | T1552.001 Credentials In Files, T1078 Valid Accounts |
| Category | Information Disclosure |
Description
Secrets used by a CI/CD pipeline, such as cloud keys, deployment credentials, registry tokens and signing keys, can be read by people or systems that do not need them, because they appear in places with broader access than the secret store. Common causes are build steps that print environment variables or run in verbose or debug mode, writing credentials to job logs; secrets written in plain text into pipeline definitions such as .gitlab-ci.yml, a Jenkinsfile or workflow files; pipeline variables not marked as masked, protected or secret, so that every project member can view them in the settings; and secrets baked into build artefacts, container image layers or cached files.
Masking in job logs is a safety net rather than a control. Platforms mask only values they know to be secret and that appear exactly as stored, so a secret that is encoded, split, transformed or written to a file can still appear in full. Logs and artefacts are often kept for long periods and are readable by everyone with access to the project, which often includes every developer, contractor and integration, and in public projects by anyone on the internet. Anyone who can read the logs, settings or artefacts can collect the secrets and use them directly.
Pipeline credentials usually have wide reach, such as deployment rights to production, write access to package registries or cloud administration roles, so their exposure can lead to changes to production systems, access to data or tampering with released software. This is most serious for long-lived credentials with broad permissions, and less so where secrets are short-lived or scoped to test environments.
The weakness is identified by reviewing pipeline definitions and variable settings, and by searching job logs and downloaded artefacts for credential patterns with secret scanning tools. Each secret found is checked to see whether it is still valid.
Remediation
Rotate exposed secrets, and keep secrets out of logs, definitions and artefacts:
- Revoke or rotate every secret found in logs, pipeline definitions, variables or artefacts, then delete the affected logs and artefacts. Rotation is what makes an exposed secret safe; deletion alone is not enough.
- Hold secrets only in the platform's secret store or an external secrets manager, marked as masked and, where supported, protected so that they are available only to protected branches and environments. Remove secrets written into pipeline definitions.
- Prefer short-lived credentials obtained at run time through OpenID Connect federation with the cloud provider to long-lived keys stored in the pipeline.
- Stop commands from printing secrets: avoid echoing environment variables, disable verbose or debug output in steps that handle credentials, and register any derived value with the platform's masking feature.
- Use the build tool's secret mounts rather than build arguments or files copied into images, and check that artefacts and image layers contain no credentials.
- Limit who can read job logs and artefacts, and set retention periods that match operational needs.
Confirm the fix by rescanning recent logs, pipeline definitions and artefacts, and checking that each secret found earlier has been revoked.
References
Add This Finding to Your Library
In Pental this write-up is in Settings, Library. Add to my library copies it into your own, rated in your firm's CVSS version, ready to put in your own words.
Free trialYour trial starts when your portal goes live, not when you sign up, so the time you spend setting up does not count. · No card required
Only need the reporting? Our reporting tool is free and open source, with the same library.