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.
There is a risk if you answer yes to all of these questions.
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"
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"