DEV Community

Bedirhan Elibol
Bedirhan Elibol

Posted on

How to catch secrets printed in CI logs before they leak

A CI step that echoes a token is one line of YAML. It passes review because the build is green and nobody reads the console output.

This is the pattern:

- name: Debug deploy
  run: echo "${{ secrets.DEPLOY_KEY }}"
Enter fullscreen mode Exit fullscreen mode

What to check in every workflow file:

  1. Any echo or printenv line that references secrets.
  2. Debug steps that print the whole environment.
  3. Logging of request headers or config objects that hold a token.
  4. Passing a token on stdin where the tool supports it, like --password-stdin, so it never appears in the command line.

Zelsis flags the first pattern as CICD-SEC-05 (Exposed Secret Tokens in Build Log Outputs) on the exact line of the workflow file, during the pull request, before merge.

A static check cannot know what a command prints at runtime. Treat it as the first filter. If a token has ever appeared in a log, rotate it, even if the log was private.

How do you find these in CI today?

Top comments (0)