GitHub Actions automatically redacts secrets from logs to prevent accidental exposure. However, when structured data stored as secrets is parsed using functions like fromJSON(), the parsed values are no longer recognized as secrets by the automatic redaction mechanism. This can lead to sensitive information being exposed in workflow logs.

Ask Yourself Whether

There is a risk if you answer yes to all of these questions.

Recommended Secure Coding Practices

Sensitive Code Example

name: Example

on:
  pull_request:

jobs:
  main:
    runs-on: ubuntu-latest

    steps:
      - name: Example Step
        env:
          SECRET: ${{ fromJSON(secrets.JSON_SECRET).SECRET_IN_JSON }} # Sensitive
        run: |
          example-command "$SECRET"

Compliant Solution

The example below is compliant because the secret is not parsed from structured data.

name: Example

on:
  pull_request:

jobs:
  main:
    runs-on: ubuntu-latest

    steps:
      - name: Example Step
        env:
          SECRET: ${{ secrets.SECRET }}
        run: |
          example-command "$SECRET"

See

See Also