ci: drop whole-value ::add-mask:: on multi-line secrets (PEM lines 2..n were logged unmasked) #107
No reviewers
Labels
No labels
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
key-store/key.store!107
Loading…
Reference in a new issue
No description provided.
Delete branch "ci/add-mask-per-line-only"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
decrypt_envin.forgejo/actions/decrypt-secrets/action.ymldidFor a multi-line value (
APPSTORE_KEYis a PKCS#8 PEM) the runner parses the firstechoas one::add-mask::command for line 1, and lines 2..n go to stdout as ordinary log lines — before the per-line masks in the loop are registered, so they are logged unmasked. A whole-value mask can never match a log line once the value contains a newline, so it buys nothing.Demo with a 3-line fake PEM (what the runner sees on stdout, in order):
Fix
Remove the whole-value
echo "::add-mask::${value}"and keep only the per-line loop — exactly whatmask_valuein.forgejo/actions/openbao-secrets/action.ymlalready does. No other behaviour changed ($GITHUB_ENVheredoc export is identical).Fixed:
.forgejo/actions/decrypt-secrets/action.yml—decrypt_env.forgejo/workflows/cloud-tofu.yml—export_env_secret(same pattern)Audit of the other
add-mask::${value}hitsgrep -rn 'add-mask::\${value}\|add-mask::\$value' .forgejo Scriptsalso matchesdeploy-api.yml×4 (emit_optional_secret,emit_optional_secret_b64, in both the age and openbao jobs). Those values are provably single-line (tr -d '\r\n',base64 -w0/base64 | tr -d '\n'), so the whole-value mask is correct there and they are left untouched. Same for the other variable masks I checked (cloud-tofu.ymljwt/grafana/garage,openbao-secretsjwt/bao_token,Scripts/namespace-runner-source-bootstrap.sh,Scripts/update-planetscale-secret.sh): alltr -d '\r\n'/sed … | head -n1/ opaque single-line tokens.Verification
run:scripts withyqand ranbash -n— clean.shellcheck -s bashfindings are byte-identical before/after for the decrypt-secrets step (only pre-existing${{ }}/ SC2129 / SC1090 noise); the cloud-tofu step has zero findings before and after.🤖 Generated with Claude Code
`echo "::add-mask::${value}"` on a multi-line value (APPSTORE_KEY is a PKCS#8 PEM) is parsed by the runner as one `::add-mask::` command for line 1 followed by lines 2..n as ordinary stdout, and those land in the job log verbatim because the per-line masks in the loop that follows have not been registered yet. A whole-value mask can never match a log line once the value contains a newline, so it buys nothing; keep only the per-line loop, exactly as .forgejo/actions/openbao-secrets/action.yml (mask_value) already does. Fixed: - .forgejo/actions/decrypt-secrets/action.yml decrypt_env - .forgejo/workflows/cloud-tofu.yml export_env_secret Audited and left alone (whole-value mask on a provably single-line value — `tr -d '\r\n'`, `base64 -w0`/`tr -d '\n'`, `sed | head -n1`, opaque tokens): deploy-api.yml emit_optional_secret / emit_optional_secret_b64 (both jobs), cloud-tofu.yml jwt/grafana/garage, openbao-secrets jwt/bao_token, Scripts/namespace-runner-source-bootstrap.sh, Scripts/update-planetscale-secret.sh. Verified: `bash -n` on both extracted `run:` scripts is clean; shellcheck findings are byte-identical before/after (cloud-tofu step: none). A 3-line fake PEM through the old function puts 2 raw lines on stdout; the new one 0. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>