Skip to content

[sec-check] fix: strip github_token from /tmp/contributor-task.json and write it 0600 - #5066

Merged
clubanderson merged 1 commit into
v4from
sec/fix-relay-taskfile-token-leak
Aug 29, 2026
Merged

[sec-check] fix: strip github_token from /tmp/contributor-task.json and write it 0600#5066
clubanderson merged 1 commit into
v4from
sec/fix-relay-taskfile-token-leak

Conversation

@kubestellar-hive

Copy link
Copy Markdown
Contributor

Security Fix

Files/functions claimed: bin/contributor-relay.sh (task_assign handler, TASK_FILE write) and bin/contributor-relay.test.js only. 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_assign handler serialized the entire hub message — still carrying msg.github_token — to TASK_FILE (/tmp/contributor-task.json by default) with default 0644 permissions, three lines after injectGhToken carefully wrote the same credential 0600 to GH_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

  • Strip github_token from the object before serializing to TASK_FILE (non-secret fields like token_expires_at survive).
  • Write TASK_FILE with mode: 0o600, plus a chmodSync to cover overwriting a pre-existing 0644 file.
  • Regression test: persisted task file carries neither the key nor the token value, and is owner-only.

Validation: node --check clean; 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

…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>
@kubestellar-prow kubestellar-prow Bot added the dco-signoff: yes Indicates the PR's author has signed the DCO. label Aug 29, 2026
@kubestellar-prow

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign hanthor for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@github-actions

Copy link
Copy Markdown
Contributor

Changelog: this PR changes code but does not touch CHANGELOG.md.

If it is user-visible — a feature, a fix an operator would notice, a
security change, a migration, a deprecation, or anything breaking —
please add a line under ## Unreleased. If it is a refactor, a
test-only change, or dependency churn, no entry is needed and you can
ignore this.

This is a reminder, not a gate; it never blocks a merge.

@kubestellar-prow kubestellar-prow Bot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Aug 29, 2026
@clubanderson
clubanderson merged commit 5632f13 into v4 Aug 29, 2026
33 of 34 checks passed
@clubanderson
clubanderson deleted the sec/fix-relay-taskfile-token-leak branch August 29, 2026 02:04
@github-actions

Copy link
Copy Markdown
Contributor

Thank you for your contribution! Your PR has been merged.

Check out what's new:

Stay connected: Slack #kubestellar-dev | Multi-Cluster Survey

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

copilot dco-signoff: yes Indicates the PR's author has signed the DCO. hold size/M Denotes a PR that changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[sec-check] contributor relay writes the hub-delivered GitHub token to world-readable /tmp/contributor-task.json

1 participant