Skip to content

fix(install): manage auth-profile env refs via OPENCLAW_SERVICE_MANAGED_ENV_KEYS#96059

Closed
Darren2030 wants to merge 1 commit into
openclaw:mainfrom
Darren2030:fix/auth-profile-managed-env-keys
Closed

fix(install): manage auth-profile env refs via OPENCLAW_SERVICE_MANAGED_ENV_KEYS#96059
Darren2030 wants to merge 1 commit into
openclaw:mainfrom
Darren2030:fix/auth-profile-managed-env-keys

Conversation

@Darren2030

Copy link
Copy Markdown
Contributor

Summary

Fixes #95895. When a provider API key such as GEMINI_API_KEY is configured via an auth profile, openclaw gateway install was writing the key as a plaintext literal in the generated systemd/LaunchAgent service file. All other provider secrets were already handled via OPENCLAW_SERVICE_MANAGED_ENV_KEYS and resolved at runtime; auth-profile env refs were the missing source.

Changes

  • src/commands/daemon-install-helpers.ts: include auth-profile env refs when computing OPENCLAW_SERVICE_MANAGED_ENV_KEYS, so they are removed from inline service env values and referenced via the managed-keys list instead.
  • src/commands/daemon-install-helpers.test.ts: update existing auth-profile assertions and add a GEMINI_API_KEY regression test.
  • scripts/repro/issue-95895-auth-profile-managed-env-keys.mts: standalone reproduction script that runs buildGatewayInstallPlan against a real temp home and verifies the key is managed, not inline.

Real behavior proof

  • Behavior addressed: auth-profile GEMINI_API_KEY no longer appears as a plaintext literal in the generated gateway service environment; it is listed in OPENCLAW_SERVICE_MANAGED_ENV_KEYS.
  • Real environment tested: Linux, Node 24.13, source tree at current main.
  • Exact steps or command run after this patch:
    • pnpm build
    • node --import tsx scripts/repro/issue-95895-auth-profile-managed-env-keys.mts
  • Evidence after fix:
    OPENCLAW_SERVICE_MANAGED_ENV_KEYS=GEMINI_API_KEY
    GEMINI_API_KEY inline=(not inline - good)
    PASS: Auth-profile GEMINI_API_KEY is managed, not written as plaintext.
    
  • Observed result after fix: plan.environment.GEMINI_API_KEY is undefined; plan.environment.OPENCLAW_SERVICE_MANAGED_ENV_KEYS contains GEMINI_API_KEY.
  • What was not tested: Actual systemd service file rendering on a host with systemctl; the fix is at the install-plan environment level.

Verification

  • pnpm test src/commands/daemon-install-helpers.test.ts --run — 45 passed
  • node scripts/run-oxlint.mjs --tsconfig config/tsconfig/oxlint.core.json src/commands/daemon-install-helpers.ts src/commands/daemon-install-helpers.test.ts — passed
  • node --import tsx scripts/repro/issue-95895-auth-profile-managed-env-keys.mts — PASS

AI-assisted: yes.

@clawsweeper

clawsweeper Bot commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Thanks for the context here. I swept through the related work, and this is now duplicate or superseded.

Close: this branch is superseded by #96149, and this patch is not safe to merge because it removes auth-profile env values from the install plan without marking them file-backed for service delivery.

Canonical path: Close this branch and review or land the file-backed environmentValueSources fix in #96149 for the canonical credential-exposure issue.

So I’m closing this here and keeping the remaining discussion on #96149.

Review details

Best possible solution:

Close this branch and review or land the file-backed environmentValueSources fix in #96149 for the canonical credential-exposure issue.

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

Yes. Source inspection shows auth-profile env refs enter the install plan as inline values on current main, and this PR then removes those values through the managed-key policy before service renderers can deliver them.

Is this the best way to solve the issue?

No. OPENCLAW_SERVICE_MANAGED_ENV_KEYS is safe for durable dotenv-managed values, but auth-profile env refs need their current values preserved and marked file-backed for the service renderer.

Security review:

Security review cleared: The diff touches credential rendering but I found no new plaintext exposure or supply-chain change; the blocking issue is provider credential delivery.

AGENTS.md: found and applied where relevant.

What I checked:

  • PR patch deletes auth-profile env values through managed-key policy: The PR changes managedServiceEnvKeys to include authProfileEnvironment; writeManagedServiceEnvKeysToEnvironment deletes listed keys from the planned environment before service rendering. (src/commands/daemon-install-helpers.ts:577, 77297447b173)
  • Current plan entries default to inline unless explicitly marked file-backed: addServiceEnvPlanEntries defaults missing valueSource to inline, so a service env value needs an explicit file-backed source if the renderer must carry it through an EnvironmentFile. (src/daemon/service-env-plan.ts:70, 654544b6b7c4)
  • Systemd EnvironmentFile only receives dotenv or file-backed environment values: Systemd staging merges dotenvVars and fileBackedEnvironment; a key removed from plan.environment and only named in OPENCLAW_SERVICE_MANAGED_ENV_KEYS has no current value to write. (src/daemon/systemd.ts:932, 654544b6b7c4)
  • Superseding PR preserves value delivery with the existing file-backed contract: The open replacement marks Google/Gemini config SecretRef and auth-profile env refs as environmentValueSources: "file", and its body includes staged systemd proof showing no inline plaintext plus a generated 0600 EnvironmentFile containing the values. (src/commands/daemon-install-helpers.ts:580, 80033c65c53e)
  • History points to daemon install and systemd env provenance owners: Blame and symbol history tie the relevant install-plan and systemd env-source code to recent daemon install commits, including the auth-profile daemon env introduction and later EnvironmentFile provenance work. (src/commands/daemon-install-helpers.ts:529, ba9fb4d994d6)

Likely related people:

  • vincentkoc: Current blame for the daemon install environment planner and systemd value-source helpers points to Vincent Koc's recent commits in this checkout. (role: recent area contributor; confidence: medium; commits: fa263affd584, c645ec4555c0; files: src/commands/daemon-install-helpers.ts, src/daemon/systemd.ts)
  • steipete: The auth-profile daemon env-ref persistence behavior appears in Peter Steinberger's fix: persist auth profile env refs for daemon install commit, directly adjacent to this PR's touched path. (role: introduced adjacent behavior; confidence: medium; commits: ba9fb4d994d6, a2cb80b9c4be; files: src/commands/daemon-install-helpers.ts, src/commands/daemon-install-helpers.test.ts, src/daemon/systemd.ts)
  • tmimmanuel: History for avoiding inline dotenv secrets in systemd units changed the EnvironmentFile rendering path that this PR should use instead of dropping the planned value. (role: adjacent systemd EnvironmentFile contributor; confidence: medium; commits: a2ab9e6a8e4c; files: src/daemon/systemd.ts, src/daemon/systemd.test.ts, src/config/state-dir-dotenv.ts)

Codex review notes: model internal, reasoning high; reviewed against 654544b6b7c4.

@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P1 High-priority user-facing bug, regression, or broken workflow. 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 Jun 23, 2026
@clawsweeper

clawsweeper Bot commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

ClawSweeper applied the proposed close for this PR.

@clawsweeper clawsweeper Bot closed this Jun 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

commands Command implementations 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. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. scripts Repository scripts size: S status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Security]: GEMINI_API_KEY written as a plaintext literal in the generated systemd service unit

1 participant