Repository navigation
fix(proxy): bound debug CA generation - #109106
Conversation
|
Codex review: needs maintainer review before merge. Reviewed August 7, 2026, 12:38 PM ET / 16:38 UTC. ClawSweeper reviewWhat this changesThe PR bounds debug-proxy CA generation, stages and validates the certificate/key pair, and recovers safely after interrupted generation. Merge readinessKeep open. Current main still directly generates the debug-proxy CA without a timeout or pair validation; this PR repairs that shared lifecycle owner with sufficient real-path proof and no actionable patch finding. Priority: P2 Review scores
Verification
How this fits togetherThe debug proxy creates a local certificate authority before proxy startup and CA installation can proceed. The shared CA routine supplies the resulting certificate/key pair to the proxy server, CLI, and install script. flowchart LR
A[Proxy startup or CA install] --> B[Shared CA lifecycle]
B --> C[Validate existing pair]
C -->|missing or invalid| D[Run OpenSSL with deadline]
D --> E[Stage and validate pair]
E --> F[Publish local CA files]
F --> G[Proxy and installer use CA]
Before merge
Agent review detailsSecurityNone. PR surfaceSource +79, Tests +198. Total +277 across 4 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Adopt one shared CA lifecycle that validates existing material, bounds generation, stages publication, and lets startup/install callers receive a prompt actionable failure instead of a hang. Do we have a high-confidence way to reproduce the issue? Yes—source establishes a high-confidence current-main path: the shared CA routine directly writes OpenSSL output without a timeout, and the supplied production-boundary trace demonstrates the repaired timeout/retry behavior. Is this the best way to solve the issue? Yes—the shared CA lifecycle is the narrowest maintainable repair because all relevant callers use it; caller-side guards and the Gateway TLS publication policy would leave this owner boundary broken or impose different semantics. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against b738e2578087. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (18 earlier review cycles; latest 8 shown)
|
1ac7074 to
5446b8d
Compare
|
@clawsweeper re-review Please review exact head The prior partial-output blocker is addressed with same-directory staging, CA/key validation, process-local and cross-process serialization, restrictive modes before publication, and retry-safe key/certificate renames. The hard-link approach was removed after adversarial review because it would not work on every supported state filesystem. Exact-head proof:
The PR body now contains the exact commands, dependency contracts, and redacted JSON proof. |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
5446b8d to
0bbc437
Compare
0bbc437 to
febb9e9
Compare
12b48ec to
7be2615
Compare
e3c65d0 to
08d1e4c
Compare
08d1e4c to
fc67faf
Compare
fc67faf to
fbdeb30
Compare
fbdeb30 to
7275bad
Compare
|
@clawsweeper re-review Please review exact head The refreshed patch retains the shared lifecycle-owner repair and adds the required LibreSSL-compatible subject configuration. The 30-second OpenSSL timeout policy also has merged maintainer precedent in #109139. Exact-head canonical CI run 31161221865 is still in progress with only lint remaining and no failures so far. |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
What Problem This Solves
Starting the local debug proxy could wait indefinitely if OpenSSL stalled while generating its short-lived root CA. Interrupting direct writes could also leave a partial certificate pair that later starts could not use safely.
Why This Change Was Made
The debug proxy now gives OpenSSL a 30-second deadline and generates into a private staging directory beside the final files. Before publication it verifies that the certificate is a CA and that its private key matches, then applies
0644/0600modes and publishes with same-directory renames.KeyedAsyncQueueserializes callers in one process, while the shared file-lock helper serializes OpenClaw writers across processes. Every caller validates the pair while holding that lock, so a process interrupted between the two renames is repaired on the next invocation instead of being reused.The explicit OpenSSL config makes the required
CA:TRUEand signing usage deterministic instead of depending on a hostOPENSSL_CONF. This remains the existing seven-day local debug-proxy CA; no config surface or external API changes.Dependency contracts checked:
req -x509accepts explicit config/extensions and writes the requested-keyout/-outfiles: https://docs.openssl.org/3.5/man1/openssl-req/fs.renameSyncreplaces an existing destination file; staging in the same directory avoids cross-device rename failures: https://nodejs.org/api/fs.html#fsrenamesyncoldpath-newpathX509Certificate.caandcheckPrivateKey; both contracts were checked against the runtime sources used by this repository.runExecforwardstimeoutMsto Execa 10.0.0; its timeout path terminates the child and waits for process completion before rejecting.User Impact
If local CA generation stalls, debug proxy startup now fails after about 30 seconds rather than hanging indefinitely. The failed attempt leaves no partial final files or orphan OpenSSL process, and a subsequent start regenerates a valid pair without manual cleanup.
Evidence
Exact reviewed head:
5446b8da419eb41661b9bc4e22d8ab8fb4d12999, rebased ona8fd558d6210fdd2dbdd500a5e3a875b383f9c67.24.18.0on Linux:node scripts/run-vitest.mjs src/proxy-capture/ca.test.ts src/proxy-capture/proxy-server.test.ts src/proxy-capture/proxy-server.managed-proxy.test.ts --run-> 3 files, 15 tests passed.config/tsconfig/oxlint.core.json, targetedoxfmt --check, andgit diff --check origin/main...HEAD: passed.Real production-path proof used the actual
ensureDebugProxyCa->runExec->/usr/bin/opensslpath, with a controlled preload that stalls only the real OpenSSL process after it creates partial staged outputs:{"head":"5446b8da419eb41661b9bc4e22d8ab8fb4d12999","node":"v24.18.0","platform":"linux/x64","timeoutElapsedMs":30041,"timeoutObserved":true,"stalledOpenSslPid":29,"orphanOpenSslProcesses":0,"entriesAfterTimeout":[]} {"retryElapsedMs":401,"finalEntries":["root-ca-key.pem","root-ca.pem"],"certificateIsCa":true,"privateKeyMatches":true,"certMode":420,"keyMode":384}The numeric modes are
0644for the certificate and0600for the private key.Exact-head proof continuity (immutable no-runtime-diff, 2026-07-20)
7be2615a6d10c0bda16612ca27961a1414f5721f.5446b8da419eb41661b9bc4e22d8ab8fb4d12999.src/proxy-capture/ca.test.ts: old5b0a5b76bd44b8b1d9bf053c59e5af1a0106eae6= current5b0a5b76bd44b8b1d9bf053c59e5af1a0106eae6src/proxy-capture/ca.ts: old728dafd2fb2f7b7bf0edaf8882bb51f85be02862= current728dafd2fb2f7b7bf0edaf8882bb51f85be02862src/proxy-capture/proxy-server.managed-proxy.test.ts: oldbd95a425b14dab59995cd4b44b949112696d5cbc= currentbd95a425b14dab59995cd4b44b949112696d5cbcsrc/proxy-capture/proxy-server.test.ts: old10b6bab842059ab5f2a62fee344bf9094370e1ec= current10b6bab842059ab5f2a62fee344bf9094370e1ecensureDebugProxyCa->runExec-> real OpenSSL: timeout around 30 seconds left no partial pair/orphan process, and a retry produced a valid matching CA/key pair. All changed files are byte-identical at the current head, so the runtime result transfers without a runtime diff.PROOF_RESULT=PASS(4/4 changed files identical).Current-head proof continuity (verified import-only rebase delta, 2026-07-27)
fbdeb307505142d8c9fda5b487ff8227b79131d4.7be2615a6d10c0bda16612ca27961a1414f5721f, which already bridges to the real OpenSSL production-run head5446b8da419eb41661b9bc4e22d8ab8fb4d12999.src/proxy-capture/ca.ts: the rebase changes the self-package SDK specifier to the repository-relative SDK specifier required by current main.src/plugin-sdk/keyed-async-queue.ts; that module has the same blob ID at both heads:0c4aca8ef10c5e959ce4f0e4ec4897ce2aab2dcc. All CA timeout, locking, staged-publication, validation, and retry code is unchanged.PROOF_RESULT=PASS.Exact-head maintenance refresh (2026-08-07)
7275badda20905bbd08a4897c4530acd3a90288b, rebased once immediately before publication ontoa672065d5e5539331960e1671db3655fba421e4a.ensureDebugProxyCais the lifecycle owner shared by the proxy server, proxy CLI, and CA-install script. Caller-side guards would leave generation broken; the sibling Gateway TLS path has different no-clobber publication semantics and is not a reusable replacement./usr/bin/openssl(LibreSSL 3.3.6) rejected the empty[subject]section withno objects specified in config file. The explicit config now ownsCN = OpenClaw Debug Proxy, and the duplicate-subjarguments are removed.CN=OpenClaw Debug Proxy, withCA:TRUE, certificate-signing and CRL-signing usage, and a public key matching the generated private key. This is a new real LibreSSL generation probe, not a new timeout injection.ensureDebugProxyCa->runExec-> OpenSSL timeout, staged-output cleanup, orphan absence, and successful retry. The maintenance delta changes only how the same subject is supplied to OpenSSL and adds its regression assertion; no new Linux timeout run is claimed.@openclaw/fs-safe0.5.2 source.patch is correct, confidence0.98).git diff --check origin/main...HEADpassed.openclaw/ci-gatejob.