Skip to content

🐛 [v6] claude auth: share refreshed logins across per-agent .claude homes and harden shared-home permission handling - #17807

Merged
clubanderson merged 1 commit into
v6from
topup/v6-claude-shared-credentials
Nov 12, 2026
Merged

clubanderson merged 1 commit into
v6from
topup/v6-claude-shared-credentials

Conversation

@clubanderson

Copy link
Copy Markdown
Member

Top-up of #17767 (v5) onto v6, merged into the credential bridge v6 already carries from #17253 / #17590 rather than added beside it.

What changes on v6

  • Keeps v6's surface: the dashboard credential bridge broken card state, resume-after-sign-in, and the legacy-directory-link rules from 🐛 [v6] claude auth: never re-bridge a credential that resolves to the shared login file #17590.
  • Brings the v5 mechanism: when a Claude Code token refresh has replaced an agent's ~/.claude/.credentials.json link with a private 0600 file, hive reads it (directly, or as the agent's uid through the existing su-exec seam), keeps whichever credential is newer and usable in the shared login, moves the private copy aside as .credentials.json.stale-<UTC>, and restores the link. Runs at launch, every HIVE_CLAUDE_CREDENTIAL_BRIDGE_INTERVAL (default 5s) from the credential watchdog, and after a dashboard sign-in. Memory, transcripts and todos stay per agent; only the login is shared.
  • Fail-safe handling of a private file hive cannot read: it is left in place (never moved aside or relinked), logged once per agent and file version; the only exception is a dashboard sign-in, whose fresh shared login is newer than anything the private copy could hold. WriteCredentials refuses a token set with no access token.
  • Hardens the shared-home permission guard and credential promotion against non-regular files: the entrypoint guard acts only on regular files inside regular directories, the shared dot-dirs carry the sticky bit, and every hive-side write to the Claude login / Copilot config goes through the new crux/sharedfile writer (random temp name, descriptor-based metadata, verified before rename, unsafe locations refused and logged once).
  • A dashboard sign-in still recovers a shared credential path that is a dangling or self-referencing link (🐛 [v6] claude auth: never re-bridge a credential that resolves to the shared login file #17590) by unlinking it first; a link that resolves to an existing file is refused.

Supersedes #17678 and #17748.

Validation

Targeted go test for crux/agent (bridge, watchdog, snapshot, copilot token), crux/claude, crux/sharedfile, crux/agent/copilottoken, pkg/dashboard; deploy/test_entrypoint_perm_guard.sh 50/50; gofmt/go vet clean; sleep ratchet passes.

…omes and harden shared-home permission handling

Top-up of #17767 (v5 squash 0cf675d) onto v6, merged into the
credential bridge v6 already carries from #17253/#17590:

- keeps v6's dashboard surface (credentialBridgeBroken, resume after
  sign-in) and the legacy-dir-link rules;
- brings the sharedfile-based promotion, owner read through su-exec,
  newest-expiresAt rule, 5s bridge cadence
  (HIVE_CLAUDE_CREDENTIAL_BRIDGE_INTERVAL), and the fail-safe handling
  of an unreadable private file (left in place except on sign-in);
- hardens the shared-home permission guard and credential promotion
  against non-regular files (entrypoint guard, sticky shared dot-dirs,
  crux/sharedfile writer for the Claude login and Copilot config);
- a dashboard sign-in still recovers a shared credential path that is a
  dangling or self-referencing link (#17590), by unlinking it first.

Supersedes #17678 and #17748.

(cherry picked from commit 0cf675d)
Signed-off-by: Andrew Anderson <andy@clubanderson.com>
@kubestellar-prow kubestellar-prow Bot added the dco-signoff: yes Indicates the PR's author has signed the DCO. label Nov 12, 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

@kubestellar-prow kubestellar-prow Bot added the size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. label Nov 12, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Open PR overlap check

Base branch: v6

Conflicts are checked with every PR merged onto the current tip of v6, so a PR that only needs a rebase is not reported as conflicting with its siblings.

PR Title Relation Files
#17748 🐛 [v6] claude auth: keep an agent's refreshed credential the server cannot read CONFLICT src/crux/agent/claude_credential_bridge.go (conflict)
src/crux/agent/claude_credential_bridge_internal_test.go (conflict)
src/crux/claude/oauth.go (conflict)
src/docs/agent-configuration.md
#17678 🐛 [v6] claude auth: never discard an agent's refreshed credential the server cannot read CONFLICT src/crux/agent/claude_credential_bridge.go (conflict)
src/crux/agent/claude_credential_bridge_internal_test.go (conflict)
src/crux/claude/oauth.go (conflict)
src/deploy/entrypoint.sh
src/deploy/test_entrypoint_perm_guard.sh (conflict)
src/docs/agent-configuration.md (conflict)

@hivecommons-hive

Copy link
Copy Markdown
Contributor
6d489f9

ℹ️ Sentinel notice — informational; author is trusted (owner), merge is not blocked

Hive flagged this PR (author @clubanderson, head 6d489f9235e7) because it matches behaviors that can override security controls, escalate privileges or damage the codebase. This is a heuristic, not an accusation — a maintainer should confirm the change is intended before it merges.

  • sensitive_path — changes 2 sensitive path(s) (Touches a sensitive path (OWNERS, workflows, policies, hive config, security docs, …))
    • src/deploy/entrypoint.sh
    • src/deploy/test_entrypoint_perm_guard.sh

Hive did not add the sentinel-alert label because this author is trusted. The finding remains recorded for audit and the dashboard Security tab; set sentinel.trusted_authors_block: true to require the blocking label for trusted authors too.

@github-actions

Copy link
Copy Markdown
Contributor

Mutation testing

Head 6d489f923.

❌ gremlins did not produce a report for 1 package(s), so no verdict can be derived from this run (see the job log):

  • crux/agent: gremlins exited 1

gremlins found 9 surviving mutant(s) in changed files: the code ran under tests, but changing it did not fail any test.

File Line Mutation
src/crux/sharedfile/sharedfile.go 127 CONDITIONALS_NEGATION
src/crux/sharedfile/sharedfile.go 148 CONDITIONALS_BOUNDARY
src/crux/sharedfile/sharedfile.go 176 ARITHMETIC_BASE
src/crux/sharedfile/sharedfile.go 176 INVERT_NEGATIVES
src/crux/sharedfile/sharedfile.go 198 CONDITIONALS_BOUNDARY
src/crux/sharedfile/sharedfile.go 208 CONDITIONALS_NEGATION
src/crux/sharedfile/sharedfile.go 267 CONDITIONALS_BOUNDARY
src/crux/sharedfile/sharedfile.go 270 ARITHMETIC_BASE
src/crux/sharedfile/sharedfile.go 274 CONDITIONALS_BOUNDARY

ℹ️ 1 mutant(s) on added lines were SKIPPED because gremlins v0.6.0 only honours the first lines added lines of each default-context hunk, so non-contiguous edits in one hunk are partly missed. This does not affect the verdict.

File Line Mutation
src/crux/claude/oauth.go 403 CONDITIONALS_NEGATION

Verdict: error (#17349).

@clubanderson
clubanderson merged commit 8aeb185 into v6 Nov 12, 2026
91 of 96 checks passed
@kubestellar-prow
kubestellar-prow Bot deleted the topup/v6-claude-shared-credentials branch November 12, 2026 00:26
@github-actions

Copy link
Copy Markdown
Contributor

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

We'd love to hear how your experience was: share feedback

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

Labels

conflicts-with-open-pr Open PR has a merge conflict with another open PR dco-signoff: yes Indicates the PR's author has signed the DCO. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant