Skip to content

fix(exec): leave safe builtins unrewritten in enforced mode - #119351

Merged
steipete merged 1 commit into
mainfrom
steipete/fix-exec-builtin-enforced
Aug 4, 2026
Merged

steipete merged 1 commit into
mainfrom
steipete/fix-exec-builtin-enforced

Conversation

@steipete

@steipete steipete commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

What Problem This Solves

Resolves a problem where the enforced-mode exec renderer rewrote POSIX shell builtins to absolute filesystem paths. When an operator-approved command containing a safe builtin such as cd . ran through the enforced authorization path, the rendered command became /usr/bin/cd . instead of cd .. Builtins (cd, :, true, false, pwd, test) are executed by the shell itself, not by an external binary, so the rewrite is semantically wrong and provides no security benefit.

Why This Change Was Made

The enforced-mode security invariant exists to pin real external executables to their resolved absolute path so a PATH-shadowed binary cannot be substituted. That invariant does not apply to builtins, which the shell resolves internally without consulting PATH. shouldRewriteCandidate previously returned true unconditionally in enforced mode; it now returns satisfiedBy !== "safeBuiltins", exempting only the closed builtin set while leaving every real external executable pinned to its resolved path. Non-goal: changing behavior for any non-builtin segment.

User Impact

Operators on platforms that ship a real external builtin binary (notably macOS, which has /usr/bin/cd) no longer get a rewritten, semantically different command for approved builtins. There is no behavior change for external executables, which still resolve to absolute paths.

Evidence

  • New regression test leaves POSIX safe builtins unrewritten in enforced mode in src/infra/exec-authorization-render.test.ts locks that cd . renders as cd ..
  • node scripts/run-vitest.mjs src/infra/exec-authorization-render.test.ts src/infra/exec-safe-builtins.test.ts src/agents/bash-tools.exec-host-gateway.test.ts — all green (15 + 90 + 14 tests).
  • Verified via buildAuthorizedShellCommandFromPlan({ command: "cd .", mode: "enforced", segmentSatisfiedBy: ["safeBuiltins"] }) returns cd . (was /usr/bin/cd .).
  • Production delta: +4/−1 in one file. Autoreview (codex, high): clean, no accepted findings.

Found during a 87,932-test stress sweep of the feature surface (30 parallel agents); this was one of two confirmed production defects.

Enforced-mode command rendering resolved every executable to an absolute
path, including POSIX shell builtins (cd, :, true, false, pwd, test).
Builtins are executed by the shell itself, not via a filesystem binary,
so rewriting cd -> /usr/bin/cd is semantically wrong and adds no
PATH-shadowing protection (the whole point of enforced-mode resolution
for real external executables). shouldRewriteCandidate now returns
satisfiedBy !== "safeBuiltins" in enforced mode, leaving real external
executables pinned to their resolved absolute path.

Adds a regression test locking that enforced mode renders cd . as-is.
@openclaw-barnacle openclaw-barnacle Bot added size: XS maintainer Maintainer-authored PR labels Aug 4, 2026
@steipete
steipete marked this pull request as ready for review August 4, 2026 21:37
@steipete
steipete merged commit 63f4acb into main Aug 4, 2026
251 of 255 checks passed
@steipete
steipete deleted the steipete/fix-exec-builtin-enforced branch August 4, 2026 22:02
@steipete

steipete commented Aug 4, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

vincentkoc added a commit that referenced this pull request Aug 5, 2026
Punchcard-Session: crisp-lantern-orchard-nv

* origin/main:
  perf(memory): defer session backfill runtime (#119372)
  fix(ci): isolate built TUI PTY fixture (#119339)
  fix(commands): restore tool inventory for dynamic models (#119306)
  fix(media): release rejected BytePlus and Runway video downloads under debug capture (#119257)
  docs: add ChromeOS (Crostini) platform install guide (#107663)
  test(msteams): serve JWKS from in-process server in auth coverage (#119354)
  fix(qa): enable OpenAI for stored audio scenario (#119349)
  test(agents): realpath apply-patch temp dir fixture (#119353)
  test(slack): drop redundant .js-suffixed system-event mock (#119352)
  fix(exec): leave safe builtins unrewritten in enforced mode (#119351)
  fix(sessions): keep gateway responsive while large transcript archives are built (#112424)
  fix(tui): restore provider auth in installed local mode (#119283)
vincentkoc added a commit that referenced this pull request Aug 5, 2026
…time

* origin/main: (75 commits)
  fix(commands): restore tool inventory for dynamic models (#119306)
  fix(media): release rejected BytePlus and Runway video downloads under debug capture (#119257)
  docs: add ChromeOS (Crostini) platform install guide (#107663)
  test(msteams): serve JWKS from in-process server in auth coverage (#119354)
  fix(qa): enable OpenAI for stored audio scenario (#119349)
  test(agents): realpath apply-patch temp dir fixture (#119353)
  test(slack): drop redundant .js-suffixed system-event mock (#119352)
  fix(exec): leave safe builtins unrewritten in enforced mode (#119351)
  fix(sessions): keep gateway responsive while large transcript archives are built (#112424)
  fix(tui): restore provider auth in installed local mode (#119283)
  fix(release): accept legacy empty core artifacts (#119337)
  fix(qa): carry selected runtime into flow scenarios (#119324)
  fix(ci): retry interrupted Windows dashboard release checks (#119095)
  fix(release): filter validation ancestry fetch (#119334)
  fix(release): accept trusted extended-stable validation evidence (#119264)
  fix(sessions): preserve recorder-owned user turns (#119307)
  perf(cli): split plugin registry startup timing (#119318)
  fix(qa): align release scenario setup and compaction proof (#119188)
  fix(ci): avoid duplicate Matrix release QA runs (#119171)
  perf(agents): reuse provider policy manifest registry (#119305)
  ...
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 5, 2026
…#119351)

Enforced-mode command rendering resolved every executable to an absolute
path, including POSIX shell builtins (cd, :, true, false, pwd, test).
Builtins are executed by the shell itself, not via a filesystem binary,
so rewriting cd -> /usr/bin/cd is semantically wrong and adds no
PATH-shadowing protection (the whole point of enforced-mode resolution
for real external executables). shouldRewriteCandidate now returns
satisfiedBy !== "safeBuiltins" in enforced mode, leaving real external
executables pinned to their resolved absolute path.

Adds a regression test locking that enforced mode renders cd . as-is.

Co-authored-by: Peter Steinberger <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

maintainer Maintainer-authored PR size: XS

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant