Safeguard
Developer Tools•

Does CI_DEBUG_TRACE leak secrets in GitLab job logs?

Yes. GitLab warns debug logging exposes every variable and secret a job can use. Who can see it, the runner variable trap, and how to clean up afterwards.

Safeguard Security Team
3 min read

Yes. Setting CI_DEBUG_TRACE to true makes a job log every command and expanded value, and GitLab states that it exposes all variables and secrets available to the job. Turn it on briefly, with logs restricted to your team, then delete the log. Never leave it enabled in a project with public logs.

What GitLab says

GitLab's troubleshooting page calls debug logging a serious security risk. It tells you to make sure only team members can view job logs before you enable it, and to delete job logs containing debug output before making logs public again. Access to the debug output is limited to users with the Developer, Maintainer or Owner role when the variable is set in .gitlab-ci.yml or in the CI/CD settings. Users with lower roles cannot see those logs.

The runner variable trap

The same page flags a difference. If you set CI_DEBUG_TRACE as a local variable on the runner, the runner does not check permission levels, so everyone who can see job logs sees the debug output. GitLab recommends setting it only in GitLab, not on the runner.

Where setWho sees debug logs
.gitlab-ci.yml or CI/CD settingsDeveloper, Maintainer, Owner
Local runner variableEveryone with job log access

Why masking does not save you

Masking replaces known values with a placeholder in the log, but it matches exact strings. GitLab's variables page notes masking can fail when output is changed, for example when shell escaping adds backslashes, and says it is not a guaranteed way to stop a malicious user. A trace prints transformed and partial values, which is exactly where masking is weakest.

Safer ways to debug a failing job

  1. Re-run with a small extra step that prints non-secret facts, such as tool versions and file lists.
  2. Keep secrets in protected, hidden or file type variables where you can, and avoid commands that dump the environment.
  3. If you must trace, set the variable on a single manual run, from a private project, with logs not public.
  4. Delete the job log afterwards. Deletion is permanent and needs the job owner or a Maintainer.
  5. Rotate any secret the job could read if the log was ever visible to someone who should not see it.
  6. Add a review rule so changes to .gitlab-ci.yml that add CI_DEBUG_TRACE need approval. See CODEOWNERS for pipeline files.

Our checklist on secrets in CI test logs and artifacts covers the wider problem, and who can read job logs covers visibility settings.

Safeguard's policies and gates can add automated checks to changes before they merge, and you can try a free scan at https://gold.safeguard.sh/scan.

Quick check

Is a private project log safe to trace?

Safer, not safe. Anyone with Developer access can read it, so rotate secrets that matter.

Can I block someone adding the variable in a merge request?

Review rules on the pipeline file help, but a variable set in project settings needs Maintainer access, so keep that role small.

Sources

Last reviewed: 19 October 2026.

Never miss an update

Weekly insights on software supply chain security, delivered to your inbox.

Self-healing security runs on Safeguard.

Your first fix PR is minutes away.

No sales call required, even your agent can complete the purchase over MCP.