Skip to content

fix(daemon): keep egress-proxy CA paths out of service units - #177007

Merged
steipete merged 2 commits into
mainfrom
upd/upd-l1696
Oct 19, 2026
Merged

steipete merged 2 commits into
mainfrom
upd/upd-l1696

Conversation

@steipete

@steipete steipete commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #176479

What Problem This Solves

Installing a Gateway from another Gateway's exec environment can persist the caller's temporary secret-egress-proxy CA in the service unit. After the caller restarts, the installed Gateway and its children inherit a missing CA path.

User Impact

Installation excludes process-owned proxy artifacts on systemd, launchd, and Windows tasks while retaining operator CA files. The shared classifier preserves corporate proxy values; existing service proxy-capture policy still applies. openclaw doctor --fix repairs affected definitions with backups, preserves unrelated settings, and restores service availability.

Why This Change Was Made

The egress-proxy owner supplies its fixed injection key set and a shared structural predicate. CA paths are normalized before checking whether they reside inside a secret-egress-proxy/gateway-*/ directory; proxy URLs must match the owner's authenticated loopback endpoint shape. Arbitrary keys and ordinary operator values are preserved. There is no environment-carried provenance marker or JSON parser. A surviving corporate HTTP(S) proxy retains NODE_USE_ENV_PROXY; that flag is removed only when the HTTP(S) proxies present are all proxy-owned.

Doctor detection, preservation checks, and install capture use the same predicate. Doctor's restoration handoff uses an exact fingerprint captured by this maintenance session's own native writer under its operation lock and authority. It cannot be supplied through environment data. The unchanged definition remains valid when no repair runs; a later edit or foreign ownership is rejected. Same-install repairs with verified unchanged/restored outcomes resume the previous running service with a warning.

The node-service launcher repair from #175860 activates through its own native installer. Gateway policy refresh occurs before the stopped-service snapshot. Repairs performed during Gateway restoration share the same native-write handoff.

Evidence

  • The forged-receipt regression fails on f4fd4f8a: it removes an operator's CA and CUSTOM_SETTING. It passes after deleting the marker mechanism. The corporate-proxy activation regression also fails before its fix and passes afterward. Tests cover arbitrary keys, normalized paths outside proxy directories, Windows casing, real proxy artifacts, Doctor drift/repair, and restoration.
  • Focused tests: 133 passed, 1 existing skip across seven files (81.47s). After the final proxy-activation correction and cosmetic lint rename, the environment suite passed 6/6 (1.81s).
  • Cross-lane selection: 86 test files exercised in original input order with node scripts/run-vitest.mjs … --maxWorkers=4. Combined completed results: 1,652 passed, 8 skipped, 3 failed. Two failures are the unchanged database-rollback Git case timeouts; the third is the unchanged rollback state-verification case detailed below. A lint-only rename during the first run invalidated its frozen compiler snapshot; the 59 affected files were replayed with source frozen, producing 1,177 passed, 8 skipped, 1 failed in 1,417.47s and a clean compiler-integrity check. Initial completed suites took 1,221.99s including the rejected later shards. These are not reported as a green broad run.
  • Clean Linux/systemd replay passed using Node 24 and isolated synthetic state. A real origin Gateway generated the CA; installing a second profile with all eight proxy variables persisted none and returned HTTP 200. After seeding a stale CA and CUSTOM_SETTING=retained, stopping the origin removed its CA. node /candidate/openclaw.mjs --profile proof doctor --fix --yes --non-interactive --no-workspace-suggestions exited 0, removed the stale CA, preserved the custom setting, wrote definition/receipt backups, restored the service to active, and returned HTTP 200 from /healthz; zero missing-CA warnings appeared in the final invocation. Both the owned container and image were removed.
  • Core and targeted test tsgo, direct oxlint on changed production/test files, oxfmt --check on all 18 changed files, git diff --check, and madge all passed; madge found zero cycles. Full build passed (4m43.7s); final runtime build passed (1m15.3s).
  • Fresh Codex review: no accepted/actionable P0–P2 findings in the selected scope after fixing the proxy-activation finding. Sensitive-path omissions remain a review limitation.
  • Production +199/−52 (net +147), tests +365/−37, docs +2/−0 against the original base. Production net growth dropped from +190 to +147; the marker parser, receipt handling, and preservation option were deleted. Remaining growth implements structural filtering, Doctor repair, and the native restoration handoff.

Full check:changed SQLite inventory was skipped under the local gate time budget. Existing ratchets are not changed: the environment-name budget is already over its limit on the base (459/452); the removed marker's historical name remains only in forgery fixtures. Existing max-lines suppression findings are in untouched chat/config/sessions UI files. The build reported a UI boot gzip advisory (1025.6 KiB against 1025.4 KiB); no UI source or budget was changed. Current slow-test timings and any failures are recorded below.

The unchanged update-command-database-rollback.test.ts exceeded its 120s case budget for git (120.057s) and git-edited (120.058s); package took 117.941s and exited-writer 80.252s. This 13-case serial integration fixture repeatedly creates packages and SQLite state, boots child services, runs the full update/Doctor/finalization path, and launches isolated database workers. Git cases additionally perform real local Git transactions; pnpm build is mocked, so package installation/network is not the cause. The source and durations support cumulative subprocess/module-load and worker-round-trip cost; the log has no phase-level timing, so precise attribution remains open. These timeouts are recorded, not retried or weakened. Other unchanged update fixture maxima and final consumer totals follow below.

The unchanged update-command-rollback.test.ts also failed identity-read-failed schema change; previous verified=true; service=stopped in 1.827s: candidate state verification returned rollback-state-unverified before any restoration step or the changed service revalidation was reached. The rollback catch omits the underlying exception from this fixture result when no update run is provided, so the exact worker/read cause remains unresolved; this is not presented as a proven timeout or patch regression. It was not rerun to chase green.

Other unchanged slow suites: update-cli.git-service.test.ts had 11 cases over 30s (maximum 114.726s, “reports managed Git restart failure: refused”); update-cli.service-authority.test.ts had nine (maximum 102.341s, final ancestry refusal); the rollback replay reached 44.112s for the owned-include-alias case. They exercise repeated service/update/worker lifecycles. No timeout, retry, skip, or assertion was weakened. Precise phase profiling remains a separate follow-up.

No new runtime environment variable, config/CLI option, schema, dependency, baseline, or suppression.

@clawsweeper

clawsweeper Bot commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

ClawSweeper review blocked

Automated review did not run, so no review verdict was produced.

Reason: The input-safety check rejected material in this revision. No detected value, path, or scanner output is reproduced here.

Automatic review is on hold, including after source changes. Request a fresh re-review after resolving the failure; maintainers can also release the hold through an intentional scanner-policy update.

Next step: If this is a genuine credential, remove and rotate it. If it is an intentional test fixture, a maintainer must review and qualify it.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime cli CLI command changes commands Command implementations size: L labels Oct 19, 2026
@steipete
steipete marked this pull request as ready for review October 19, 2026 06:07
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-19T07:06:37.413997Z 4988784 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@github-actions

github-actions Bot commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

⚠️ Security sensitive changes

This maintainer PR changes sensitive security components.

No secops approval is required. This comment is informational because the PR author has Maintain or Admin access.

  • Current SHA: 4988784466ee998e0f5ba745bcfa574fea3330da
  • Maintainer: @steipete
  • Repository role: admin

These security sensitive changes were made:

  • src/secrets/egress-proxy/environment.ts: Controls credential persistence, secret resolution, or redaction. Check storage permissions, credential scope, and exposure in logs or responses.
  • src/secrets/egress-proxy/proxy-server.ts: Controls credential persistence, secret resolution, or redaction. Check storage permissions, credential scope, and exposure in logs or responses.

Carefully review these changes before merging.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f4fd4f8a1e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/secrets/egress-proxy/environment.ts Outdated
Comment on lines +50 to +54
const proxyUrl = normalized.HTTPS_PROXY;
const legacyProxy =
legacyCa(caPath) && /^http:\/\/openclaw:[^@]+@127\.0\.0\.1:\d+$/u.test(proxyUrl ?? "")
? proxyUrl!
: "";

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Detect both legacy proxy variables independently

When a pre-receipt service still contains the injected HTTP_PROXY but an operator has replaced or removed HTTPS_PROXY, legacyProxy is empty because it is derived only from HTTPS_PROXY. The later matching logic therefore preserves both the dead authenticated loopback HTTP_PROXY and NODE_USE_ENV_PROXY while removing the temporary CA, so doctor --fix or reinstall leaves HTTP requests routed through a proxy that disappeared with the old Gateway. Classify each legacy proxy variable independently and remove the Node flag when either injected proxy remains.

AGENTS.md reference: AGENTS.md:L75-L76

Useful? React with 👍 / 👎.

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. labels Oct 19, 2026
@steipete

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

Updated in 4988784: removed the inherited JSON marker and replaced it with the egress owner's fixed-key structural filter. Operator CA paths and surviving corporate proxy activation are preserved. The native, session-owned restoration fingerprint handoff remains intact. The PR body includes the passing clean Linux replay, current checks, LOC, and the three unresolved failures in unchanged consumer suites.

@clawsweeper

clawsweeper Bot commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added the clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. label Oct 19, 2026
@steipete
steipete merged commit 7fcb8fb into main Oct 19, 2026
131 of 134 checks passed
@steipete
steipete deleted the upd/upd-l1696 branch October 19, 2026 07:16
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 20, 2026
…w#177007)

Running openclaw gateway install from inside a Gateway exec with the secret egress proxy enabled captured that Gateway's per-process NODE_EXTRA_CA_CERTS (an ephemeral trust bundle under its state dir) into the new service unit, so the installed Gateway and its children later pointed at another profile's stale or live proxy CA. The egress-proxy owner now exports the fixed set of variables it injects plus a structural check for its own per-process artifacts; service installation (systemd, launchd, Scheduled Task) excludes only those values and keeps operator-set CA and proxy settings. openclaw doctor --fix repairs existing units, and Doctor restoration accepts exactly the definition its own repair wrote, so the service is restarted instead of left stopped.

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

Labels

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. cli CLI command changes commands Command implementations docs Improvements or additions to documentation gateway Gateway runtime security-sensitive-changed size: L

Projects

None yet

Development

Successfully merging this pull request may close these issues.

gateway install persists caller process-owned secret-egress-proxy NODE_EXTRA_CA_CERTS into the service unit

1 participant