Skip to content

fix(gateway): separate GitHub preview credentials - #125158

Merged
steipete merged 5 commits into
mainfrom
steipete/github-service-credential-isolation
Aug 17, 2026
Merged

steipete merged 5 commits into
mainfrom
steipete/github-service-credential-isolation

Conversation

@steipete

@steipete steipete commented Aug 17, 2026 •

Copy link
Copy Markdown
Contributor

Related: #125157

What Problem This Solves

Fixes an issue where operators configuring GitHub access for Control UI previews, project discovery, and managed project cloning had to rely on the Gateway process-wide GH_TOKEN / GITHUB_TOKEN environment. An explicit unavailable credential was also treated like a missing credential, causing anonymous fallback and misleading setup guidance.

Why This Change Was Made

This adds a dedicated SecretRef-capable gateway.controlUi.github.token service credential. A configured-but-unavailable reference now fails closed at the shared GitHub service boundary, while omitting the field preserves the existing environment and anonymous fallbacks for compatibility. GitHub-specific errors and doctor guidance now identify the dedicated setting instead of conflating it with an agent identity.

This is the first change in the GitHub identity series tracked by #125157. It intentionally does not add per-agent identities or cloud publication.

User Impact

Operators can keep Gateway-owned GitHub reads under an explicit secret owner and receive truthful degraded-state errors when that secret cannot resolve. Existing deployments using GH_TOKEN or GITHUB_TOKEN continue to work unchanged while they migrate.

Evidence

  • 185 focused tests across config SecretRef resolution, GitHub preview/project consumers, cloning errors, and doctor guidance
  • Core, UI, and config type checks
  • Config baseline, docs list, formatting, and git diff --check
  • Full-branch Codex autoreview at P1: clean after scope correction
  • Live external proof against the PR head: the explicit configured credential selected successfully, and bounded GitHub /user plus public openclaw/openclaw repository requests both returned valid responses
  • No secret values were logged or added to config snapshots

Visual proof

Before — the project picker described only the ambient GH_TOKEN mechanism:

Before: project picker asks for GH_TOKEN

After — the picker distinguishes the dedicated Control UI credential from the legacy shared environment fallback:

After: project picker distinguishes the Control UI credential

AI-assisted implementation; behavior and owner boundaries were independently reviewed against the current Gateway and SecretRef contracts.

@clawsweeper

clawsweeper Bot commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation app: web-ui App: web-ui gateway Gateway runtime size: M maintainer Maintainer-authored PR labels Aug 17, 2026
@steipete
steipete marked this pull request as ready for review August 17, 2026 08:00
@steipete
steipete requested a review from a team as a code owner August 17, 2026 08:00
@steipete steipete self-assigned this Aug 17, 2026
@steipete

steipete commented Aug 17, 2026 •

Copy link
Copy Markdown
Contributor Author

Land-ready proof for exact head 2fbbf47145d9b94af67644061f4b18eaf393edc6:

  • Exact-head CI: green, run https://github.com/openclaw/openclaw/actions/runs/32014165578
  • Native landing review findings resolved:
    • GitHub preview cache entries are credential-scoped and credential availability is revalidated before cache lookup
    • New Session GitHub guidance uses the localized catalog again, with the canonical raw-copy baseline refreshed
  • Focused source proof across SecretRef resolution, preview/project consumers, cloning errors, doctor guidance, cache revalidation, and New Session GitHub project behavior
  • Control UI i18n verify, focused Chromium E2E, formatting, config baseline, docs list, type checks, and diff checks passed
  • Visual before/after evidence is embedded in the PR body
  • Live external contract proof against the PR-head client: explicit credential selection succeeded, and bounded GitHub /user plus public openclaw/openclaw repository requests returned valid responses
  • Final full-branch P1 autoreview: clean

Known proof gap: the dedicated SecretRef setting was not deployed to the production Team Gateway in this PR. The live proof exercised the exact PR-head GitHub client and credential-selection path in an isolated tree; deployment verification belongs to the post-merge rollout.

@clawsweeper clawsweeper Bot added merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Aug 17, 2026
@clawsweeper

clawsweeper Bot commented Aug 17, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: found issues before merge. Reviewed August 17, 2026, 5:21 AM ET / 09:21 UTC.

ClawSweeper review

What this changes

Adds an optional SecretRef-backed Gateway credential for Control UI GitHub previews, project search, and managed repository cloning, while retaining ambient-token fallback when omitted.

Merge readiness

⚠️ Needs maintainer review before merge - 5 items remain

Keep open: the prior cached-preview availability finding is fixed, but the new global credential selector also changes Control UI session pull-request chips, outside the documented preview/project scope. That security and ownership boundary needs an explicit maintainer decision before merge.

