Skip to content

Commit fd1662f

Browse files
authored
fix(cli): retire invalid secret flags and prove doctor recovery (#118926)
* test(qa): add doctor CLI recovery coverage * test(qa): secure doctor exec SecretRef proof * test(qa): gate doctor systemd recovery proof * test(qa): normalize doctor terminal output * test(qa): close doctor probe sockets * test(qa): classify doctor probe as foreign * test(qa): track doctor probe sockets * test(qa): retain doctor instance narrowing * test(qa): preserve observed doctor recovery proof * test(qa): keep doctor recovery on stable dist * test(qa): honor Windows exec ACL blocking * test(qa): use canonical home for systemd recovery * test(qa): follow bounded gateway recovery * test(qa): accept lifecycle service label * test(qa): align doctor recovery contract Punchcard-Session: crisp-lantern-orchard-nv * docs(secrets): remove retired provider bypasses Punchcard-Session: crisp-lantern-orchard-nv * test(qa): isolate doctor recovery target Punchcard-Session: crisp-lantern-orchard-nv * fix(cli): retire invalid secret provider flags Punchcard-Session: crisp-lantern-orchard-nv * test(qa): isolate doctor supervisor mode Punchcard-Session: crisp-lantern-orchard-nv * fix(plugins): remove dead secret path bypass Punchcard-Session: crisp-lantern-orchard-nv * chore: drop release-owned changelog entry Punchcard-Session: crisp-lantern-orchard-nv * test(qa): isolate doctor sudo scope Punchcard-Session: crisp-lantern-orchard-nv * fix(secrets): remove dead path bypass Punchcard-Session: crisp-lantern-orchard-nv * test(qa): isolate systemd user bus Punchcard-Session: crisp-lantern-orchard-nv
1 parent 0ef1911 commit fd1662f

21 files changed

Lines changed: 1330 additions & 72 deletions

‎docs/cli/config.md‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,6 @@ Provider builder targets must use `secrets.providers.<alias>` as the path.
229229
- `--provider-path <path>` (required)
230230
- `--provider-mode <singleValue|json>`
231231
- `--provider-max-bytes <bytes>`
232-
- `--provider-allow-insecure-path`
233232

234233
</Accordion>
235234
<Accordion title="Exec provider (--provider-source exec)">
@@ -241,8 +240,6 @@ Provider builder targets must use `secrets.providers.<alias>` as the path.
241240
- `--provider-env <KEY=VALUE>` (repeatable)
242241
- `--provider-pass-env <ENV_VAR>` (repeatable)
243242
- `--provider-trusted-dir <path>` (repeatable)
244-
- `--provider-allow-insecure-path`
245-
- `--provider-allow-symlink-command`
246243

247244
</Accordion>
248245
</AccordionGroup>

‎docs/cli/secrets.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ Notes:
117117

118118
### Exec provider safety
119119

120-
Homebrew installs often expose symlinked binaries under `/opt/homebrew/bin/*`. Set `allowSymlinkCommand: true` only when needed for trusted package-manager paths, paired with `trustedDirs` (for example `["/opt/homebrew"]`). On Windows, if ACL verification is unavailable for a provider path, OpenClaw fails closed; for trusted paths only, set `allowInsecurePath: true` on that provider to bypass the path security check.
120+
Package managers often expose symlinked command paths. Resolve the real binary path (for example with `realpath "$(command -v vault)"`) and configure that absolute, non-symlink path; use `trustedDirs` to restrict executables to approved directories. On Windows, provider paths fail closed when ACL verification is unavailable, with no provider-level bypass.
121121

122122
## Apply a saved plan
123123

‎docs/gateway/configuration-reference.md‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1169,10 +1169,10 @@ Validation:
11691169
Notes:
11701170

11711171
- `file` provider supports `mode: "json"` and `mode: "singleValue"` (`id` must be `"value"` in singleValue mode).
1172-
- File and exec provider paths fail closed when Windows ACL verification is unavailable. Set `allowInsecurePath: true` only for trusted paths that cannot be verified.
1172+
- File and exec provider paths fail closed when Windows ACL verification is unavailable. Use paths whose ACLs OpenClaw can verify; there is no provider-level bypass.
11731173
- `exec` provider requires an absolute `command` path and uses protocol payloads on stdin/stdout.
1174-
- By default, symlink command paths are rejected. Set `allowSymlinkCommand: true` to allow symlink paths while validating the resolved target path.
1175-
- If `trustedDirs` is configured, the trusted-dir check applies to the resolved target path.
1174+
- Symlink command paths are rejected. Configure the resolved absolute binary path instead.
1175+
- If `trustedDirs` is configured, the command path must be inside an approved directory.
11761176
- `exec` child environment is minimal by default; pass required variables explicitly with `passEnv`.
11771177
- Secret refs are resolved at activation time into an in-memory snapshot, then request paths read the snapshot only.
11781178
- Active-surface filtering applies during activation: unresolved refs on enabled surfaces fail startup/reload, while inactive surfaces are skipped with diagnostics.

‎docs/gateway/secrets.md‎

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -206,16 +206,16 @@ Define providers under `secrets.providers`:
206206
- `mode: "json"` (default) expects a JSON object payload and resolves `id` as a JSON pointer.
207207
- `mode: "singleValue"` expects ref id `"value"` and returns the raw file contents (trailing newline stripped).
208208
- Path must pass ownership/permission checks; `timeoutMs` (default 5000) and `maxBytes` (default 1 MiB) bound the read.
209-
- Windows fail-closed: if ACL verification is unavailable for the path, resolution fails. For trusted paths only, set `allowInsecurePath: true` on that provider to bypass the check.
209+
- Windows fail-closed: if ACL verification is unavailable for the path, resolution fails. Move the secret to a path whose ACLs OpenClaw can verify; there is no provider-level bypass.
210210

211211
</Accordion>
212212

213213
<Accordion title="Exec provider">
214214
- Runs the configured absolute binary path directly, no shell.
215-
- By default `command` must be a regular file, not a symlink. Set `allowSymlinkCommand: true` to allow symlink command paths (for example Homebrew shims), and pair it with `trustedDirs` (for example `["/opt/homebrew"]`) so only package-manager paths qualify.
215+
- `command` must be a regular file, not a symlink. For package-manager shims, resolve the real binary path (for example with `realpath "$(command -v vault)"`) and configure that absolute path. Use `trustedDirs` to restrict executables to approved directories.
216216
- Supports `timeoutMs` (default 5000), `noOutputTimeoutMs` (default equals `timeoutMs`), `maxOutputBytes` (default 1 MiB), `env`/`passEnv` allowlist, and `trustedDirs`.
217217
- `jsonOnly` defaults to `true`. With `jsonOnly: false` and a single requested id, plain non-JSON stdout is accepted as that id's value.
218-
- Windows fail-closed: if ACL verification is unavailable for the command path, resolution fails. For trusted paths only, set `allowInsecurePath: true` on that provider to bypass the check.
218+
- Windows fail-closed: if ACL verification is unavailable for the command path, resolution fails. Use a command path whose ACLs OpenClaw can verify; there is no provider-level bypass.
219219
- Plugin-managed exec providers can use `pluginIntegration` instead of a copied `command`/`args`. OpenClaw resolves the current command details from the installed plugin manifest during startup/reload; if the plugin is disabled, removed, untrusted, or no longer declares the integration, active SecretRefs on that provider fail closed.
220220

221221
Request payload (stdin):
@@ -376,9 +376,8 @@ For a dedicated 1Password guide covering service accounts, the bundled agent ski
376376
providers: {
377377
vault_openai: {
378378
source: "exec",
379-
command: "/opt/homebrew/bin/vault",
380-
allowSymlinkCommand: true, // required for Homebrew symlinked binaries
381-
trustedDirs: ["/opt/homebrew"],
379+
command: "/absolute/non-symlink/path/to/vault",
380+
trustedDirs: ["/absolute/non-symlink/path/to"],
382381
args: ["kv", "get", "-field=OPENAI_API_KEY", "secret/openclaw"],
383382
passEnv: ["VAULT_ADDR", "VAULT_TOKEN"],
384383
jsonOnly: false,
@@ -484,9 +483,8 @@ For a dedicated 1Password guide covering service accounts, the bundled agent ski
484483
providers: {
485484
sops_openai: {
486485
source: "exec",
487-
command: "/opt/homebrew/bin/sops",
488-
allowSymlinkCommand: true, // required for Homebrew symlinked binaries
489-
trustedDirs: ["/opt/homebrew"],
486+
command: "/absolute/non-symlink/path/to/sops",
487+
trustedDirs: ["/absolute/non-symlink/path/to"],
490488
args: ["-d", "--extract", '["providers"]["openai"]["apiKey"]', "/path/to/secrets.enc.json"],
491489
passEnv: ["SOPS_AGE_KEY_FILE"],
492490
jsonOnly: false,

‎docs/plugins/manifest.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1145,7 +1145,7 @@ At startup/reload, OpenClaw resolves that provider by loading current plugin man
11451145

11461146
Only `source: "exec"` presets are currently supported. `command` must be `${node}`, and `args[0]` must be a `./` plugin-root-relative resolver script. OpenClaw materializes it at startup/reload to the current Node executable and the absolute in-plugin script path. Node options such as `--require`, `--import`, `--loader`, `--env-file`, `--eval`, and `--print` are not part of the manifest preset contract. Operators who need non-Node commands can configure standalone manual exec providers directly.
11471147

1148-
OpenClaw derives `trustedDirs` for manifest presets from the plugin root and, for `${node}` presets, the current Node executable directory. Manifest-authored `trustedDirs` are ignored. Other exec provider options such as `timeoutMs`, `noOutputTimeoutMs`, `maxOutputBytes`, `jsonOnly`, `env`, `passEnv`, and `allowInsecurePath` pass through to the normal SecretRef exec provider config.
1148+
OpenClaw derives `trustedDirs` for manifest presets from the plugin root and, for `${node}` presets, the current Node executable directory. Manifest-authored `trustedDirs` are ignored. Other exec provider options such as `timeoutMs`, `noOutputTimeoutMs`, `maxOutputBytes`, `jsonOnly`, `env`, and `passEnv` pass through to the normal SecretRef exec provider config.
11491149

11501150
## modelPricing reference
11511151

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
title: Doctor auth and SecretRef checks
2+
3+
scenario:
4+
id: doctor-auth-secretref-checks
5+
surface: runtime
6+
category: cli.doctor
7+
coverage:
8+
primary:
9+
- cli.auth-and-secretref-checks
10+
objective: Prove that the real doctor CLI validates gateway SecretRefs without leaking, replacing, or silently bypassing configured credentials.
11+
successCriteria:
12+
- A resolved environment SecretRef passes doctor validation without exposing its value.
13+
- An unresolved SecretRef remains configured and ambient gateway token fallback cannot mask the failure.
14+
- Exec SecretRefs remain gated unless the operator explicitly passes --allow-exec; Windows then proves the current fail-closed ACL diagnostic without executing or leaking the secret.
15+
- Explicit token generation persists a new token only when no SecretRef owns the field.
16+
docsRefs:
17+
- docs/cli/doctor.md
18+
- docs/gateway/secrets.md
19+
codeRefs:
20+
- src/flows/doctor-health-contributions.ts
21+
- src/commands/doctor-gateway-health.ts
22+
- test/e2e/qa-lab/runtime/doctor-auth-secretref-checks.e2e.test.ts
23+
execution:
24+
kind: vitest
25+
path: test/e2e/qa-lab/runtime/doctor-auth-secretref-checks.e2e.test.ts
26+
summary: Run the real doctor CLI across resolved, unresolved, fallback, exec-gated, and generated-token auth states.
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
title: Doctor gateway startup recovery
2+
3+
scenario:
4+
id: doctor-gateway-startup-recovery
5+
surface: runtime
6+
category: cli.doctor
7+
coverage:
8+
primary:
9+
- cli.port-and-startup-diagnosis
10+
- cli.restart-guidance
11+
objective: Prove that the real doctor CLI diagnoses a foreign TCP listener and a systemd restart limit, then hands recovery to the explicit gateway restart command.
12+
successCriteria:
13+
- Doctor reports the configured gateway port when a real foreign TCP listener owns it.
14+
- Doctor recognizes a real failed systemd unit that exhausted StartLimitBurst and emits restart guidance.
15+
- Removing the test-owned crash override and running the guided gateway restart restores independently verified gateway status and health.
16+
- Cleanup removes the exact listener, unit override, installed profile service, and profile state.
17+
docsRefs:
18+
- docs/cli/doctor.md
19+
- docs/gateway/troubleshooting.md
20+
- docs/platforms/linux.md
21+
codeRefs:
22+
- src/commands/doctor-gateway-daemon-flow.ts
23+
- src/commands/doctor-format.ts
24+
- src/daemon/service-runtime.ts
25+
- test/e2e/qa-lab/runtime/doctor-gateway-startup-recovery.ts
26+
execution:
27+
kind: script
28+
path: test/e2e/qa-lab/runtime/doctor-gateway-startup-recovery.ts
29+
summary: On an explicitly enabled systemd host, exercise real TCP port ownership, a named-profile start limit, doctor guidance, explicit gateway restart, independent health verification, and exact-unit cleanup.
30+
allowBlockedEvidence: true
31+
timeoutMs: 480000
32+
args:
33+
- --artifact-base
34+
- ${outputDir}

‎src/cli/config-cli-input.ts‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,6 @@ function buildProviderFromBuilder(opts: ConfigSetOptions): SecretProviderConfig
232232
...(mode ? { mode } : {}),
233233
...(timeoutMs !== undefined ? { timeoutMs } : {}),
234234
...(maxBytes !== undefined ? { maxBytes } : {}),
235-
...(opts.providerAllowInsecurePath ? { allowInsecurePath: true } : {}),
236235
};
237236
} else {
238237
const command = opts.providerCommand?.trim();
@@ -254,8 +253,6 @@ function buildProviderFromBuilder(opts: ConfigSetOptions): SecretProviderConfig
254253
...(opts.providerTrustedDir?.length
255254
? { trustedDirs: normalizeStringEntries(opts.providerTrustedDir) }
256255
: {}),
257-
...(opts.providerAllowInsecurePath ? { allowInsecurePath: true } : {}),
258-
...(opts.providerAllowSymlinkCommand ? { allowSymlinkCommand: true } : {}),
259256
};
260257
}
261258

‎src/cli/config-cli.test.ts‎

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1765,6 +1765,8 @@ describe("config cli", () => {
17651765
expect(helpText).toContain("Strict JSON parsing (error instead of");
17661766
expect(helpText).toContain("--ref-provider");
17671767
expect(helpText).toContain("--provider-source");
1768+
expect(helpText).not.toContain("--provider-allow-insecure-path");
1769+
expect(helpText).not.toContain("--provider-allow-symlink-command");
17681770
expect(helpText).toContain("--batch-json");
17691771
expect(helpText).toContain("--dry-run");
17701772
expect(helpText).toContain("--allow-exec");
@@ -1944,6 +1946,27 @@ describe("config cli", () => {
19441946
});
19451947
});
19461948

1949+
it.each(["--provider-allow-insecure-path", "--provider-allow-symlink-command"])(
1950+
"rejects retired provider builder option %s",
1951+
async (option) => {
1952+
await expect(
1953+
runConfigCommand([
1954+
"config",
1955+
"set",
1956+
"secrets.providers.vaultfile",
1957+
"--provider-source",
1958+
"file",
1959+
"--provider-path",
1960+
"/tmp/vault.json",
1961+
option,
1962+
]),
1963+
).rejects.toThrow(`unknown option '${option}'`);
1964+
1965+
expect(mockReadConfigFileSnapshot).not.toHaveBeenCalled();
1966+
expect(mockWriteConfigFile).not.toHaveBeenCalled();
1967+
},
1968+
);
1969+
19471970
it("rejects exponent-style provider builder integer options", async () => {
19481971
await expect(
19491972
runConfigCommand([

‎src/cli/config-cli.ts‎

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -476,16 +476,6 @@ export function registerConfigCli(program: Command) {
476476
collectOption,
477477
[] as string[],
478478
)
479-
.option(
480-
"--provider-allow-insecure-path",
481-
"Provider builder (file|exec): bypass strict path permission checks",
482-
false,
483-
)
484-
.option(
485-
"--provider-allow-symlink-command",
486-
"Provider builder (exec): allow command symlink path",
487-
false,
488-
)
489479
.option("--batch-json <json>", "Batch mode: JSON array of set operations")
490480
.option("--batch-file <path>", "Batch mode: read JSON array of set operations from file")
491481
.action(async (path: string | undefined, value: string | undefined, opts: ConfigSetOptions) => {

0 commit comments

Comments
 (0)