Skip to content

fix(node-host): allow absolute-path native binaries through approval binder#66731

Merged
obviyus merged 10 commits intoopenclaw:mainfrom
tmimmanuel:fix/node-host-absolute-binary-approval-binding
Apr 16, 2026
Merged

fix(node-host): allow absolute-path native binaries through approval binder#66731
obviyus merged 10 commits intoopenclaw:mainfrom
tmimmanuel:fix/node-host-absolute-binary-approval-binding

Conversation

@tmimmanuel
Copy link
Copy Markdown
Contributor

Summary

Fix the node-host approval binder so absolute-path native binaries are not rejected as unsafe interpreter/runtime commands.

Before this change, tools.exec with host=node could fail for commands like /usr/bin/whoami because the shell-payload binder treated any existing file at argv[0] as requiring stable script-style binding. That was correct for mutable scripts, but wrong for native binaries.

This patch keeps the fail-closed behavior for likely script files while allowing native executables through without requiring a mutable file operand.

Fixes #66524.

What changed

  • updated src/node-host/invoke-system-run-plan.ts
  • refined shellPayloadNeedsStableBinding() to distinguish:
    • script-like file payloads that should stay fail-closed
    • native binaries that should be allowed
  • added lightweight executable header detection for ELF, Mach-O, and PE/COFF
  • added regression tests in src/node-host/invoke-system-run-plan.test.ts for:
    • /bin/sh -lc /usr/bin/whoami succeeds
    • /bin/sh -lc <script-path> still fails closed

Why

The previous logic rejected all shell payloads whose first token resolved to an existing file, which unintentionally blocked absolute-path binaries on node hosts. The env /usr/bin/whoami workaround reported in #66524 demonstrated that the rejection was overly broad.

This change narrows the rejection surface to mutable script-like targets rather than all file-backed commands.

Risk

Low to medium.

The patch only affects the shell-payload stable-binding heuristic. It preserves the existing stricter behavior for script/interpreter cases and does not change allowlist, approval, or execution policy flows.

Testing

Added regression tests for:

  • absolute-path native binary payloads
  • script-path payloads that must remain fail-closed

Local verification:

  • git diff --check passed

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Apr 14, 2026

Greptile Summary

This PR narrows shellPayloadNeedsStableBinding so it only blocks shell payloads whose first token resolves to a script-like file — identified by shebang, empty content, or absence of null bytes — rather than any existing file. Native binaries are now allowed through via ELF/Mach-O/PE header detection, with a null-byte fallback that correctly handles unlisted binary formats (fat Mach-O, WASM, etc.). Fail-closed behavior is preserved for all script and ambiguous cases.

Confidence Score: 5/5

  • This PR is safe to merge — it narrows an overly broad rejection heuristic without relaxing the approval or allowlist policy flows.
  • All findings are P2 or lower. The header detection logic is correct for ELF, Mach-O, and PE; the null-byte fallback handles unlisted binary formats conservatively; fail-closed behavior is preserved for scripts, empty files, and read errors. The four new regression tests are well-structured and cover the key decision branches.
  • No files require special attention.

Reviews (2): Last reviewed commit: "test(node-host): use stable native binar..." | Re-trigger Greptile

Comment thread src/node-host/invoke-system-run-plan.ts Outdated
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3fce6fea6f

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread src/node-host/invoke-system-run-plan.ts Outdated
Comment thread src/node-host/invoke-system-run-plan.ts Outdated
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: dd8d73ded1

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread src/node-host/invoke-system-run-plan.ts Outdated
Comment thread src/node-host/invoke-system-run-plan.test.ts Outdated
@tmimmanuel tmimmanuel force-pushed the fix/node-host-absolute-binary-approval-binding branch from dd8d73d to 47b6e87 Compare April 14, 2026 18:44
@tmimmanuel
Copy link
Copy Markdown
Contributor Author

@greptileai

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 47b6e87ead

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread src/node-host/invoke-system-run-plan.ts Outdated
@tmimmanuel tmimmanuel force-pushed the fix/node-host-absolute-binary-approval-binding branch from 47b6e87 to 2985cec Compare April 14, 2026 18:58
@tmimmanuel
Copy link
Copy Markdown
Contributor Author

@obviyus Please review.

Copy link
Copy Markdown
Contributor

@obviyus obviyus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Root cause checks out.

shellPayloadNeedsStableBinding() was still fail-closing any shell payload whose first token resolved to a file, which wrongly lumped native binaries in with mutable script operands. The new header probe in src/node-host/invoke-system-run-plan.ts narrows that to actual script-like payloads, keeps the fail-closed behavior on probe errors / empty files / weak PE matches, and the regressions in src/node-host/invoke-system-run-plan.test.ts cover the important branches.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e2217c4738

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/node-host/invoke-system-run-plan.ts Outdated
Comment thread src/node-host/invoke-system-run-plan.ts Outdated
@obviyus obviyus self-assigned this Apr 16, 2026
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e1955a457d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/node-host/invoke-system-run-plan.ts Outdated
@obviyus obviyus force-pushed the fix/node-host-absolute-binary-approval-binding branch from e1955a4 to af0e160 Compare April 16, 2026 14:17
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: af0e160ee9

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/node-host/invoke-system-run-plan.ts
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 650dbdd11e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/node-host/invoke-system-run-plan.ts Outdated
Copy link
Copy Markdown
Contributor

@obviyus obviyus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified the node-host approval binder bug where absolute-path shell payload binaries were being treated like unsafe interpreter/script payloads and denied before allowlist approval.

Maintainer follow-up: added regressions and tightened the shell-payload path so unknown headers, relative binaries, writable paths, and symlinked writable targets all stay fail-closed.

Local gate: pnpm test src/node-host/invoke-system-run-plan.test.ts

@obviyus obviyus merged commit 29919bb into openclaw:main Apr 16, 2026
42 checks passed
@obviyus
Copy link
Copy Markdown
Contributor

obviyus commented Apr 16, 2026

Landed on main.

Thanks @tmimmanuel.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 77edb54b17

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/node-host/invoke-system-run-plan.ts
xudaiyanzi pushed a commit to xudaiyanzi/openclaw that referenced this pull request Apr 17, 2026
) (thanks @tmimmanuel)

* fix(node-host): allow absolute-path native binaries through approval binder

* test(node-host): cover binary binder edge cases

* test(node-host): use stable native binary fixture

* fix(ci): restore fail-closed race handling

* refactor(node-host): distill approval binding regressions

* fix(node-host): fail closed on unknown shell payload headers

* fix: land node-host approval binding for native binaries (openclaw#66731) (thanks @tmimmanuel)

* fix: keep relative shell binary payloads fail-closed (openclaw#66731) (thanks @tmimmanuel)

* fix: keep shell binary bypass on stable paths only (openclaw#66731) (thanks @tmimmanuel)

* fix: fail closed on symlinked shell binary targets (openclaw#66731) (thanks @tmimmanuel)

---------

Co-authored-by: Ayaan Zaidi <hi@obviy.us>
kvnkho pushed a commit to kvnkho/openclaw that referenced this pull request Apr 17, 2026
) (thanks @tmimmanuel)

* fix(node-host): allow absolute-path native binaries through approval binder

* test(node-host): cover binary binder edge cases

* test(node-host): use stable native binary fixture

* fix(ci): restore fail-closed race handling

* refactor(node-host): distill approval binding regressions

* fix(node-host): fail closed on unknown shell payload headers

* fix: land node-host approval binding for native binaries (openclaw#66731) (thanks @tmimmanuel)

* fix: keep relative shell binary payloads fail-closed (openclaw#66731) (thanks @tmimmanuel)

* fix: keep shell binary bypass on stable paths only (openclaw#66731) (thanks @tmimmanuel)

* fix: fail closed on symlinked shell binary targets (openclaw#66731) (thanks @tmimmanuel)

---------

Co-authored-by: Ayaan Zaidi <hi@obviy.us>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

tools.exec: binder fail-closed rejects ALL absolute-path commands in v2026.4.11+v2026.4.12 (with reproducible env workaround)

2 participants