Priority: P2
Reviewed head: 2fbbf47145d9b94af67644061f4b18eaf393edc6
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The proof and cache repair are strong, but the unresolved credential-consumer boundary is merge-blocking.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): The PR body and follow-up provide redacted after-fix external GitHub client output plus before/after Control UI evidence; the remaining blocker is credential scope, not proof absence.
Patch quality 🦐 gold shrimp (3/6) Security review found an item that needs attention.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): The PR body and follow-up provide redacted after-fix external GitHub client output plus before/after Control UI evidence; the remaining blocker is credential scope, not proof absence.
Evidence reviewed 5 items Changed credential owner: The PR head prefers gateway.controlUi.github.token and fails closed for an unavailable configured owner before considering ambient environment tokens.
Unchanged sibling consumer: Session pull-request chips call the same resolver, so they adopt the new credential and unavailable-owner behavior even though this PR does not explicitly describe that surface.
Published configuration scope: The configuration reference limits the setting to Control UI previews and project discovery, omitting session pull-request chips.
Findings 1 actionable finding [P2] Constrain the credential to its documented consumers
Security Needs attention Undeclared session-chip credential consumer: The dedicated GitHub credential is selected by the session pull-request cache, so its authorization and fail-closed behavior extend beyond the documented preview and project surfaces.

How this fits together

The Gateway supplies GitHub-backed previews, project discovery, cloning, and session pull-request chips to Control UI. A credential resolver chooses the token used by those GitHub requests and determines what happens when a configured SecretRef is unavailable.

flowchart LR
  A[Control UI operator] --> B[Gateway GitHub features]
  B --> C[Credential selection]
  C --> D[Preview and project operations]
  C --> E[Session pull request chips]
  C --> F[Unavailable credential state]
  D --> G[Control UI results]
  E --> G
  F --> G
Loading

Decision needed

Question Recommendation
Should gateway.controlUi.github.token also govern Control UI session pull-request chips, or remain limited to the documented preview, discovery, and cloning paths? Limit the credential to documented paths: Pass the dedicated credential only to previews, project search, and cloning, preserving the existing ambient-token behavior for session pull-request chips.

Why: Credential scope determines both which GitHub identity is used and which UI behavior fails closed, so source review cannot infer the intended operator-security boundary.

Before merge

  • Constrain the credential to its documented consumers (P2) - This selector is also called by the unchanged session pull-request loader at src/gateway/control-ui-session-prs.ts:643, so setting this credential changes that chip's identity and unavailable behavior despite docs limiting it to previews and project discovery. Either pass the dedicated credential only to the documented consumers, or explicitly document and test the broader Control UI scope. This was visible at the prior reviewed head; it is raised late after sibling-surface review.
  • Resolve security concern: Undeclared session-chip credential consumer - The dedicated GitHub credential is selected by the session pull-request cache, so its authorization and fail-closed behavior extend beyond the documented preview and project surfaces.
  • Resolve merge risk (P1) - A token configured for the documented preview/project features will also govern session pull-request chips; an unavailable owner turns those chips into an unavailable snapshot, without that scope being documented or tested.
  • Complete next step (P2) - A maintainer must choose the intended credential ownership boundary for session pull-request chips before any mechanical repair can be selected.

Findings

  • [P2] Constrain the credential to its documented consumers — src/gateway/control-ui-github-api.ts:57-73
  • [medium] Undeclared session-chip credential consumer — src/gateway/control-ui-github-api.ts:57
Agent review details

Security

Needs attention: The shared credential selector expands the new SecretRef's effective scope to session pull-request chips without an explicit ownership decision.

PR surface

Source +95, Tests +228, Docs +2, Generated 0. Total +325 across 25 files.

View PR surface stats
Area Files Added Removed Net
Source 13 118 23 +95
Tests 8 231 3 +228
Docs 2 5 3 +2
Config 0 0 0 0
Generated 2 5 5 0
Other 0 0 0 0
Total 25 359 34 +325

Review metrics

Metric Value Why it matters
Credential configuration surface 1 optional SecretRef setting added The new setting changes which credential owns Gateway GitHub access and therefore needs an explicit consumer scope.
Production versus test delta production +118/-23, tests +231/-3; docs/generated +10/-8 The production growth is tied to a new credential owner and degraded-state boundary; the outstanding concern is its undocumented sibling consumer.

Stored data model

Persistent data-model change detected: persistent cache schema: src/gateway/control-ui-github-preview.ts. Confirm migration or upgrade compatibility proof before merge.

Root-cause cluster

Relationship: partial_overlap
Canonical: #125157
Summary: This PR is explicitly the first Gateway-owned credential step in the broader GitHub identity proposal; it does not implement the proposed per-agent identities or publication flow.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Merge-risk options

