Commit 9a3b437
authored
Fix: Improve daemon startup reliability and add secrets-in-args audit check (#75)
* fix: daemon silent death after fork + add secrets-in-process-args audit
Fix two issues reported by OpenClaw customers:
1. Daemon process dies silently after fork with no logs or error output.
The child was forked with stdio:'ignore', so any errors during module
loading or config parsing were swallowed. Now:
- stdout/stderr redirect to daemon-startup.log before logger init
- IPC channel detects child readiness or early exit
- uncaughtException/unhandledRejection handlers installed before main()
- forkDaemon reports startup log contents on failure
2. Container secrets visible via `ps aux` (new check OC-H-064).
When containers are started with `docker run -e SECRET=value`, the
secret is visible to any process on the host via /proc/*/cmdline.
The new audit check flags sensitive env vars passed inline and
recommends Docker secrets, --env-file, or mounted files instead.
* chore: update package-lock.json after npm install
* fix: ensure ~/.g0 directory exists before opening startup log
forkDaemon() opens the startup log file before writePid() creates the
directory. If ~/.g0/ doesn't exist yet (e.g. first run without prior
saveDaemonConfig call), fs.openSync would fail with ENOENT.
* fix: harden daemon startup, improve secret detection, update docs
Daemon robustness (process.ts, runner.ts):
- resolveRunnerPath() now throws with searched paths instead of silently
returning a non-existent path that causes a cryptic fork failure
- Startup log truncated on each start (mode 'w') with 0o600 permissions
to prevent unbounded growth and restrict access
- FD leak fixed: startupLogFd is now closed if writePid() throws
- Extracted settle() helper to deduplicate event handler cleanup logic
- Signal handlers (SIGTERM/SIGINT) registered before IPC ready signal
so a kill during initialization triggers graceful shutdown
Secret detection (openclaw-deployment.ts, OC-H-064):
- Added missing sensitive patterns: AWS_SECRET, GOOGLE_APPLICATION_CREDENTIALS,
PASSPHRASE, OAUTH_CLIENT_SECRET, HMAC, JWT_SECRET
- Added exact-match token patterns (_TOKEN$, TOKEN$) to catch GITHUB_TOKEN,
GH_TOKEN etc. without false-positiving on TOKEN_ENDPOINT
- Expanded safe patterns: AUTHORIZATION_TYPE, AUTH_TYPE, TOKEN_URL,
TOKEN_ISSUER, TOKEN_VALIDITY, REFRESH_TOKEN_ENDPOINT, etc.
- DATABASE_URL only flagged when it contains embedded credentials (user:pass@)
Documentation (openclaw-deployment-guide.md):
- Added OC-H-064 to the container deep audit table (now 36 checks)
- Added "Never Pass Secrets via -e Flags" section with good/bad examples
- Added "Daemon won't stay alive" troubleshooting section with
startup log, common causes, and verification steps
* chore: bump version to 1.5.0
- package.json and package-lock.json version bump
- CHANGELOG.md entry for v1.5.0 (daemon fixes, OC-H-064)
- Updated version references in evidence-collector test and docs
* fix: restore tree-sitter entry in package-lock.json
npm ci on CI was failing because the node_modules/tree-sitter@0.21.1
entry was missing from the lock file. The language-specific parsers
(tree-sitter-python, etc.) were present but the base tree-sitter
package was stripped by npm install on a machine without native build
tools. Restored the entry from main.1 parent dcf4de8 commit 9a3b437
12 files changed
Lines changed: 385 additions & 272 deletions
File tree
- docs
- src
- cli/commands
- daemon
- mcp
- reporters
- tests/unit
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
8 | 22 | | |
9 | 23 | | |
10 | 24 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
37 | | - | |
| 37 | + | |
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
| |||
70 | 70 | | |
71 | 71 | | |
72 | 72 | | |
73 | | - | |
| 73 | + | |
74 | 74 | | |
75 | 75 | | |
76 | 76 | | |
| |||
96 | 96 | | |
97 | 97 | | |
98 | 98 | | |
99 | | - | |
| 99 | + | |
100 | 100 | | |
101 | 101 | | |
102 | 102 | | |
| |||
110 | 110 | | |
111 | 111 | | |
112 | 112 | | |
| 113 | + | |
113 | 114 | | |
114 | 115 | | |
115 | 116 | | |
| |||
427 | 428 | | |
428 | 429 | | |
429 | 430 | | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
430 | 459 | | |
431 | 460 | | |
432 | 461 | | |
| |||
1357 | 1386 | | |
1358 | 1387 | | |
1359 | 1388 | | |
| 1389 | + | |
| 1390 | + | |
| 1391 | + | |
| 1392 | + | |
| 1393 | + | |
| 1394 | + | |
| 1395 | + | |
| 1396 | + | |
| 1397 | + | |
| 1398 | + | |
| 1399 | + | |
| 1400 | + | |
| 1401 | + | |
| 1402 | + | |
| 1403 | + | |
| 1404 | + | |
| 1405 | + | |
| 1406 | + | |
| 1407 | + | |
| 1408 | + | |
| 1409 | + | |
| 1410 | + | |
| 1411 | + | |
| 1412 | + | |
| 1413 | + | |
| 1414 | + | |
| 1415 | + | |
1360 | 1416 | | |
1361 | 1417 | | |
1362 | 1418 | | |
| |||
1396 | 1452 | | |
1397 | 1453 | | |
1398 | 1454 | | |
1399 | | - | |
| 1455 | + | |
1400 | 1456 | | |
1401 | 1457 | | |
1402 | 1458 | | |
| |||
0 commit comments