glsec

Rules / GL062

GL062 printenv or bare env dumps all variables to the job log

Severity: warn
OWASP: CICD-SEC-6 – Insufficient Credential Hygiene
CWE: CWE-532 – Insertion of Sensitive Information into Log File

Risk

Running printenv or bare env in a CI script dumps every environment variable to the job log — including all CI/CD secrets, tokens, and masked variables. GitLab masks known secret variable values in logs, but masking is not guaranteed for all formats (short values, values with special characters, values that appear mid-line). Any third party with read access to the job log can potentially extract credentials.

GL021 already flags echo/printf of individual secret variables. This rule covers the broader pattern of dumping the entire environment.

Trigger example

debug:
  script:
    - printenv   # dumps all variables to the log
    - env

/usr/bin/env, and forms with shell separators (printenv && ..., cd /tmp; env), are also detected.

What is not flagged

Safe alternative

Print only the specific variables needed for debugging:

debug:
  script:
    - echo "CI_COMMIT_REF=$CI_COMMIT_REF_NAME"
    - echo "DEPLOY_ENV=$DEPLOY_ENV"

Notes

Documentation for glsec 1.23.0. Source of this page · Rule implementation