Skip to content

fix(tls): bound self-signed certificate generation - #109139

Merged
steipete merged 8 commits into
openclaw:mainfrom
Alix-007:alix/gateway-tls-generation-timeout
Jul 21, 2026
Merged

steipete merged 8 commits into
openclaw:mainfrom
Alix-007:alix/gateway-tls-generation-timeout

Conversation

@Alix-007

@Alix-007 Alix-007 commented Jul 16, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Automatic Gateway TLS setup runs openssl req when no certificate/key exists. The old path had no timeout and wrote directly to configured final paths, so a stalled or interrupted process could block startup indefinitely or leave partial certificate material.

Why This Change Was Made

This branch now implements the maintainer-decided best-effort policy:

  • bound OpenSSL generation to 30 seconds through the existing runExec lifecycle;
  • generate and validate the certificate/key pair in private staging directories;
  • publish with atomic no-overwrite hard links when the filesystem supports them;
  • when hard links are unsupported (ENOTSUP, EOPNOTSUPP, or EPERM), publish through exclusive wx file handles instead of blocking startup;
  • emit one typed [GATEWAY_TLS_DEGRADED] warning with gateway:tls owner metadata when best-effort publication is used.

There is no new config, environment variable, dependency, migration, protocol, or schema surface. CHANGELOG.md is unchanged.

User Impact

A stalled OpenSSL process no longer hangs Gateway startup or writes into configured final paths. Filesystems without hard-link support continue startup with the generated TLS pair and one structured degradation warning.

The non-atomic fallback deliberately does not delete final pathnames on failure because another process may replace them. A failed best-effort write can therefore leave an attempt-owned partial file for operator cleanup; this is the explicit availability-over-atomicity tradeoff selected for this path.

Release-note context: Gateway self-signed TLS generation is now bounded and staged, and unsupported hard-link filesystems use a warned best-effort fallback. Original fix by @Alix-007.

Evidence

  • Exact current head: 5d3ca4adc51e657f0255d5fdce09c694dce0e17a, rebased onto current main before push.
  • mise exec [email protected] -- node scripts/run-vitest.mjs src/infra/tls/gateway.test.ts: 11/11 passed on the exact rebased tree.
  • Source-blind contract probe for publishes best-effort and warns once when hard links are unavailable: 1/1 passed; the harness asserts enabled TLS, private final files, and exactly one typed diagnostic for ENOTSUP.
  • OPENCLAW_CHECK_CHANGED_REMOTE_CHILD=1 OPENCLAW_CHANGED_LANES_RAW_SYNC=1 CI=1 node scripts/check-changed.mjs -- src/infra/tls/gateway.ts src/infra/tls/gateway.test.ts under Node 24.18.0: core and core-test typechecks, targeted lint/format, import cycles, dependency/patch guards, and repository guards passed.
  • Blacksmith Testbox warmup timed out three times before allocation. AWS Crabbox run_e694396eb80f / cbx_c81aecb18d7d reached the check command but the raw synced workspace intentionally had no .git, so its conflict-marker guard could not run; the lease stopped cleanly. The trusted-source local fallback above supplied the complete changed gate.
  • AutoReview secret scanning is clean. Two deletion/rollback findings were accepted as real risks but consciously rejected as contrary to the maintainer-decided best-effort policy; the fallback uses an exclusive handle and performs no pathname cleanup that could delete concurrent operator material.
  • Dependency contracts checked against Node 24 fs documentation (wx/exclusive creation and copy cleanup behavior), Execa 9.6.1 timeout semantics, OpenClaw runExec, and the sibling backup publication patterns.

AI-assisted: yes. Final implementation and evidence were maintainer-reviewed.

@clawsweeper clawsweeper Bot added 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. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. labels Jul 16, 2026
@clawsweeper

clawsweeper Bot commented Jul 16, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed July 20, 2026, 2:33 AM ET / 06:33 UTC.

Summary
The PR adds a 30-second bound to automatic Gateway TLS certificate generation and stages, validates, and no-overwrite publishes the generated certificate/key pair.

PR surface: Source +256, Tests +452, Docs +1. Total +709 across 3 files.

Reproducibility: yes. for the proposed branch: the supplied redacted live run exercises the production TLS loader with a controlled stalled OpenSSL child, then verifies timeout cleanup and retry. I could not independently rerun that path against the checkout because the read-only command runner was unavailable.

