openclaw - ✅(Solved) Fix [Bug]: Validation Failure when Using exec with host=node and cwd is Omitted (Gateway Path Inheritance) [1 pull requests, 1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openclaw/openclaw#58934Fetched 2026-04-08 02:31:01
View on GitHub
Comments
1
Participants
2
Timeline
17
Reactions
0
Author
Participants
Timeline (top)
referenced ×9labeled ×2renamed ×2closed ×1

When using exec with host=node, if the model/tool call does not explicitly set cwd, OpenClaw still derives a default working directory from the gateway runtime context. In cross-platform setups (e.g., gateway on WSL/Linux, node on Windows), that gateway path often does not exist on the node, causing node-side approval validation to fail with:

SYSTEM_RUN_DENIED: approval requires an existing canonical cwd

PR #50961 fixed the explicit-cwd path preservation issue, but this default-cwd behavior remains.

Root Cause

When using exec with host=node, if the model/tool call does not explicitly set cwd, OpenClaw still derives a default working directory from the gateway runtime context. In cross-platform setups (e.g., gateway on WSL/Linux, node on Windows), that gateway path often does not exist on the node, causing node-side approval validation to fail with:

SYSTEM_RUN_DENIED: approval requires an existing canonical cwd

PR #50961 fixed the explicit-cwd path preservation issue, but this default-cwd behavior remains.

Fix Action

Fix / Workaround

PR fix notes

PR #50961: fix(gateway): skip local workdir resolution for remote node execution

Description (problem / solution / changelog)

Summary

  • Problem: When executing remote commands with host=node in a multi-user setup (e.g., Linux gateway to macOS node), the execution fails with exec INVALID_REQUEST: SYSTEM_RUN_DENIED: approval requires canonical cwd (no symlink cwd). This happens even if the working directory on the node is a valid absolute path. The issue originates in src/agents/bash-tools.exec.ts around line 361.
  • Root Cause: The gateway incorrectly applies resolveWorkdir() to the host=node request. resolveWorkdir() uses fs.statSync() to verify if the directory exists on the local gateway filesystem. Since the remote node's path (e.g., /Users/vv) doesn't exist on the Linux gateway, it falls back to the gateway's local process.cwd() or homedir(). This incorrect fallback path is then sent to the remote node, which subsequently fails the strict resolveCanonicalApprovalCwdSync checks during the approval phase on the node side.
  • Fix: Modified the else branch in src/agents/bash-tools.exec.ts to else if (host !== "node"). This prevents the gateway from attempting to resolve and validate the working directory locally when the target host is a remote node. The node is now responsible for resolving and validating its own cwd, which is the correct architectural behavior. This fix completely avoids side effects because it only changes the behavior for host=node, leaving host=gateway and host=sandbox paths untouched.
  • What changed:
    • src/agents/bash-tools.exec.ts: Added if (host !== "node") condition before calling resolveWorkdir(rawWorkdir, warnings).
  • What did NOT change (scope boundary):
    • No changes were made to how host=gateway or host=sandbox resolve their working directories.
    • No changes were made to the node-side approval logic (resolveCanonicalApprovalCwdSync); the strict security checks on the node remain fully intact.

Reproduction

  1. Setup an OpenClaw architecture with a Linux Gateway and a macOS Node.
  2. Connect the macOS node to the gateway.
  3. Run a command targeting the node: openclaw nodes run --node --cwd /Users/username -- /usr/bin/pwd
  4. Before this PR, it fails with the canonical cwd error. With this PR, it executes successfully and returns the correct path.

Risk / Mitigation

  • Risk: Low. The change is highly localized to the host=node condition in the exec tool.
  • Mitigation: The strict canonical cwd checks on the node side (src/node-host/invoke-system-run-plan.ts) are left untouched, ensuring that security boundaries are maintained at the execution endpoint. The change simply ensures the correct path is passed to those checks.

Change Type (select all)

  • Bug fix

Scope (select all touched areas)

  • Gateway / orchestration

Linked Issue/PR

Fixes #50783

AI-Assisted Contribution

  • AI Usage: This PR was developed with AI assistance.
  • Human Review: I have personally reviewed, designed, and fully understand all the code changes.
  • Testing: Fully tested locally with my OpenClaw instance.

Changed files

  • CHANGELOG.md (modified, +1/-0)
  • src/agents/bash-tools.exec.approval-id.test.ts (modified, +34/-0)
  • src/agents/bash-tools.exec.ts (modified, +4/-1)
RAW_BUFFERClick to expand / collapse

Bug type

Behavior bug (incorrect output/state without crash)

Beta release blocker

No

Summary

When using exec with host=node, if the model/tool call does not explicitly set cwd, OpenClaw still derives a default working directory from the gateway runtime context. In cross-platform setups (e.g., gateway on WSL/Linux, node on Windows), that gateway path often does not exist on the node, causing node-side approval validation to fail with:

SYSTEM_RUN_DENIED: approval requires an existing canonical cwd

PR #50961 fixed the explicit-cwd path preservation issue, but this default-cwd behavior remains.

Steps to reproduce

  1. Set up a cross-platform deployment:
  • Gateway: WSL/Linux
  • Node host: Windows (paired and supports system.run)
  1. Configure exec to run on node (tools.exec.host=node) and ensure approvals/security allow execution.

  2. Trigger an exec run via model where workdir/cwd is not explicitly provided (default behavior).

  3. Run any simple command on node (for example ipconfig or whoami).

  4. Observe that execution fails with: INVALID_REQUEST: SYSTEM_RUN_DENIED: approval requires an existing canonical cwd

Expected behavior

For host=node, when cwd is omitted:

  • OpenClaw should not inject gateway-local cwd as node cwd.
  • It should either:
  1. Let node use its own default working directory, or
  2. Use a node-specific configured default cwd.

Actual behavior

When cwd is omitted for host=node, OpenClaw uses gateway-derived default cwd. In cross-platform environments this path may not exist on node, and node-side canonical cwd validation fails with: SYSTEM_RUN_DENIED: approval requires an existing canonical cwd

OpenClaw version

v2026.3.28

Operating system

Windows11 & WSL2

Install method

npm global

Model

Any

Provider / routing chain

openclaw -> OpenAI

Additional provider/model setup details

No response

Logs, screenshots, and evidence

Impact and severity

No response

Additional information

extent analysis

TL;DR

To fix the issue, explicitly set the cwd parameter when using exec with host=node to avoid OpenClaw deriving a default working directory from the gateway runtime context.

Guidance

  • When using exec with host=node, ensure that the cwd parameter is explicitly set to a valid path on the node to prevent the default gateway-derived path from being used.
  • Verify that the node-side approval validation succeeds by checking the execution logs for the absence of the SYSTEM_RUN_DENIED: approval requires an existing canonical cwd error.
  • Consider implementing a node-specific configured default cwd as a fallback when cwd is omitted for host=node.
  • Review the local hotfix/workaround documented here (Fix 2) for an alternative solution that requires extra config options.

Example

No code snippet is provided as the issue does not require a specific code change, but rather a configuration adjustment.

Notes

The provided fix is specific to the scenario where cwd is omitted for host=node and may not address all possible use cases. The related fix [#50961] only addresses explicit cwd preservation and does not fully resolve the issue.

Recommendation

Apply workaround: Explicitly set the cwd parameter when using exec with host=node to ensure a valid path on the node is used, as this is a straightforward and effective solution to the problem.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

FAQ

Expected behavior

For host=node, when cwd is omitted:

  • OpenClaw should not inject gateway-local cwd as node cwd.
  • It should either:
  1. Let node use its own default working directory, or
  2. Use a node-specific configured default cwd.

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING