You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 2b263ad
Browse filesBrowse the repository at this point in the historyBrowse files
fix(secrets): preflight exec provider command paths before config acceptance (#117128)
* fix(secrets): preflight exec provider command paths before config acceptance
Schema validation and config writes accepted exec SecretRef command paths that
gateway cold start rejects (symlink, missing, unsafe permissions/ownership), so
a config that printed "Config valid" could crash the gateway on the next restart.
Share one non-executing exec-provider command-path validator
(`src/secrets/exec-provider-path-validation.ts`, extracted from `resolve.ts`
`assertSecurePath`) across cold-start activation, `openclaw config validate`, and
supported config writes so all three surfaces return the same verdict for manual
exec SecretRef providers.
- New `src/secrets/exec-provider-path-validation.ts` (`assertSecureExecCommandPath`);
`resolve.ts` imports and calls it, deleting the duplicated logic.
- `config validate` calls `collectManualExecProviderCommandPathErrors` with
`validateAllProviders: true` so the strict validation command checks every
configured manual exec provider. Config writes (`config set/patch/dry-run`)
use targeted preflight instead — they check only providers touched by the
operation, or all providers when the write edits the `secrets.providers`
collection itself — so an unrelated routine write is not blocked by a dormant
inactive provider that gateway startup would skip. A shared
`collectTouchedProviders` helper deduplicates the touch-collection logic this
function and `collectPluginIntegrationProviderErrors` both need.
- Guards against non-object provider values so a value-mode write setting a
provider to `null`/primitive no longer throws a raw TypeError.
- Docs aligned with the exact permission rule, symlink rejection, and that
`config validate` checks every provider while writes use targeted preflight.
The extracted validator stays at parity with current `resolve.ts` cold-start
activation: absolute path, non-symlink, trusted-directory containment,
non-writable-by-others permissions, current-user ownership, and Windows ACL
availability. It deliberately does not add a regular-file or owner-execute-bit
requirement, so cold start (which now calls the shared validator) does not grow
stricter and block existing configurations without an upgrade path. Tightening
the executable policy is upgrade-sensitive and left to maintainers (the issue
carries `needs-product-decision` / `needs-security-review`).
Scope is limited to manual exec SecretRef providers as reported in #117051.
Plugin-integration materialized-command parity, the deprecated `allowInsecurePath`
manifest field, `checks.schema` semantic widening, and dead CLI flag retirement
from earlier revisions are intentionally left out for the same boundary reason.
Closes#117051
* refactor(config): unify secret provider preflight and mutations
Share one provider issue collector and one set/patch/unset write lifecycle. Preserve validation JSON and targeted recovery, and carry provider metadata through patch deletions. Keep startup path policy unchanged.
Co-authored-by: SunnyShu0925 <[email protected]>
---------
Co-authored-by: Peter Steinberger <[email protected]>
Copy file name to clipboardExpand all lines: docs/cli/config.md
+12-1Lines changed: 12 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -114,11 +114,22 @@ machine-output spelling and keeps stdout reserved for the schema document.
114
114
115
115
Validates the current config against the active schema without starting the gateway. It also checks provider/source compatibility for every registry-declared SecretRef, including disabled plugin or channel configuration. This strict command can report an inactive mismatch that does not block normal Gateway startup, where SecretRef resolution remains limited to effectively active surfaces.
116
116
117
+
After schema validation, it checks every configured manual exec provider's command path using the same non-executing trust checks as startup: file presence, symlinks, trusted directories, permissions, ownership, and Windows ACL availability. `config set`, `config patch`, and `config unset` apply these checks only to providers changed or referenced by the operation, including during dry runs. Replacing the `secrets` or `secrets.providers` collection checks every remaining provider. An unrelated inactive provider does not block targeted repairs or removal of that provider.
118
+
119
+
Path validation does not execute providers or verify their output. Passing it does not guarantee successful secret resolution; exec dry runs require `--allow-exec` to test that separately.
120
+
117
121
```bash
118
122
openclaw config validate
119
123
openclaw config validate --json
120
124
```
121
125
126
+
<Note>
127
+
The exec-provider checks inspect the filesystem of the host where the CLI
128
+
runs. Run `config validate` on the gateway host itself (or on a host with
129
+
matching command paths, ownership, and ACLs). Paths and permissions can change
130
+
after validation; startup checks them again before execution.
131
+
</Note>
132
+
122
133
<Note>
123
134
If validation is already failing, start with `openclaw configure` or `openclaw doctor --fix`. `openclaw chat` does not bypass the invalid-config guard.
124
135
</Note>
@@ -364,7 +375,7 @@ openclaw config set channels.discord.token \
364
375
- Builder mode: runs SecretRef resolvability checks for changed refs/providers.
365
376
- JSON mode (`--strict-json`, `--json`, or batch mode): runs schema validation plus SecretRef resolvability checks.
366
377
- Policy validation runs against the full post-change config, so parent-object writes (for example setting `hooks` as an object) cannot bypass unsupported-surface validation.
367
-
- Exec SecretRef checks are skipped by default to avoid command side effects; pass `--allow-exec` to opt in (this may execute provider commands). `--allow-exec` is dry-run only and errors without `--dry-run`.
378
+
- Exec command-path trust checks run without executing providers. Exec SecretRef resolvability checks are skipped by default to avoid command side effects; pass `--allow-exec` to opt in (this may execute provider commands). `--allow-exec` is dry-run only and errors without `--dry-run`.
Copy file name to clipboardExpand all lines: docs/cli/secrets.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -217,7 +217,7 @@ Notes:
217
217
218
218
### Exec provider safety
219
219
220
-
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.
220
+
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. Run `openclaw config validate` on the Gateway host to check manual exec command paths without executing providers. On Windows, provider paths fail closed when ACL verification is unavailable, with no provider-level bypass.
Copy file name to clipboardExpand all lines: docs/gateway/configuration-reference.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1573,8 +1573,8 @@ Notes:
1573
1573
-`file` provider supports `mode: "json"` and `mode: "singleValue"` (`id` must be `"value"` in singleValue mode).
1574
1574
- 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.
1575
1575
-`exec` provider requires an absolute `command` path and uses protocol payloads on stdin/stdout.
1576
-
- Symlink command paths are rejected. Configure the resolved absolute binary path instead.
1577
-
- If `trustedDirs` is configured, the command path must be inside an approved directory.
1576
+
- Symlink command paths are rejected. Configure the resolved absolute binary path instead; it must not be group- or world-writable and, on POSIX, must be owned by the current user.
1577
+
- If `trustedDirs` is configured, the command path (after `~` expansion) must be inside an approved directory; symlinked commands are rejected before this check, so the configured path itself is what `trustedDirs` constrains.
1578
1578
-`exec` child environment is minimal by default; pass required variables explicitly with `passEnv`.
1579
1579
- Secret refs are resolved at activation time into an in-memory snapshot, then request paths read the snapshot only.
1580
1580
- Active-surface filtering applies during activation: unresolved refs on enabled surfaces fail startup/reload, while inactive surfaces are skipped with diagnostics.
Copy file name to clipboardExpand all lines: docs/gateway/secrets.md
+2-1Lines changed: 2 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -230,7 +230,8 @@ Provider aliases are source-specific. A matching explicit provider entry wins; i
230
230
231
231
<Accordiontitle="Exec provider">
232
232
- Runs the configured absolute binary path directly, no shell.
233
-
-`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.
233
+
-`command` must not be a symlink, must not be group- or world-writable, and on POSIX must be owned by the current user. 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.
234
+
-[`config validate`](/cli/config#config-validate) checks every manual exec command path without executing providers. Config writes and dry runs check only changed or newly referenced providers, so an unrelated inactive provider does not block repairs. These are path trust checks, not proof that a provider can execute or return a secret.
-`jsonOnly` defaults to `true`. With `jsonOnly: false` and a single requested id, plain non-JSON stdout is accepted as that id's value.
236
237
- 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.
0 commit comments