[sec-check] fix: strip github_token from /tmp/contributor-task.json and write it 0600 - #5066
Conversation
…rld-readable /tmp/contributor-task.json task_assign serialized the entire hub message — including msg.github_token — to TASK_FILE with default 0644 perms, so any local user on a contributor host could read the live task-scoped installation token. The token's only legitimate on-disk home is the 0600 GH_TOKEN_CACHE written by injectGhToken. Strip github_token before serializing, write the task file 0600 (with a chmod to cover overwriting a pre-existing 0644 file), and add a regression test asserting the persisted file carries neither the key nor the value. Fixes #5065 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: sec-check <sec-check@hive.kubestellar.io>
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
Changelog: this PR changes code but does not touch If it is user-visible — a feature, a fix an operator would notice, a This is a reminder, not a gate; it never blocks a merge. |
|
Thank you for your contribution! Your PR has been merged. Check out what's new:
Stay connected: Slack #kubestellar-dev | Multi-Cluster Survey |
Security Fix
Files/functions claimed:
bin/contributor-relay.sh(task_assignhandler, TASK_FILE write) andbin/contributor-relay.test.jsonly. Disjoint from open hold-gated PRs #5044 (src/pkg/mint + src/pkg/advisory tests), #5036 (provenance test), #4032 (Go MITM proxy: src/pkg/proxy, src/pkg/github, src/pkg/config).The
task_assignhandler serialized the entire hub message — still carryingmsg.github_token— toTASK_FILE(/tmp/contributor-task.jsonby default) with default 0644 permissions, three lines afterinjectGhTokencarefully wrote the same credential 0600 toGH_TOKEN_CACHE. Any local user on a contributor host could read the live task-scoped installation token for its full lifetime. No code reads the token back from TASK_FILE — it is observability/debug state.Changes
github_tokenfrom the object before serializing to TASK_FILE (non-secret fields liketoken_expires_atsurvive).mode: 0o600, plus achmodSyncto cover overwriting a pre-existing 0644 file.Validation:
node --checkclean;node bin/contributor-relay.test.js→ 164/164 passed.Fixes #5065
Filed by sec-check agent (ACMM L4/L5 — hold-gated mode). Hold-gated: human review required.
— hive: agent=sec-check backend=copilot model=claude-fable-5