Review metrics: none identified.

Stored data model
Persistent data-model change detected: serialized state: src/infra/tls/gateway.test.ts. Confirm migration or upgrade compatibility proof before merge.

Merge readiness
Overall: 🦞 diamond lobster
Proof: 🦞 diamond lobster
Patch quality: 🦞 diamond lobster
Result: ready for maintainer review.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Risk before merge

  • [P1] The change alters the failure mode of automatic TLS generation from an unbounded wait to a bounded startup failure; maintainers should retain the existing user-facing error path and confirm the no-overwrite publication behavior remains supported on the filesystem/platforms OpenClaw supports.

Maintainer options:

  1. Confirm supported-filesystem behavior (recommended)
    Merge after maintainer review verifies that the staged no-overwrite publication path preserves successful TLS setup on the supported local filesystem targets.
  2. Accept the bounded-failure tradeoff
    Accept a 30-second TLS-generation failure as the intended safer alternative to an indefinitely blocked Gateway startup when the publication path is supported.

Next step before merge

  • [P2] No discrete repair is identified; the remaining action is ordinary maintainer review of the current PR head and its supported-platform compatibility.

Security
Cleared: The reviewed diff uses the existing OpenSSL execution path and Node filesystem APIs to reduce partial private-key/certificate artifacts; no new dependency, secret, permission, workflow, or supply-chain concern is evident from the provided patch context.

Review details

Best possible solution:

Land the bounded, staged publication path after normal maintainer review confirms its supported-filesystem behavior and the exact reviewed head remains the one being merged.

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

Yes for the proposed branch: the supplied redacted live run exercises the production TLS loader with a controlled stalled OpenSSL child, then verifies timeout cleanup and retry. I could not independently rerun that path against the checkout because the read-only command runner was unavailable.

Is this the best way to solve the issue?

Yes, based on the supplied evidence: keeping OpenSSL writes out of the configured final paths and publishing only a validated pair is safer than timing out direct writes. The remaining maintainer check is supported-filesystem compatibility, not a competing product direction.

AGENTS.md: unclear because the file could not be read completely.

Codex review notes: model internal, reasoning high; reviewed against 6304a47762cc.

Label changes

Label justifications:

  • P2: This fixes a bounded Gateway startup reliability gap during optional automatic TLS generation without evidence of a broad current outage.
  • merge-risk: 🚨 compatibility: The PR changes generated TLS artifact publication semantics and should preserve successful setup across supported existing filesystem environments.
  • merge-risk: 🚨 availability: The PR changes Gateway startup behavior when OpenSSL stalls, replacing an indefinite wait with a bounded failure and retry path.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The PR body provides redacted after-fix production-path terminal output for a real OpenSSL timeout, cleanup, no-orphan check, and successful retry; the body also documents byte-identical runtime files on the current head.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body provides redacted after-fix production-path terminal output for a real OpenSSL timeout, cleanup, no-orphan check, and successful retry; the body also documents byte-identical runtime files on the current head.
Evidence reviewed

PR surface:

Source +256, Tests +452, Docs +1. Total +709 across 3 files.

View PR surface stats
Area Files Added Removed Net
Source 1 284 28 +256
Tests 1 459 7 +452
Docs 1 1 0 +1
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 3 744 35 +709

What I checked:

  • Real runtime proof: The PR body records a controlled stalled OpenSSL run through loadGatewayTlsRuntime and runExec: timeout at about 30 seconds left no configured final files or orphan OpenSSL processes, followed by a successful retry that produced the expected pair with a 0600 key. (src/infra/tls/gateway.ts, fa34186cfe67)
  • Exact-head continuity: The PR body states that src/infra/tls/gateway.ts and src/infra/tls/gateway.test.ts are byte-identical between the previously exercised runtime head and current head d000950b, with only CHANGELOG.md changed afterward. (src/infra/tls/gateway.ts, d000950b0a47)
  • Focused validation: The contributor reports the focused Gateway TLS test file passed 19/19 on the proven head, alongside targeted lint, format, and diff checks; current-head CI is reported successful in the PR body. (src/infra/tls/gateway.test.ts, fa34186cfe67)
  • Related execution-layer provenance: The merged process refactor introduced the canonical Execa-backed runExec layer that this PR uses for timeout and child-process handling; this PR is a narrow Gateway TLS follow-up rather than a duplicate of that refactor. (src/process/exec.ts, db02a96c4c7a)

Likely related people:

  • steipete: Authored the merged canonical runExec refactor and authored the later TLS hardening commits on this PR, making them the clearest historical routing contact for timeout/publication semantics. (role: related execution-layer author and recent TLS follow-up contributor; confidence: medium; commits: db02a96c4c7a, f01f2efaeb8c, d000950b0a47; files: src/process/exec.ts, src/infra/tls/gateway.ts)
  • Alix-007: Proposed the initial bounded-generation and staged-output implementation and supplied focused runtime proof, though current-main ownership was not independently inspectable in this read-only environment. (role: original TLS hardening contributor; confidence: low; commits: 7b9bfff20ebe, 320fd2cf025e; files: src/infra/tls/gateway.ts, src/infra/tls/gateway.test.ts)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

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.
Review history (10 earlier review cycles; latest 8 shown)
  • reviewed 2026-07-17T09:08:28.159Z sha 7a946f69f1985f10819161d30346213d6d109365 :: needs real behavior proof before merge. :: none
  • reviewed 2026-07-18T04:11:03.442Z sha fa34186cfe6766d4805ffc00392280cfcaaf92b1 :: needs maintainer review before merge. :: none
  • reviewed 2026-07-20T03:09:27.214Z sha 9e6dfa0689436aaf921f65b5e21074672904d10d :: needs real behavior proof before merge. :: none
  • reviewed 2026-07-20T03:24:25.463Z sha 8fe8a734d9ed7e2d65bb481a3bdd55390a780757 :: needs real behavior proof before merge. :: none
  • reviewed 2026-07-20T03:51:21.587Z sha b8674b3548e5cf5abdaf3ff4ea581d2959bdb2a2 :: needs real behavior proof before merge. :: none
  • reviewed 2026-07-20T04:12:49.818Z sha d000950b0a47418af62f924ea6fb9b05f01dc4f3 :: needs real behavior proof before merge. :: none
  • reviewed 2026-07-20T04:55:09.352Z sha d000950b0a47418af62f924ea6fb9b05f01dc4f3 :: needs real behavior proof before merge. :: none
  • reviewed 2026-07-20T05:50:35.464Z sha d000950b0a47418af62f924ea6fb9b05f01dc4f3 :: needs maintainer review before merge. :: none

@Alix-007
Alix-007 force-pushed the alix/gateway-tls-generation-timeout branch from f4c3f13 to 5a60a5c Compare July 17, 2026 04:53
@Alix-007

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

The partial-output finding is fixed on exact head 5a60a5c86e6e8bcf9f65234162781cc871e330dc:

  • OpenSSL receives only private sibling staging paths and has a 30-second runExec deadline;
  • the generated pair is validated and published with no-overwrite hard links;
  • failed publication rolls back only outputs whose file identity still belongs to this attempt;
  • focused Node 24.18.0 tests pass 11/11, and targeted type-aware oxlint, oxfmt, and diff checks pass;
  • fresh independent adversarial review found no actionable issue after checking the full module, callers, tests, and direct Execa/fs-safe contracts.

The PR body now contains exact-head real production-path proof. A controlled stalled OpenSSL run returned after 30,042 ms, left no configured final entries and no surviving OpenSSL process, then a second call on the same paths succeeded in 401 ms with the expected pair and a 0600 private key.

@clawsweeper

clawsweeper Bot commented Jul 17, 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 repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

Re-review progress:

@clawsweeper clawsweeper Bot added 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. and removed 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 Jul 17, 2026
@steipete
steipete force-pushed the alix/gateway-tls-generation-timeout branch from 5a60a5c to 965a011 Compare July 17, 2026 07:48
@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. 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. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Jul 17, 2026
@clawsweeper clawsweeper Bot added the rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. label Jul 20, 2026
@Alix-007
Alix-007 force-pushed the alix/gateway-tls-generation-timeout branch 2 times, most recently from b8674b3 to d000950 Compare July 20, 2026 04:09
@Alix-007

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jul 20, 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 repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

Re-review progress:

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed 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 Jul 20, 2026
@steipete steipete self-assigned this Jul 21, 2026
@steipete
steipete force-pushed the alix/gateway-tls-generation-timeout branch from d000950 to 016ae84 Compare July 21, 2026 03:48
Alix-007 and others added 8 commits July 21, 2026 08:45
Keep self-signed certificate generation bounded and staged, but fall back to exclusive best-effort writes when hard-link publication is unavailable. Emit a typed gateway TLS degradation warning and preserve startup availability on supported non-atomic filesystems.\n\nCo-authored-by: Alix-007 <[email protected]>
@steipete
steipete force-pushed the alix/gateway-tls-generation-timeout branch from 016ae84 to 5d3ca4a Compare July 21, 2026 15:46
@clawsweeper

clawsweeper Bot commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

ClawSweeper status: review started.

I am starting a fresh review of this pull request: fix(tls): bound self-signed certificate generation This is item 1/1 in the current shard. Shard 0/1.

This placeholder means the worker is alive and reading the current context. I will edit this same comment with the actual review when the claws are done clicking.

Crustacean status: shell secured, claws on keyboard, evidence pebbles being sorted.

@steipete

Copy link
Copy Markdown
Contributor

Land-ready proof for exact head 5d3ca4adc51e:

  • Reworked the branch to Peter's decided best-effort policy: 30-second bounded OpenSSL generation, private staging and pair validation, atomic hard links where supported, exclusive 0600 writes plus one typed gateway:tls degradation warning where hard links are unavailable.
  • Removed the fail-closed atomic recovery subsystem; final PR surface is +250/-35 across two files, down from +743/-35.
  • mise exec [email protected] -- node scripts/run-vitest.mjs src/infra/tls/gateway.test.ts: 11/11 passed.
  • Focused verbose ENOTSUP behavior contract: 1/1 passed, proving enabled TLS, private final files, and exactly one typed warning.
  • Node 24 node scripts/check-changed.mjs -- src/infra/tls/gateway.ts src/infra/tls/gateway.test.ts: core/core-test typechecks, targeted lint/format, import cycles, dependency/patch, schema/storage, and repository guards passed.
  • Required hosted CI is green on exact-head run 29845553508; openclaw/ci-gate passed.
  • Repo-native OPENCLAW_TESTBOX=1 scripts/pr prepare-run 109139 passed in hosted_exact_or_recent_parent mode and verified the remote PR tree matches the prepared head.
  • AutoReview secret scanning is clean. Its remaining two P2 rollback/partial-file suggestions were consciously rejected because they restore the stronger atomic recovery contract Peter explicitly declined; the accepted best-effort failure tradeoff is documented in code and the PR body.

Known proof gap: no real mounted filesystem without hard-link support was available, so the non-atomic branch uses the focused ENOTSUP filesystem mock. Blacksmith warmup timed out three times; AWS Crabbox run_e694396eb80f reached the gate but its raw sync lacked .git, so the trusted-source Node 24 local fallback supplied the complete changed checks. The AWS lease stopped cleanly.

Contributor credit is preserved with Co-authored-by: Alix-007 <[email protected]> and release-note context in the PR body. No changelog edit is required.

@steipete
steipete merged commit cdf69d9 into openclaw:main Jul 21, 2026
129 of 132 checks passed
@steipete

Copy link
Copy Markdown
Contributor

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 22, 2026
* fix(tls): bound self-signed certificate generation

* fix(tls): stage generated certificate material

* docs(changelog): note gateway TLS generation hardening

Co-authored-by: Alix-007 <[email protected]>

* fix(tls): make generated pair publication recoverable

Co-authored-by: Alix-007 <[email protected]>

* test(tls): narrow recovery directory fixture

* fix(tls): harden atomic certificate publication

* chore: drop PR changelog edit

Co-authored-by: Alix-007 <[email protected]>

* fix(tls): degrade atomic publication failures

Keep self-signed certificate generation bounded and staged, but fall back to exclusive best-effort writes when hard-link publication is unavailable. Emit a typed gateway TLS degradation warning and preserve startup availability on supported non-atomic filesystems.\n\nCo-authored-by: Alix-007 <[email protected]>

---------

Co-authored-by: Peter Steinberger <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. size: M status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants