NemoClaw icon indicating copy to clipboard operation
NemoClaw copied to clipboard

[macOS][CLI] nemoclaw config set accepts arbitrary --key paths and writes garbage to openclaw config

Open zNeill opened this issue 7 months ago • 2 comments

Description

Description

`nemoclaw  config set --key  --value ` accepts ANY key path
without validation and writes garbage nodes into the openclaw config tree. There is no
schema check against the known config surface; the pre-step validation described in
DevTest tasks 489884 / 497386 ("Key-path validation runs FIRST: --key invalid.path is
rejected with a clear error before the SSRF URL validator ever runs") is not implemented.
Environment
Device:        MacBook Pro (Apple M3 Pro, 36GB)
OS:            macOS Darwin 25.3.0 (arm64)
Architecture:  arm64
Node.js:       v24.5.0
npm:           10.9.7
Docker:        Docker Desktop / colima
OpenShell CLI: openshell 0.0.26
NemoClaw:      v0.0.21
OpenClaw:      2026.4.2 (d74a122)
Steps to Reproduce
1. Onboard a sandbox (e.g. `my-assistant`) with any provider
2. Run: `nemoclaw my-assistant config set --key invalid.path --value foo`
3. Run: `nemoclaw my-assistant config get` and grep for "invalid"
Expected Result
1. Command exits non-zero with a clear error message,
   e.g. "Invalid key path 'invalid.path' — allowed keys: agents.*, models.*, channels.*, update.*, ..."
2. Nothing is written to openclaw config
3. The SSRF URL validator never runs because the key-path validator short-circuits first
Actual Result
$ nemoclaw my-assistant config set --key invalid.path --value foo
  Reading openclaw config...
  Agent:     openclaw
  Key:       invalid.path
  Old value: (not set)
  New value: "foo"
  Writing config to sandbox (/sandbox/.openclaw/openclaw.json)...
  openclaw config updated.

  Note: Some config changes require a sandbox restart to take effect.
EXIT=0

$ nemoclaw my-assistant config get | grep -A1 invalid
  "invalid": {
    "path": "foo"

The garbage path persists across restarts and accumulates over time. Repeated runs
show "Old value: \"foo\"" confirming the bad data survives.

NOTE: This invalid config also breaks the agent at runtime — when openclaw tries to
load /sandbox/.openclaw/openclaw.json with the invalid key, the agent rejects the
config with: "Invalid config at /sandbox/.openclaw/openclaw.json: - : Unrecognized
key: \"invalid\"" and refuses to start. doctor --fix cannot recover (EACCES — file is 444).
Logs
$ nemoclaw my-assistant config set --key invalid.path --value foo
  Reading openclaw config...
  Agent:     openclaw
  Key:       invalid.path
  Old value: (not set)
  New value: "foo"
  Writing config to sandbox (/sandbox/.openclaw/openclaw.json)...
  openclaw config updated.

(Later, when openclaw agent starts:)
Invalid config at /sandbox/.openclaw/openclaw.json:
- : Unrecognized key: "invalid"
Run: openclaw doctor --fix
Notes
- Same codepath correctly rejects SSRF URLs (169.254.169.254, localhost, 192.168.x.x)
  when the key is `models.providers.inference.baseUrl` — so validation CAN be wired in.

Bug Details

Field Value
Priority Unprioritized
Action Dev - Open - To fix
Disposition Open issue
Module Machine Learning - NemoClaw
Keyword NemoClaw, NemoClaw_CLI&UX, NEMOCLAW_GH_SYNC_APPROVAL, NemoClaw_Security

[NVB#6112256]

zNeill avatar Apr 28 '26 10:04 zNeill

This should already be covered by #2036 and its follow-up #2420.

laitingsheng avatar Apr 29 '26 04:04 laitingsheng

Already fixed on main via a two-stage rollout. Re-verified per [[nemoclaw-triage-before-repro]].

Root fix (2 PRs):

  1. #2036 (fix: reject unrecognized config paths in config set, merged 2026-04-22, commit 2c9c6b586e) — first-pass: isRecognizedConfigPath() made configSet() fail fast when the requested dotpath was not present in the current agent config. Cites "Fixes #2019" but the scope precisely covers this issue: config set was "accepting arbitrary dotpaths and writing them straight into openclaw.json ... easy to create config keys that OpenClaw does not recognize, which then breaks agent startup."
  2. #2420 (fix(cli): replace config-set allow-list with mode-based new-path gate, merged 2026-04-26, commit 7b76df6bdb) — iteration after #2400 reported the allow-list was too restrictive (rejected schema-valid first-time writes). Final form: existing keys go through, first-time writes prompt y/N interactively / refuse non-interactive (with --config-accept-new-path / NEMOCLAW_CONFIG_ACCEPT_NEW_PATH=1 opt-in override).

What ships today (#2420 on main):

  • src/lib/sandbox-config.ts: validateConfigDotpath helper enforces dotpath syntax + prototype-pollution segment block (__proto__, constructor, prototype, toString, hasOwnProperty).
  • configSet gates first-time writes: TTY prompt / non-TTY refuse / explicit override flag.
  • docs/reference/troubleshooting.md: documents the override + rationale.

Regression tests on main: test/config-set-nested-ssrf.test.ts:29 (existing-config-set SSRF enforcement) + the validateConfigDotpath syntax/prototype-pollution coverage.

The original symptom ("writes garbage to openclaw config") is no longer reachable: arbitrary dotpaths to new keys are blocked unless the user explicitly opts in.

Closing as fixed by #2036 + #2420. Reopen if nemoclaw <name> config set --key <bogus.path> --value foo on v0.0.50+ still silently writes to openclaw.json without prompt/refusal.

nvshaxie avatar Jun 10 '26 06:06 nvshaxie