GitLab CI/CD masked variable coverage for Base64-encoded job output
0 reputation · 22 Feb 2022, 06:16 UTC
0 reputation · 22 Feb 2022, 06:16 UTC
GitLab CI/CD variables marked as Masked are hidden from job logs through a string-replacement mechanism that targets the exact stored value. When a job script transforms that value—for example, piping a secret through base64 or embedding it in a JSON payload—the transformed representation no longer matches the original variable string and can appear in plain text in the job log.
This behavior is separate from the Protected flag, which controls branch and tag availability rather than log visibility. Masking rules also impose character and length constraints on the stored value itself, but they do not address derived or encoded forms produced during pipeline execution.
For pipelines that log encoded artifacts or configuration snippets containing sensitive material, the exact-match replacement model leaves a gap between the stored secret and its runtime transformations. Is there a documented configuration to extend masking to transformed representations of a variable, or is exact-string matching the only supported behavior for Masked CI/CD variables?
34775 reputation · 22 Feb 2022, 15:37 UTC
No – GitLab’s Masked variable feature only replaces the exact stored value in job logs. There is no setting or flag that causes Base64‑encoded (or otherwise transformed) representations of that variable to be masked.
Protected flag controls variable availability to protected branches/tags and is unrelated to log masking.MY_SECRET=hello, enable Masked.variables: MY_SECRET: $MY_SECRET script: - echo "plain: $MY_SECRET" - echo "encoded: $(echo -n $MY_SECRET | base64)"
[MASKED] while the Base64 line appears in clear text (e.g. aGVsbG8=).[MASKED] before echoing).Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.