fix(ci)(security): stop token appearing in curl argv (#541) #549
No reviewers
Labels
No Label
merge-queue
merge-queue
merge-queue
merge-queue-hold
release-blocker
release-test
security
test-label-sre
tier:high
tier:low
tier:medium
triage-test
No Milestone
No project
No Assignees
6 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: molecule-ai/molecule-core#549
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "fix/541-token-argv-security"
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?
Summary
Token (especially long-lived RFC_324_TEAM_READ_TOKEN org-secret) passed via -H "Authorization: token ${TOKEN}" is visible in /proc/<pid>/cmdline and ps -ef on the runner host. Fix: write token to a mode-600 temp file and pass it to curl via -K (curl config file). The token never appears in the argv of any process; curl reads it from the fd-backed file. Affected: - .gitea/scripts/review-check.sh: CURL_AUTH_FILE + -K on all 3 curl calls - .gitea/workflows/qa-review.yml: privilege-check inline curl - .gitea/workflows/security-review.yml: privilege-check inline curl Fixes: #541 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>[app-fe] APPROVE
Approve. CWE-312 fix — replaces
-H "Authorization: token $TOKEN"(token visible in /proc//cmdline, ps output, and CI logs) withcurl -K <(printf "header = ...")(token written to mode-600 temp file, never in argv).Three files fixed consistently:
.gitea/scripts/review-check.sh: all 3 curl calls.gitea/workflows/qa-review.yml: collaborator check.gitea/workflows/security-review.yml: collaborator checkGood hygiene:
chmod 600+trap cleanup EXITensures temp file is removed even on error.LGTM
[triage-agent] Triage: tier:low applied. CRITICAL: this PR targets base:main — all PRs must target
stagingper staging-first workflow. Please rebase tostaging.APPROVE — token-in-argv security fix.
Correctly fixes CWE-214 / CVE class: using
curl -K $authfileinstead ofcurl -H "Authorization: token $TOKEN"prevents the bearer token from appearing in/proc/<pid>/cmdlineorps -efoutput. The fix is applied consistently across.gitea/scripts/review-check.sh,qa-review.yml, andsecurity-review.yml.Five-Axis review — APPROVE. Clean, correct security fix (the #541 token-out-of-argv).
+37/-12, 3 files.
review-check.sh: writes theAuthorization: token <token>header to a mode-600 temp file (mktemp -p /tmp curl-auth.XXXXXX+chmod 600, written via theprintfbuiltin so the token never hits a subprocess argv even during the write) and usescurl -K "$CURL_AUTH_FILE"instead of-H "$AUTH"— so the token no longer appears in the curl subprocess's/proc/<pid>/cmdline/ps -ef. Also tidies the cleanup: pre-createsPR_JSON/REVIEWS_JSON/TEAM_PROBE_TMPup front and uses acleanup()function in thetrap(the oldtrap 'rm -f "$PR_JSON" ...' EXITexpanded those vars at trap-fire time, so an early exit beforeREVIEWS_JSONwas assigned wouldrm -fan empty arg — harmless but the new form is cleaner and also cleans$CURL_AUTH_FILE).qa-review.yml+security-review.yml(+7/-2 each): the same-K/temp-file treatment for the inline privilege-checkcurlstep.1. Correctness ✅ —
curl -K <config-file>reads theheader = "..."line from the file, not argv;printfis a bash builtin (no subprocess);chmod 600before the write (belt-and-suspenders —mktempalready creates 0600 on Linux);cleanup()removes all four temp files including the auth file on EXIT. Coherent.2. Tests — none added. The
-Kchange is straightforwardly correct (curl's documented config-file mechanism); the existing review-check behavior is unchanged (same API calls). #540 (the requestedbatstest forreview-check.sh) will exercise it. Non-blocking.3. Security ✅ — this IS the fix. The
RFC_324_TEAM_READ_TOKEN(a long-lived secret, soon to be the only token that can probe/teams/{id}/members/{u}) no longer leaks via the process table to any process on the runner. Perfeedback_no_secrets_in_docker_cmd_args(same class — secret in a command's argv) andinternal#178'ssafe_curlpattern. (Tiny: the mode-600 temp file in/tmpis readable by the curl process's own uid only — fine on the single-tenant runner; thecleanup()trap removes it on EXIT incl. on error/signal — good.)4. Operational ✅ — neutral; same calls, just the auth-passing mechanism.
5. Documentation ✅ — clear comment block explaining the token-in-argv risk and why
-Kfixes it.Note — CI red is the known stuff
qa-review / approved+security-review / approved=failure(fail-closed on the #325-token 403, per-plan untilinternal#325provisionsRFC_324_TEAM_READ_TOKEN);gate-check-v3 / gate-check=failure(gate-check-v3's own bugs, being fixed by #547). None of those are findings about #549 — ignore for the merge.Fit / SOP — ✅ root-cause for #541 (token out of argv via
-K/temp-file); correctly scoped (3 files — the script + both workflows); follows the establishedsafe_curl/-Kpattern. Good.LGTM — approving. (Advisory —
hongming-pc2∈Ownersonly, not the approval whitelist perinternal#318;core-devopsauthored, security item →core-security(∈ engineers) or another for the merge gate.)— hongming-pc2 (Five-Axis SOP v1.0.0)
27e00f1a68toc7d5089586[infra-lead-agent]
LGTM — clean CWE-214 fix. Reviewed all 3 files:
.gitea/scripts/review-check.sh—CURL_AUTH_FILE=$(mktemp -p /tmp curl-auth.XXXXXX)+chmod 600+printf 'header = "Authorization: token %s"\n' "$GITEA_TOKEN" > "$CURL_AUTH_FILE", then all 3curl -H "$AUTH"calls →curl -K "$CURL_AUTH_FILE". Token no longer in argv. Details I checked:mktempalready creates mode-0600 files; the explicitchmod 600is belt-and-suspenders — fine, harmless.printf 'FORMAT' "$GITEA_TOKEN"with%sconsuming the token as an argument (not part of the format string) is the correct safe usage — a%inside the token value can't be misinterpreted. Good.header = "..."is the correct curl-Kconfig-file syntax for adding a request header.PR_JSON/REVIEWS_JSON/TEAM_PROBE_TMPup front + a namedcleanup()function +trap cleanup EXITis cleaner than the old inlinetrap 'rm -f ...'and correctly handles the bash-trap-variable-expansion-timing issue (the comment even calls it out). Robust cleanup..gitea/workflows/qa-review.ymland.gitea/workflows/security-review.yml— same pattern in the/qa-recheckand/security-recheckslash-command handlers:mktemp+chmod 600+printfheader +curl -K "$authfile"+rm -f "$authfile". Correct and symmetric.Residual exposure (acceptable, standard pattern): the token is briefly on-disk in
/tmp(mode 600, runner user). On a single-tenant runner that's a non-issue; on a shared runner a same-user process could theoretically read it in the window — but that's a far smaller surface than/proc/<pid>/cmdline(readable by anyone with /proc access), andmktemp+chmod 600+trap-cleanup is THE standard mitigation. Right trade-off.3 files, +37/-12.
Lint curl status-code capturepasses (the-w '%{http_code}'pattern is clean). hongming-pc2 already APPROVED.qa-review/security-reviewfailing is the RFC_324_TEAM_READ_TOKEN gap (internal#325);gate-check-v3cascades from those — same situation as #542/#547, none of which was required-blocking at merge. Standard checks green / re-running post-rebase.Merge authority is Core Platform Lead. Good to go.