Maintainer options:

  1. Narrow the credential boundary (recommended)
    Restrict the configured credential to the documented preview, discovery, and cloning paths before merge.
  2. Approve the broader Control UI scope
    Deliberately include session pull-request chips, then document that behavior and add focused configured and unavailable-owner coverage.

Technical review

Best possible solution:

Confine the new credential to previews, search, and cloning until broader Control UI GitHub ownership is explicitly approved; otherwise document and test session pull-request chips as a deliberate consumer.

Do we have a high-confidence way to reproduce the issue?

Yes, source-reproducible: configure the new credential, then load session pull-request chips; their existing shared resolver selects it even though the documented scope omits that feature.

Is this the best way to solve the issue?

No: the cache repair is sound, but the global selector makes an unreviewed credential-scope decision for session pull-request chips; either narrow it or explicitly support that consumer.

Full review comments:

  • [P2] Constrain the credential to its documented consumers — src/gateway/control-ui-github-api.ts:57-73
    This selector is also called by the unchanged session pull-request loader at src/gateway/control-ui-session-prs.ts:643, so setting this credential changes that chip's identity and unavailable behavior despite docs limiting it to previews and project discovery. Either pass the dedicated credential only to the documented consumers, or explicitly document and test the broader Control UI scope. This was visible at the prior reviewed head; it is raised late after sibling-surface review.
    Confidence: 0.93
    Late finding: first raised on code an earlier review cycle already covered.

Overall correctness: patch is incorrect
Overall confidence: 0.9

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 7ce934a8b5d0.

Labels

Label justifications:

  • P2: The PR introduces a bounded but user-visible credential-scope change for Control UI GitHub behavior.
  • merge-risk: 🚨 security-boundary: The new SecretRef selection alters which GitHub identity and fail-closed state apply to a shared Control UI GitHub client.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦞 diamond lobster and patch quality is 🦐 gold shrimp.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Sufficient (live_output): The PR body and follow-up provide redacted after-fix external GitHub client output plus before/after Control UI evidence; the remaining blocker is credential scope, not proof absence.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body and follow-up provide redacted after-fix external GitHub client output plus before/after Control UI evidence; the remaining blocker is credential scope, not proof absence.

Evidence

Security concerns:

  • [medium] Undeclared session-chip credential consumer — src/gateway/control-ui-github-api.ts:57
    The dedicated GitHub credential is selected by the session pull-request cache, so its authorization and fail-closed behavior extend beyond the documented preview and project surfaces.
    Confidence: 0.93

What I checked:

Likely related people:

  • steipete: Current-main blame and history attribute the shared credential-cache helper to Peter Steinberger; the proposed branch continues work in that same owner boundary. (role: recent contributor to the shared Control UI GitHub credential and cache path; confidence: high; commits: 3010318ba3fe; files: src/gateway/control-ui-github-api.ts, src/gateway/control-ui-github-preview.ts, src/gateway/control-ui-session-prs.ts)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Choose the credential scope for session pull-request chips.
  • Make the chosen scope explicit in docs and focused regression coverage.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (1 earlier review cycle)
  • reviewed 2026-08-17T08:54:47.186Z sha 4b5ad57 :: found issues before merge. :: [P2] Revalidate credential availability before returning cached previews

@steipete

Copy link
Copy Markdown
Contributor Author

Maintainer scope decision for the latest ClawSweeper review: gateway.controlUi.github.token intentionally owns all Gateway-side Control UI GitHub reads, including session pull-request chips.

That consumer is explicit in the final docs/web/control-ui.md session-chip section. Coverage is layered at the ownership boundaries: the shared credential tests prove configured selection and cold-owner failure, the session loader tests prove token forwarding and credential-scoped caching, and the subscription tests prove loader failures publish an unavailable snapshot. A duplicate SecretRef setup in the session suite would not add a new behavior contract.

The late credential-scope finding and its two rank-up moves are therefore addressed at exact head 2fbbf47145d9b94af67644061f4b18eaf393edc6; no additional head change is needed.

@steipete
steipete merged commit 1487b45 into main Aug 17, 2026
223 checks passed
@steipete
steipete deleted the steipete/github-service-credential-isolation branch August 17, 2026 09:31
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 18, 2026
* fix(gateway): isolate GitHub service credentials

* fix(gateway): harden GitHub credential isolation

* refactor(gateway): scope GitHub preview credentials

* fix(ui): refresh GitHub credential copy baseline

* fix(gateway): revalidate cached GitHub previews
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

app: web-ui App: web-ui docs Improvements or additions to documentation gateway Gateway runtime maintainer Maintainer-authored PR merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: M status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant