Skip to content

fix(macos): resolve typed gateway auth refs - #128175

Merged
RomneyDa merged 21 commits into
openclaw:mainfrom
TheAngryPit:fix/macos-typed-gateway-auth-secretrefs
Nov 5, 2026
Merged

RomneyDa merged 21 commits into
openclaw:mainfrom
TheAngryPit:fix/macos-typed-gateway-auth-secretrefs

Conversation

@TheAngryPit

@TheAngryPit TheAngryPit commented Aug 23, 2026 •

Copy link
Copy Markdown
Contributor

Repair and validation update — November 4, 2026

Current head: 8149b98130829cb7d83ec153c9bc9355bcc7cc64. Validation completed November 5 UTC (November 4 Pacific).

The follow-up fixes Core secret preparation: a remote-client token no longer deactivates the local password SecretRef. Local-token suppression and remote fallback rules remain intact. Original contributor history is preserved.

Successful exact-candidate validation run (proof harness 41fd6f3290417aa078a1de9cbfc4114d247c389f):

  • Original-Core regression remains red; repaired Core tests, focused native tests, actual app build, scoped lint and both typechecks passed.
  • All eight app phases passed: four fresh candidate credential scenarios, both v2026.10.9 baselines, and both dollar/braced-shorthand candidate upgrades. Independent inspection of retained Gateway logs confirms expected authentication and successful protected config.get on the same native UI connection in every phase.
  • Authored auth, environment, named preferences and user document preservation assertions passed in all eight phases. Both manual upgrades completed Doctor-owned credential migration and retained auth/workspace through service replacement. All six scenario cleanups passed.
  • This proves attach-only app launches against a ready service. The harness applies the existing readiness gate before each app launch, including after upgrade; authentication/preservation assertions and timeouts were not weakened.
  • Unresolved startup-recovery limitation: in prior run 41933671638, the braced-shorthand candidate exhausted initial control operations while the replacement Gateway was starting, then authenticated without issuing protected config.get. The ready-service replay does not demonstrate a fix for that behavior.
  • PR CI test checks and the CI workflow's openclaw/ci-gate check run passed. The separate current openclaw/ci-gate status is failure, with openclaw/security-sensitive-review pending: “A maintainer must approve the current PR revision.” Thus the aggregate gate is not green. Fresh independent source review and local ClawSweeper review of 3481ca33..8149b981 previously found no actionable correctness/security findings; those reviews do not satisfy the outstanding maintainer approval.

Requested native/upgrade proof complete; maintainer security approval remains outstanding. No merge performed. Historical evidence below retains its original revision and limitations; historical pending proof statements are superseded only by the exact-candidate evidence above.


Closes #128171

What Problem This Solves

The macOS app could not authenticate to a local Gateway when gateway.auth.token or gateway.auth.password used a typed env SecretRef. The Gateway supports those inputs, but the native endpoint store previously handled only strings.

What Changed

  • Resolve supported typed env SecretRefs from the actual Gateway LaunchAgent environment, with the app environment as fallback.
  • Enforce the configured env provider and allowlist; malformed, unsupported, denied, or unresolved refs fail closed.
  • Keep configured refs authoritative over same-surface ambient fallbacks.
  • Match Core's implicit-mode behavior: two configured token/password inputs remain ambiguous; a concrete opposite-side fallback suppresses typed-ref materialization; after materialization, password is inferred before token.
  • Match Core startup when a typed local password coexists with gateway.remote.token: the local password wins unless an ambient Gateway token causes Core to leave that password ref inactive; when token auth is active, preserve LaunchAgent-token precedence before the remote-token fallback.
  • Pass only the selected credential into the native Gateway handshake.

User Impact

Users can keep local Gateway credentials in supported typed environment SecretRefs without breaking the macOS app connection. Invalid or disallowed references remain fail-closed, and the native app follows the same token/password selection behavior as Core.

Evidence

Current evidence refresh, 2026-10-28

Current public head is 3481ca33a1bf69a445814f0c620e12719c78f947 (tree f9061f44fb6a5815d8ab0e0f3a5391a9cac3a758). Its merge preserves c17b72d3538f81e934caaa4d5c373cf90e90c513 and integrates main 9a5581b4ce230381e3f200a62be4cdbe78e41c19. GitHub blob identities confirm that both PR-owned Swift files are unchanged from c17b72d353. Contributor credit and the prior source and native evidence below remain attached to their stated revisions.

Canonical CI run 40678248294 and its CI gate succeeded for head 3481ca33a1bf69a445814f0c620e12719c78f947. This run contains 5 successful and 38 skipped jobs. Both macOS Swift phases and the iOS build phase were skipped. macOS and shared Periphery run 40678248230 completed seven selected jobs successfully, including both shared-kit producers and the intersection; the iOS dead-code scan was skipped. Skipped native tests and successful static scans do not establish packaged-app authentication.

No new native run or fresh ClawSweeper verdict is claimed. The durable review below remains bound to ff41c754, and the shorthand correction at c17b72d353 remains a source disposition. Exact-current-head focused tests, packaged-app coverage of the later remote-fallback combinations, and a stable-release upgrade retaining existing shorthand settings remain required. Historical native runs, the beta2 port, and earlier CI are preserved below and are not relabeled as current-head proof.

Historical evidence status refresh, 2026-10-27

At that refresh, the public head was c17b72d3538f81e934caaa4d5c373cf90e90c513. The completed CI run 39411875583 succeeded on tested merge 44577cf085aada61cbbfb40cbbd236c63a28518a, combining this head with main d8c96213c5cf40295863fb5fb6d347e1f9caf6b7. Its unique job inventory contains 5 successful and 37 skipped jobs, with no failures or pending jobs. These are this run's jobs, not a sum of duplicate check/status surfaces; skipped jobs are not passing runtime proof.

The exact delta since reviewed head ff41c754 changes only the endpoint source and its test file. configuredInput now classifies trimmed shorthand through envSecretRefName before auth-surface selection, and the existing handshake matrix adds both $GW_PASSWORD and ${GW_PASSWORD} with the available service token. This addresses the source change requested by the earlier P1 finding and preserves the original shorthand/fallback intent. It is a source disposition, not a new exact-head ClawSweeper verdict or packaged-app result.

The durable review explicitly says maintaining Swift/Core parity alone does not require another product decision. Earlier parity-approval language below records historical status and is superseded on that point. Maintainer acceptance remains outstanding. Packaged-app proof for the later remote-fallback combinations and a stable-release upgrade retaining existing shorthand settings remain unproven. The beta2-port test evidence below is not relabeled as current-head packaged-app proof. Earlier pending-CI statements are historical and superseded only by the completed run identified here. No new runtime test, whole-current-tree review, or upgrade demonstration is claimed by this refresh.

Historical follow-up, 2026-10-20

Follow-up head: c17b72d353.

  • Classify the existing $NAME and ${NAME} shorthand forms as references before implicit auth-mode selection. A missing password reference no longer suppresses an available service token. Explicit modes and malformed or literal values keep their existing paths.
  • The two-file follow-up passed scoped P0–P3 Codex review with no actionable findings. This is source review, not runtime proof.
  • The equivalent fix was compiled in the beta2 native integration. Its 13 credential-test functions passed in a deny-default OS sandbox, including the handshake matrix with both new shorthand cases. Strict SwiftLint, SwiftFormat, native i18n verification, and git diff --check passed. This is synthetic proof of the beta2 port, not an exact-head packaged-app run or real Keychain, GUI, identity, or upgrade proof.
  • Current-head CI started automatically after the push; no completed verdict is claimed here. Maintainer parity and acceptance decisions remain open.

Historical candidate evidence

Current PR candidate: 1ad4bcb852b2266950eea45c077ee023e1a42358, merged with current openclaw/openclaw:main at 1e13fc8abcd942ca398a89ca5560da11a1d46c41. GitHub confirms the PR is OPEN and the head/base match those revisions. The branch is MERGEABLE (no content conflict), but the merge state is BLOCKED by required CI. The PR delta against current main is limited to GatewayEndpointStore.swift and GatewayEndpointStoreTests.swift (+118/-8 production, +477/-1 tests).

  • The prior exact-head CI run found a SwiftFormat conditionalAssignment style error before compilation. The follow-up changes only the expression form and is being validated in current-head CI.
  • Scoped Codex autoreview on this exact head returned scoped-clean at P2 with no findings (confidence 0.76). Its report used the selected diff and supplied Core auth sources; it does not claim runtime verification. The report is preserved in the task-local review artifacts.
  • ClawSweeper reviewed this exact head and reported no actionable code or security findings. It marked merge blocked pending the macOS auth owner's decision on the ongoing Swift/Core credential-selection parity contract, and notes there is no fresh packaged-app runtime demonstration for the remote-token fallback.
  • Exact-head GitHub CI run 36282160728 completed with the macos-swift (tests) job cancelled while its Swift test step was running; no Swift test result is available. The aggregate openclaw/ci-gate failed solely because the selected macos-swift check was cancelled. Preflight, security-fast, native-i18n, all three macOS Node shards, Swift lint, macos-swift (packages), shared OpenClawKit scans, macOS Periphery, OpenGrep, actionlint, changed-path scan, and security review passed. The iOS Periphery scan was skipped by scope.
  • A rerun was requested for the cancelled job, but GitHub refused it with Must have admin rights to Repository. The Swift test verdict and aggregate CI gate therefore require a repository admin to rerun.
  • git diff --check passes. This Windows host has no Swift toolchain, so native Swift execution relies on exact-head GitHub CI.
  • The app-to-Gateway runtime proof below was performed on the earlier candidate 23b805fa3821e06e882d846843d96da2252a91bd. It is historical evidence and does not demonstrate the added remote-token fallback cases on the current candidate.

Native validation on 2026-09-04:

Validated candidate: 23b805fa3821e06e882d846843d96da2252a91bd.

The main refresh preserves @TheAngryPit's original repair, @CassieMei's carried
auth-mode and precedence corrections, and all five contributor commits. Its sole
content conflict was two independent insertions in the endpoint store; both the
typed-reference resolver and main's source-snapshot helper are retained.

Before

Native baseline run
used unchanged production main 606d9ab82afdb28ebaad33896e41811b96ad87c7.
The actual ad-hoc packaged app sent no token for a supported typed custom env
reference that the healthy managed local Gateway could resolve. It received
token_missing. A fresh literal-token control authenticated as openclaw-macos
and completed config.get.

After

Exact-candidate native run
reconstructed and checked the exact candidate tree/commit, verified its signature,
built the real app through the normal package script, and installed each real
local service through gateway install --wrapper. The wrapper supplied normal
diagnostics and, only in the app-env fallback cases, the service's synthetic env
value. Every case used fresh synthetic profile/pairing state.

Cases Native result
Service-only typed token and password Shared authentication and completed config.get
Different app/service values for one ref, both modes Service value selected; completed config.get
Supported app-env fallback, both modes Service snapshot lacks the ref value; completed config.get
Explicit modes with inactive opposite refs Correct active credential; completed config.get
Typed token + ambient password; typed password + ambient token Same password/token selection as Core; completed config.get
Denied and unresolved active refs, both modes No credential sent despite a valid ambient fallback; no protected request completed
All four rejected setups corrected and relaunched Shared authentication and completed config.get

The protocol evidence correlates openclaw-macos, mode ui, to successful
protected responses on the same connections. Separate Control UI traffic is not
used as a substitute. Rejected-ref probes kept the server healthy with the
existing reload-off option; no auth or pairing policy was relaxed. The corrected
setups connect normally.

  • GatewayEndpointStoreTests: 83 tests passed on the exact candidate, including
    provider/allowlist rules, handshake auth, legacy strings and lifecycle siblings.
  • All 14 managed services were uninstalled/unloaded, all app phases stopped, and
    all synthetic Keychains were deleted successfully.
  • The earlier obscured screenshots are not counted as visual auth evidence.
  • Native proof does not replace the fresh independent review or required PR CI.

Prior ClawSweeper finding and current scope

The fresh ClawSweeper finding was checked against Gateway startup at the exact
Core revision it reviewed. Startup's hasGatewayTokenCandidate excludes
gateway.remote.token, so a typed local password ref is materialized when no
ambient/local token candidate suppresses it; after materialization Core infers
password mode before token. The native selector and connect-frame regression
now preserve that password. If an ambient Gateway token is present, Core leaves
the password ref inactive and the native selector uses the token surface.

Against current main, the production delta is +118/-8 and the test delta is
+477/-1. The added native code
implements the existing typed-env contract; it adds no configuration option,
policy, schema, remote-auth behavior, or file/exec/store-ref support. Keep the
native/Core parity cases aligned when the shared auth contract changes.

The material below is retained contributor history at its stated inputs, not a
replacement for this current baseline and exact-candidate proof.

Historical contributor evidence

Historical contributor head: 4e35b1caf03687853b8cc9dd47f8d5c6ea81bb93

The native proof was built from the exact two-file PR patch (patch-id 7040be749e604bbda4f9be0b44ed15605a058bd9) over frozen base 9d79bf3f8c5f18f7c35d028d57402f5085659640.

  • swift test --package-path apps/macos --filter GatewayEndpointStoreTests — 75/75 passed on Apple Silicon macOS.
  • SwiftFormat with config/swiftformat — 0/2 files require formatting.
  • SwiftLint 0.65.1 with config/swiftlint.yml — 0 violations.
  • git diff --check — passed.
  • Full ad-hoc OpenClaw.app package build completed; codesign --verify --deep --strict passed.
  • Real isolated app-to-Gateway proof passed on port 19791: the Gateway service and app process received different synthetic values for the same typed token ref; the app selected the Gateway service value, authenticated, and completed a real config.get response.
  • Both isolated proof PIDs stopped afterward; the installed app remained running and no operator Gateway, config, Keychain, or PortGuardian state was changed.

Review finding and vanilla verification

ClawSweeper correctly identified that the previous selector returned no credential for mixed typed-ref/ambient cases. Before changing it, the current Core Gateway was exercised directly in two isolated profiles:

  • typed token ref + ambient password: Core marked the typed token surface inactive and started with password auth;
  • typed password ref + ambient token: Core marked the typed password surface inactive and started with token auth.

The native selector and regression expectations now reproduce those observed Core outcomes rather than introducing an independent token/password policy.

Fail-before evidence

  • The original typed-ref handshake cases failed before the SecretRef implementation.
  • Active-mode regression cases failed before mode filtering.
  • The service-vs-app conflict initially selected the stale app value before LaunchAgent precedence was corrected.
  • The two mixed inferred-mode cases returned no credential before 4e35b1caf03; both now match the isolated Core runtime outcomes.

Historical current-main revalidation (2026-09-03)

  • Current openclaw/openclaw:main: 9d6f5d218884b00a50746353c40170f5ab46e4db.
  • Exact PR head preserved: 4e35b1caf03687853b8cc9dd47f8d5c6ea81bb93.
  • git merge-tree --write-tree origin/main refs/remotes/audit/pr128175 completed cleanly.
  • The change is not superseded: current main resolves literal strings and legacy $ENV/${ENV} string forms, but still lacks the typed SecretRef object flow and matching credential-selection semantics covered by this PR.
  • Current product checks are complete. The earlier red PR context and evidence result was caused by malformed heading presentation; this body restores the authored sections explicitly.

AI assistance was used to investigate, implement, test, and review this change. The final diff and proof were inspected against current Core behavior.

@clawsweeper

clawsweeper Bot commented Aug 23, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@clawsweeper clawsweeper Bot added merge-risk: 🚨 auth-provider 🚨 May break OAuth, tokens, provider routing, model choice, or credentials. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Aug 23, 2026
@clawsweeper

clawsweeper Bot commented Aug 23, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: stale review; fresh review needed.

Summary
The latest durable ClawSweeper review was for head 3481ca33a1bf69a445814f0c620e12719c78f947, but the PR head is now 8149b98130829cb7d83ec153c9bc9355bcc7cc64. Its old verdict and PR readiness labels are no longer current.

Next step
Comment @clawsweeper re-review when the current head is ready; pushes after the first review are not reviewed automatically.

Review history (22 earlier review cycles; latest 8 shown)
  • reviewed 2026-09-27T00:26:07.083Z sha 1ad4bcb :: blocked before merge. :: none
  • reviewed 2026-09-27T01:04:20.317Z sha 1ad4bcb :: blocked before merge. :: none
  • reviewed 2026-09-29T22:20:20.068Z sha a536cc6 :: blocked before merge. :: none
  • reviewed 2026-09-29T22:31:49.121Z sha 1dd1b3d :: blocked before merge. :: none
  • reviewed 2026-09-29T23:21:39.227Z sha 343b812 :: blocked before merge. :: none
  • reviewed 2026-09-30T10:44:57.802Z sha 570338e :: blocked before merge. :: none
  • reviewed 2026-10-18T05:58:06.631Z sha ff41c75 :: needs real behavior proof before merge. :: [P1] Recognize environment shorthand before selecting the auth surface
  • reviewed 2026-11-02T22:22:03.307Z sha 3481ca3 :: needs real behavior proof before merge. :: none

@TheAngryPit
TheAngryPit force-pushed the fix/macos-typed-gateway-auth-secretrefs branch from 7140b7d to 3d2fca0 Compare August 23, 2026 10:41
@TheAngryPit
TheAngryPit marked this pull request as ready for review August 23, 2026 10:50
@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. clawsweeper-recovery-stuck rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. clawsweeper-recovery-stuck labels Aug 24, 2026
@TheAngryPit
TheAngryPit force-pushed the fix/macos-typed-gateway-auth-secretrefs branch from 3d2fca0 to 6616ec0 Compare August 29, 2026 05:29
@TheAngryPit

Copy link
Copy Markdown
Contributor Author

Exact-head proof is now attached to the PR body for 6616ec0279c11feb6d7d697b20fdc3547328aae4. The added connection-level regression covers both the allowlisted custom GW_TOKEN handshake and the denied-ref no-fallback handshake. @clawsweeper re-review

@TheAngryPit

Copy link
Copy Markdown
Contributor Author

Resolved the current-head P2 from ClawSweeper in 1b72615e3a95a94fc4b2b61ed24500b21817cf00.

  • The endpoint store now filters local credentials by the configured active auth mode before resolving typed refs.
  • The existing connection-level test now covers both inverse cases: token mode with a configured password ref and password mode with a configured token ref, plus the denied-ref/no-fallback case.
  • Fail-before: the new assertions produced four failures on 6616ec0279c (both inactive credentials resolved; password mode sent token).
  • After: 73/73 GatewayEndpointStoreTests pass; SwiftFormat 0/2; SwiftLint 0 violations; git diff --check passes.
  • Repair delta: production +12/-0; test +37/-23.

No installed app, operator Gateway, config, Keychain, or PortGuardian state was touched, so this remains exact-head connection-path test_proven, not a claim of installed-app runtime proof.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 29, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

@openclaw-barnacle openclaw-barnacle Bot added triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. and removed triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. labels Aug 29, 2026
@TheAngryPit
TheAngryPit force-pushed the fix/macos-typed-gateway-auth-secretrefs branch 3 times, most recently from 1b72615 to 0d6d0f6 Compare August 29, 2026 07:55
@clawsweeper clawsweeper Bot added clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 18, 2026
@roboclaw-bot roboclaw-bot added the clawtributors PR from a clawtributor label Oct 28, 2026
@roboclaw-bot

Copy link
Copy Markdown
Collaborator

Contributor-PR loop note: we checked this against current main (b7cc7ebc). The defect is still there: GatewayEndpointStore.swift:149 casts gateway auth to a string, so typed secret-ref objects are dropped (#128171).

We're leaving this PR open rather than taking it over. The fix is Swift-only and needs a native macOS reproduction and proof, and this loop has no macOS host. When it lands, it should keep the human co-author credits: Ayaan Zaidi, TheAngryPit and Vitor Cepeda Lopes.

@RomneyDa

RomneyDa commented Nov 2, 2026

Copy link
Copy Markdown
Member

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 auth-provider 🚨 May break OAuth, tokens, provider routing, model choice, or credentials. labels Nov 2, 2026
tideclaw-bot pushed a commit that referenced this pull request Nov 4, 2026
Adapt #128175 source 3481ca3 to stable. Preserve #191468 configured credential precedence and the existing remote base path. Resolve explicit auth modes and typed env SecretRefs without falling through invalid configuration. Fresh P2 source review clean; Swift/native execution remains required qualification.

Co-authored-by: RomneyDa <[email protected]>
@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime labels Nov 4, 2026
@github-actions

github-actions Bot commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

⚠️ Maintainer security review required

This external contributor PR changes sensitive security components. A maintainer must review these changes before merging.

Current SHA: 8149b98130829cb7d83ec153c9bc9355bcc7cc64

These sensitive security changes were made:

  • src/gateway/credential-planner.ts: Controls credential persistence, secret resolution, or redaction. Check storage permissions, credential scope, and exposure in logs or responses.
  • src/secrets/runtime-gateway-auth-surfaces.ts: Controls credential persistence, secret resolution, or redaction. Check storage permissions, credential scope, and exposure in logs or responses.

After reviewing the changes, post a new PR comment containing only approval commands, each on its own line:

/allow-security-sensitive-change

A later push requires a fresh approval comment.

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

Labels

app: macos App: macos clawtributors PR from a clawtributor docs Improvements or additions to documentation gateway Gateway runtime P1 High-priority user-facing bug, regression, or broken workflow. security-review-required security-sensitive-changed size: L

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: macOS app cannot resolve typed Gateway auth SecretRefs

6 participants