Skip to content

[Bug]: NODE_USE_SYSTEM_CA=1 breaks openai-codex auth/keychain paths on macOS and can fail fresh runtime launch with SecItemCopyMatching failed -50 #89655

Closed as not planned

Description

@kasanuowa

Bug type

Regression (worked before, now fails)

Beta release blocker

No

Summary

On macOS, exporting NODE_USE_SYSTEM_CA=1 in the OpenClaw Gateway/runtime environment makes openai-codex keychain-backed auth reads fail with SecItemCopyMatching failed -50, while forcing bundled CA restores the same auth call.

Steps to reproduce

  1. Ensure the Gateway/runtime environment exports NODE_USE_SYSTEM_CA=1.
  2. Run openclaw models auth list --agent main --provider openai-codex --json.
  3. Observe immediate failure: SecItemCopyMatching failed -50.
  4. Run NODE_USE_SYSTEM_CA=0 NODE_OPTIONS=--use-bundled-ca openclaw models auth list --agent main --provider openai-codex --json.
  5. Observe that the command succeeds and returns the expected openai-codex OAuth profiles.

Expected behavior

Enabling system CA should not break openai-codex auth/keychain access or fresh runtime launch paths on macOS; openclaw models auth list --agent main --provider openai-codex --json should succeed under the same environment.

Actual behavior

With NODE_USE_SYSTEM_CA=1, macOS keychain-backed auth access fails with SecItemCopyMatching failed -50, and fresh runtime launch paths that depend on that auth surface become unreliable.

OpenClaw version

2026.5.28 (e932160)

Operating system

macOS 26.4.1 (Darwin 25.4.0, arm64)

Install method

local gateway service

Model

openai-codex

Provider / routing chain

openclaw -> openai-codex OAuth/keychain auth lookup on macOS

Additional provider/model setup details

Gateway/service environment includes NODE_USE_SYSTEM_CA=1.

Forcing bundled CA behavior with NODE_USE_SYSTEM_CA=0 NODE_OPTIONS=--use-bundled-ca openclaw models auth list --agent main --provider openai-codex --json restores the same auth lookup immediately.

This can appear intermittent because already-warm sessions or code paths with explicit bundled-CA overrides may still work while fresh auth reads or fresh child launches fail.

Logs, screenshots, and evidence

Observed failing command:
`openclaw models auth list --agent main --provider openai-codex --json`

Observed error:
`SecItemCopyMatching failed -50`

Observed successful workaround command:
`NODE_USE_SYSTEM_CA=0 NODE_OPTIONS=--use-bundled-ca openclaw models auth list --agent main --provider openai-codex --json`

The workaround returns the expected `openai-codex` OAuth profiles immediately.

Impact and severity

Affected: macOS OpenClaw runtimes using openai-codex auth/keychain access with NODE_USE_SYSTEM_CA=1
Severity: High (breaks auth reads and can block fresh runtime launches)
Frequency: Observed immediately on fresh auth reads in this setup; warm or overridden paths may appear intermittent
Consequence: openclaw models auth list, openclaw models status, agent launches, ACP/subagent spawns, and background launches that need fresh auth access can fail

Additional information

This appears related to the broader macOS + openai-codex + auth/keychain/runtime-launch issue cluster, but this repro isolates NODE_USE_SYSTEM_CA=1 as the trigger and bundled CA as the immediate workaround.

Workaround observed in this environment:
NODE_USE_SYSTEM_CA=0
NODE_OPTIONS=--use-bundled-ca

Activity

  1. added
    bug
    on Jun 3, 2026
  2. added
    regression
    on Jun 3, 2026
  3. clawsweeper commented on Jun 3, 2026

    @clawsweeper
    Contributor

    Codex review: keeping this open for maintainer follow-up; there is still a little grit to resolve. Reviewed June 21, 2026, 5:04 AM ET / 09:04 UTC.

    Summary
    Keep open: current main and the latest release still contain the macOS NODE_USE_SYSTEM_CA=1 service default plus reachable Codex keychain/auth paths, and no merged same-repo fix or canonical duplicate proves the reported macOS SecItemCopyMatching failed -50 failure is resolved. The external credential-delegation comment is useful context, but it is not a current OpenClaw implementation or proven in-repo workaround.

    Reproducibility: no. high-confidence live reproduction was run in this review. The reporter provides concrete macOS commands, and current source still has the relevant service CA default plus keychain-capable Codex auth paths, so the source path remains credible.

    Ways to help us reproduce this

    • Add a screenshot or short recording showing the behavior.
    • Add expected vs actual behavior.
    • Include redacted logs or terminal output.

    Next step
    A maintainer needs to choose and validate the macOS TLS/auth boundary with live macOS proof before any automated fix PR is safe.

    Review details

    Best possible solution:

    Reproduce the failure on macOS, then fix the narrow auth/startup boundary so Codex keychain/status/runtime launch reads do not inherit the problematic CA mode while preserving launchd TLS reliability.

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

    No high-confidence live reproduction was run in this review. The reporter provides concrete macOS commands, and current source still has the relevant service CA default plus keychain-capable Codex auth paths, so the source path remains credible.

    Is this the best way to solve the issue?

    Unclear: forcing bundled CA globally is a useful workaround signal but not clearly the best product fix because the macOS system-CA default protects launchd TLS. A scoped auth/startup boundary fix needs maintainer choice and macOS proof.

    AGENTS.md: found and applied where relevant.

    Remaining risk / open question:

    • The exact macOS SecItemCopyMatching failed -50 symptom was not live-reproduced in this review, so the failure remains source-supported plus reporter-provided rather than independently proven on current main.
    • Changing the macOS system-CA default globally could regress the launchd TLS behavior that default was added to protect.
    • Open PR fix: CLI auth status/probe path regression #75223 overlaps CLI status/probe discovery but does not directly prove the NODE_USE_SYSTEM_CA keychain failure or fresh runtime launch path is fixed.
    • The external credential-delegation workaround proposed in the issue comments may be useful directionally, but it is not a current OpenClaw core implementation or documented support path.

    Codex review notes: model internal, reasoning high; reviewed against 3b332fd0a485.

    Label changes

    Label justifications:

    • P1: The report describes an auth-provider regression that can block fresh macOS runtime launches for affected users.
    • impact:auth-provider: The affected surface is OpenAI/Codex OAuth, keychain credential resolution, and provider auth status/runtime startup behavior.
    Evidence reviewed

    What I checked:

    • Repository policy read: Root AGENTS.md plus relevant scoped guides for agents, gateway, and scripts were read; the Codex dependency-inspection and auth/provider compatibility guidance affected the review. (AGENTS.md:1, 3b332fd0a485)
    • Vision fit: VISION.md lists bug fixes, stability, setup reliability, and safe defaults as current priorities, so a macOS auth/startup reliability regression is in scope. (VISION.md:17, 3b332fd0a485)
    • Current main macOS CA default: resolveNodeStartupTlsEnvironment still defaults NODE_USE_SYSTEM_CA to 1 on Darwin when Darwin defaults are included. (src/bootstrap/node-startup-env.ts:35, 3b332fd0a485)
    • Service environment carries the CA default: The daemon service environment still passes the resolved Node TLS env into managed service env, so launch-style paths can inherit the macOS NODE_USE_SYSTEM_CA default. (src/daemon/service-env.ts:480, 3b332fd0a485)
    • Current Codex keychain path: OpenClaw still reads Codex CLI credentials through security find-generic-password on Darwin unless allowKeychainPrompt is explicitly false. (src/agents/cli-credentials.ts:257, 3b332fd0a485)
    • Auth-list path is only a partial mitigation: models auth list --provider ... now scopes external CLI discovery through externalCliDiscoveryForProviderAuth, whose default disables keychain prompting, but that does not prove all status or fresh launch paths are fixed. (src/commands/models/auth-list.ts:120, 3b332fd0a485)

    Likely related people:

    • magos-minor: Authored the merged commit that defaulted NODE_USE_SYSTEM_CA=1 on macOS service environments for managed daemon launches. (role: introduced behavior; confidence: high; commits: 350ac0d82448; files: src/daemon/service-env.ts, src/daemon/service-env.test.ts)
    • steipete: History shows repeated work on Codex keychain credential reads, startup TLS planning, and external CLI auth scoping in the central files for this report. (role: feature-history owner; confidence: high; commits: 1f95d7fc8bec, 720b9dd11699, 29b165e45613; files: src/agents/cli-credentials.ts, src/bootstrap/node-startup-env.ts, src/daemon/service-env.ts)
    • vincentkoc: Recent path history and current-source blame boundaries point to concentrated maintenance of auth bootstrap, external OAuth, and adjacent Codex runtime auth surfaces. (role: recent area contributor; confidence: medium; commits: 859eb0666282, 78288e37ed, f6921fd733; files: src/agents/cli-credentials.ts, src/agents/auth-profiles/external-cli-sync.ts, src/commands/models/list.status-command.ts)
    How this review workflow works
    • 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.
  4. added
    P1
    impact:auth-provider
    issue-rating: 🐚 platinum hermit
    clawsweeper:needs-live-repro
    clawsweeper:no-new-fix-pr
    clawsweeper:needs-maintainer-review
    on Jun 3, 2026
  5. added
    clawsweeper:needs-product-decision
    on Jun 15, 2026
  6. openclaw-barnacle commented on Jul 6, 2026

    @openclaw-barnacle

    This issue has been automatically marked as stale due to inactivity.
    Please add updates or it will be closed.

  7. added
    stale
    on Jul 6, 2026
  8. openclaw-barnacle commented on Jul 14, 2026

    @openclaw-barnacle

    Closing due to inactivity.
    If this is still an issue, please retry on the latest OpenClaw release and share updated details.
    If you are absolutely sure it still happens on the latest release, open a new issue with fresh steps to reproduce.

  9. locked as resolved and limited conversation to collaborators on Aug 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P1bugclawsweeper:needs-live-reproclawsweeper:needs-maintainer-reviewclawsweeper:needs-product-decisionclawsweeper:no-new-fix-primpact:auth-providerissue-rating: 🐚 platinum hermitregressionstale

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions