Skip to content

fix(exec): implement Windows exec allowlist with argPattern and quote-aware analysis#56285

Merged
steipete merged 3 commits intoopenclaw:mainfrom
kpngr:fix/windows-exec-allowlist
Apr 2, 2026
Merged

fix(exec): implement Windows exec allowlist with argPattern and quote-aware analysis#56285
steipete merged 3 commits intoopenclaw:mainfrom
kpngr:fix/windows-exec-allowlist

Conversation

@kpngr
Copy link
Copy Markdown

@kpngr kpngr commented Mar 28, 2026

Summary

  • Enable exec approval allowlist on Windows by implementing buildSafeShellCommand via PowerShell & call operator (fixes [Bug]: Regression of #25376 - Exec allowlist returns 'unsupported platform' on Windows (v2026.3.12) #50403)
  • Make findWindowsUnsupportedToken quote-aware: metacharacters inside double- or single-quoted args (e.g. (土) in "2026-03-28 (土) - LifeLog") no longer block allowlist checking entirely
  • Add argPattern field to ExecAllowlistEntry for regex-based argument matching (Windows-only); uses \x00 separator to preserve argv boundaries
  • Strip trailing shell redirections (2>&1 etc.) before argPattern matching
  • Handle powershell -ExecutionPolicy Bypass -Command "..." and '...' single-quoted payloads in wrapper stripping
  • Show pre-approved commands in exec tool description on Windows (LLM hint)
  • Fix plugin-sdk-entrypoints.json: add missing signal-core entry (oversight in d5841f64runtime-api.ts imports it but entrypoint was not registered, breaking vitest alias resolution)

Root cause (fixes #50403)

buildSafeShellCommand returned { ok: false, reason: "unsupported platform" } on Windows, causing every exec to request approval even for allowlisted commands. Additionally, findWindowsUnsupportedToken was not quote-aware, so a command like node add_lifelog.js "2026-03-28 (土) - LifeLog" was rejected before the allowlist was even checked — the ( in the quoted title string triggered an early exit.

Codex review

Ran codex review --base origin/main locally and addressed all findings:

  • Removed ! from WINDOWS_UNSAFE_CMD_META (PowerShell doesn't treat ! as special in double-quoted strings)
  • Gated argPattern tests to Windows-only (buildArgPatternFromArgv returns undefined on non-Windows)
  • Fixed tokenizeWindowsSegment to handle '' as escaped apostrophe in single-quoted strings
  • Used \x00 arg-boundary separator in buildArgPatternFromArgv to prevent argv-flattening bypass
  • Matched script-wrapper allow-always entries against wrapper-stripped argv
  • Allowed $ not followed by identifier (\host\C$ etc.) in windowsEscapeArg

Known pre-existing failures in main (not introduced by this PR)

  • pnpm build: Telegram TypeScript errors (extensions/telegram/src/bot.ts)
  • pnpm test: src/image-generation/runtime.test.ts (2 failures, unrelated to exec)

Testing

  • pnpm test passes (93/93 on changed files; 2 pre-existing failures in image-generation are unrelated)
  • Locally verified on Windows: LifeLog cron job with (土) in title now runs without approval prompts

AI-assisted PR checklist

  • Marked as AI-assisted (Claude Code + codex review)
  • Testing: fully tested on Windows (the target platform)
  • Code reviewed and understood
  • codex review --base origin/main run locally; all findings addressed
  • Screenshots: N/A (no UI changes)

@openclaw-barnacle openclaw-barnacle Bot added scripts Repository scripts agents Agent runtime and tooling size: L labels Mar 28, 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: eb075e919a

ℹ️ 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/infra/exec-approvals-analysis.ts Outdated
// ` — PowerShell escape character; can form escape sequences like `n, `0 inside double quotes.
// Note: ! is intentionally omitted — PowerShell does not treat ! as special in double-quoted
// strings (unlike cmd.exe delayed expansion), so "Hello!" is safe to pass through.
const WINDOWS_UNSAFE_CMD_META = /[%`]|\$(?=[A-Za-z_{])/;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Reject $( subexpressions in Windows arg escaping

windowsEscapeArg currently blocks %, backticks, and $ before identifiers/braces, but it still allows $(. In the new Windows allowlist path, arguments parsed from single-quoted input are rebuilt with double quotes, so a command like node tool.js 'safe$(Start-Process calc)' can pass analysis/matching and then execute the $() subexpression when the enforced command runs. This allows non-allowlisted commands to execute via argument expansion on Windows and undermines the allowlist boundary for any approved command that carries attacker-controlled arguments containing $(.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Fixed in commit 21309bdcf7: WINDOWS_UNSAFE_CMD_META lookahead extended from [A-Za-z_{] to [A-Za-z_{(] to also block $(expression) subexpressions. A test case covering $(whoami) and $(Get-Date) has been added.

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented Mar 28, 2026

Greptile Summary

This PR implements Windows exec allowlist support by: (1) making findWindowsUnsupportedToken quote-aware so parentheses in quoted arguments like "2026-03-28 (土) - LifeLog" no longer block allowlist checking, (2) adding buildSafeShellCommand for Windows via the PowerShell & call operator, (3) introducing an argPattern field on ExecAllowlistEntry for regex-based argument matching (Windows-only, using \x00 arg-boundary separators), and (4) surfacing pre-approved commands in the exec tool description. The type refactoring from string[] to AllowAlwaysPattern[] in resolveAllowAlwaysPatterns is propagated consistently through both call sites.

Key issues found:

  • P1 (Security)WINDOWS_UNSAFE_CMD_META does not block PowerShell $(expression) subexpressions. The quote-aware fix newly permits ( inside double-quoted strings, which combined with $ not being in WINDOWS_UNSUPPORTED_TOKENS and $( not matching \\$(?=[A-Za-z_{]), means PowerShell subexpressions pass through to windowsEscapeArg and get double-quoted — where PowerShell will still evaluate them. Fix: extend the lookahead to [A-Za-z_{(].
  • P2 (Logic)stripTrailingRedirections in matchArgPattern uses \\s+ which never matches the \\x00 arg separator, making the retry a silent no-op for all auto-generated argPatterns. Unreachable in practice but misleading.
  • P2 (Style)deriveExecShortName has two consecutive JSDoc blocks; the earlier draft was not removed.

Confidence Score: 4/5

Mostly safe to merge; one P1 security gap should be addressed before shipping to Windows users.

The feature is well-designed and thoroughly tested. The argPattern mechanism correctly prevents injection in constrained allowlist entries. However, the quote-aware change to findWindowsUnsupportedToken newly permits ( inside double-quoted strings, and the missing $( check in WINDOWS_UNSAFE_CMD_META means PowerShell subexpressions can bypass the argument-escaping layer for path-only allowlist entries. Fixing it requires a one-character addition to the regex lookahead. All other issues are P2 or style-level.

src/infra/exec-approvals-analysis.ts — specifically the WINDOWS_UNSAFE_CMD_META regex.

Important Files Changed

Filename Overview
src/infra/exec-approvals-analysis.ts Largest changed file — adds quote-aware token scanning, single-quote tokenizer support, Windows shell wrapper stripping, windowsEscapeArg, and Windows buildSafeShellCommand. One P1 security gap: $(expression) is not caught by WINDOWS_UNSAFE_CMD_META but is now reachable inside double-quoted args.
src/infra/exec-approvals-allowlist.ts Adds AllowAlwaysPattern type and argPattern field; changes resolveAllowAlwaysPatterns return type from string[] to AllowAlwaysPattern[]; adds buildArgPatternFromArgv / buildScriptArgPatternFromArgv helpers. Deduplication change from Set<string> to array with custom addAllowAlwaysPattern is correct.
src/infra/exec-command-resolution.ts Adds matchArgPattern, stripTrailingRedirections, and updates matchAllowlist to accept argv and prefer argPattern-matched entries on Windows. The \x00-separator stripping in stripTrailingRedirections is a no-op for Windows (redirections are already blocked upstream), but is logically inconsistent.
src/infra/exec-approvals.ts Adds argPattern to ExecAllowlistEntry type, threads it through addAllowlistEntry and recordAllowlistUse, and extends ExecApprovalDecision with "expired". Changes are clean and consistent.
src/agents/bash-tools.exec.ts Adds buildExecToolDescription to surface pre-approved Windows commands as an LLM hint. The deriveExecShortName and argPatternToReadable helpers are display-only. Clean implementation with try/catch to avoid blocking tool creation.
src/agents/bash-tools.exec-host-gateway.ts Correctly updated to destructure AllowAlwaysPattern objects and pass argPattern to addAllowlistEntry.
src/node-host/invoke-system-run.ts Same mechanical update as bash-tools.exec-host-gateway.ts — threads argPattern through to addAllowlistEntry. Correct.

Comments Outside Diff (1)

  1. src/infra/exec-approvals-analysis.ts, line 53-66 (link)

    P2 Duplicate JSDoc comment block on deriveExecShortName

    There are two consecutive JSDoc blocks before deriveExecShortName. The first block (lines 53–58) appears to be an earlier draft that was superseded by the second block (lines 60–66) but not removed. Only the second block should remain.

    Prompt To Fix With AI
    This is a comment left during a code review.
    Path: src/infra/exec-approvals-analysis.ts
    Line: 53-66
    
    Comment:
    **Duplicate JSDoc comment block on `deriveExecShortName`**
    
    There are two consecutive JSDoc blocks before `deriveExecShortName`. The first block (lines 53–58) appears to be an earlier draft that was superseded by the second block (lines 60–66) but not removed. Only the second block should remain.
    
    How can I resolve this? If you propose a fix, please make it concise.
Prompt To Fix All With AI
This is a comment left during a code review.
Path: src/infra/exec-approvals-analysis.ts
Line: 709

Comment:
**PowerShell `$()` subexpression not blocked by `WINDOWS_UNSAFE_CMD_META`**

`WINDOWS_UNSAFE_CMD_META` correctly blocks `$var`, `${var}`, and `$env:SECRET` (via `\$(?=[A-Za-z_{])`), and backtick escape sequences. However, it does not block `$(expression)` — the PowerShell subexpression operator — because `$` followed by `(` is not matched by `[A-Za-z_{]`.

This is newly exploitable after the quote-aware changes in this PR. Before, `(` was in `WINDOWS_UNSUPPORTED_TOKENS` and blocked everywhere. Now `(` inside double-quoted arguments is permitted (the motivating fix for `"2026-03-28 (土) - LifeLog"`). As a result, a command like `node tool.js "$(Get-Item env:SECRET)"` now passes both `findWindowsUnsupportedToken` (the `(` is inside a double-quoted string and `$` is not in `WINDOWS_UNSUPPORTED_TOKENS`) and `windowsEscapeArg` (the lookahead `(?=[A-Za-z_{])` does not match `(`). PowerShell **does** expand `$(expression)` inside double-quoted strings, so the rebuilt command would evaluate the expression before passing the result to `node`.

This affects commands with path-only allowlist entries (no `argPattern`) and represents a new injection surface that didn't exist before this PR.

Suggestion: extend `WINDOWS_UNSAFE_CMD_META` to also catch `$(`:

```suggestion
const WINDOWS_UNSAFE_CMD_META = /[%`]|\$(?=[A-Za-z_{(])/;
```

The `(` in the lookahead catches `$(expression)` while still permitting bare `$` not followed by an identifier or `(` (e.g. UNC paths like `\\host\C$`), consistent with the existing test for that case.

How can I resolve this? If you propose a fix, please make it concise.

---

This is a comment left during a code review.
Path: src/infra/exec-approvals-analysis.ts
Line: 53-66

Comment:
**Duplicate JSDoc comment block on `deriveExecShortName`**

There are two consecutive JSDoc blocks before `deriveExecShortName`. The first block (lines 53–58) appears to be an earlier draft that was superseded by the second block (lines 60–66) but not removed. Only the second block should remain.

How can I resolve this? If you propose a fix, please make it concise.

---

This is a comment left during a code review.
Path: src/infra/exec-command-resolution.ts
Line: 266-295

Comment:
**`stripTrailingRedirections` is a no-op for `\x00`-joined arg strings**

`matchArgPattern` joins `argv` with either `\x00` (for patterns built by `buildArgPatternFromArgv`) or ` ` (for legacy space-separated patterns). When `\x00` is the separator, `TRAILING_SHELL_REDIRECTIONS_RE` uses `\s+` before the redirection operator, but `\x00` is not whitespace — so the regex never matches and the retry is silently a no-op for all auto-generated argPatterns.

In practice this is harmless: on Windows, `>` and `&` are in `WINDOWS_UNSUPPORTED_TOKENS` and are rejected before reaching `matchArgPattern`, so a trailing `2>&1` token would never appear in a valid Windows command. But the retry logic is misleading as written. Consider documenting that this branch only fires for legacy space-joined patterns, or updating the regex to also accept `\x00` as a separator before the redirection.

How can I resolve this? If you propose a fix, please make it concise.

Reviews (1): Last reviewed commit: "fix(exec): address remaining codex P2 is..." | Re-trigger Greptile

Comment thread src/infra/exec-approvals-analysis.ts Outdated
Comment thread src/infra/exec-command-resolution.ts Outdated
@kpngr
Copy link
Copy Markdown
Author

kpngr commented Mar 28, 2026

All findings addressed in commits d15eae77d5 and 21309bdcf7:

Codex P1 — single-quote Windows quoting mismatch: inSingle tracking removed from findWindowsUnsupportedToken and tokenizeWindowsSegment. Single quotes are literal characters in cmd.exe (used by the node-host exec path), so shell metacharacters inside single-quoted strings were active at runtime despite being analysed as safe. Tests updated accordingly.

Codex P2 — cmd /c semantic change: stripWindowsShellWrapperOnce no longer strips cmd /c wrappers. Stripping and re-running the inner payload via PowerShell changes semantics for cmd.exe builtins (dir, copy, etc.). Commands wrapped with cmd /c now require an explicit allowlist entry for cmd or user approval.

Greptile P1 — $(expression) not blocked: WINDOWS_UNSAFE_CMD_META lookahead extended from [A-Za-z_{] to [A-Za-z_{(]. PowerShell evaluates $(expr) inside double-quoted strings, so $(whoami) would have bypassed windowsEscapeArg. Test cases added.

Greptile P2 — stripTrailingRedirections no-op for \x00: TRAILING_SHELL_REDIRECTIONS_RE updated to /[\s\x00]+/ so the retry in matchArgPattern fires for both legacy space-joined and auto-generated \x00-joined arg strings.

Greptile P2 Style — duplicate JSDoc on deriveExecShortName: Stale first block removed; only the current description remains.

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: 21309bdcf7

ℹ️ 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/infra/exec-approvals-analysis.ts
Comment thread src/infra/exec-command-resolution.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: 888efd68b1

ℹ️ 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/infra/exec-command-resolution.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: cc70267216

ℹ️ 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/agents/bash-tools.exec.ts Outdated
Comment thread src/infra/exec-approvals-analysis.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: eb30eb0c3c

ℹ️ 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/infra/exec-command-resolution.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: af98b40d5d

ℹ️ 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/infra/exec-approvals-analysis.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: c5827553fa

ℹ️ 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/infra/exec-approvals-analysis.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: 36f2d79f00

ℹ️ 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/infra/exec-approvals-analysis.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

https://github.com/openclaw/openclaw/blob/4e5708d1a5fd7b826dbfe7e2f9c88cc850a04ed1/src/infra/exec-approvals-allowlist.ts#L425-L429
P2 Badge Skip value-taking PowerShell flags before script path extraction

resolveShellWrapperScriptCandidatePath is used for shell wrappers on Windows, but this loop only skips values for a POSIX-oriented subset of flags. For common commands like powershell -ExecutionPolicy Bypass -File script.ps1, -ExecutionPolicy is consumed but Bypass is then treated as the script token, so allow-always can persist/match /cwd/Bypass instead of script.ps1. That breaks allowlist stability for PowerShell script invocations and can bind approvals to the wrong path.

ℹ️ 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/infra/exec-approvals-analysis.ts Outdated
@kpngr
Copy link
Copy Markdown
Author

kpngr commented Mar 28, 2026

Fixed in 94fa8e3 (review #4025536905). Added POWERSHELL_OPTIONS_WITH_VALUE_RE to resolveShellWrapperScriptCandidatePath so that PowerShell value-taking flags like -ExecutionPolicy advance past both the flag and its argument before locating the script token. Previously powershell -ExecutionPolicy Bypass -File script.ps1 resolved to /cwd/Bypass instead of script.ps1.

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: 94fa8e32d3

ℹ️ 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/infra/exec-approvals.ts Outdated
Comment thread src/infra/exec-command-resolution.ts Outdated
@openclaw-barnacle openclaw-barnacle Bot added app: web-ui App: web-ui gateway Gateway runtime labels Mar 28, 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: 7acdd2e477

ℹ️ 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/infra/exec-command-resolution.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: 398671e6b1

ℹ️ 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/infra/exec-approvals-allowlist.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: ed52e1cf5f

ℹ️ 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/infra/exec-approvals-allowlist.ts Outdated
Comment on lines +275 to +279
let idx = effectiveArgv.findIndex((a) => a === shellScriptCandidatePath);
if (idx === -1) {
idx = effectiveArgv.findIndex(
(a) => path.basename(a).toLowerCase() === scriptBase,
);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Normalize relative script paths before basename fallback

Fresh evidence beyond the prior basename fix: shellScriptCandidatePath is resolved to an absolute path, so effectiveArgv.findIndex((a) => a === shellScriptCandidatePath) fails whenever -File was passed as a relative path. In that case the basename fallback can latch onto an earlier non-script argument with the same filename (for example -SettingsFile C:\tmp\deploy.ps1 -File .\scripts\deploy.ps1), which slices scriptArgs from the wrong point and makes allow-always argPattern matching depend on unrelated pre-script flags. This causes false allowlist misses/re-prompts for otherwise identical script invocations.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Fixed in 15f2760. Added optional cwd to buildScriptArgPatternFromArgv and a resolveArgPath helper that normalizes relative argv tokens to absolute before comparing against the already-absolute scriptPath. The same normalization is applied in evaluateSegments using params.cwd. The basename fallback remains as a last resort.

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: 15f27602da

ℹ️ 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/infra/exec-approvals.ts Outdated
@kpngr kpngr force-pushed the fix/windows-exec-allowlist branch from bacddf4 to 95b734b Compare March 28, 2026 14:29
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: 95b734b4ac

ℹ️ 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/infra/exec-approvals-allowlist.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: 80189aabeb

ℹ️ 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/infra/exec-approvals-analysis.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: 6e948952b8

ℹ️ 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/infra/exec-approvals-analysis.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: 8e30a380b9

ℹ️ 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/infra/exec-approvals-allowlist.ts
@steipete steipete force-pushed the fix/windows-exec-allowlist branch from ed70f9f to 13d6b66 Compare April 2, 2026 14:30
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: 13d6b664ff

ℹ️ 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 on lines +8 to 11
argPattern: Type.Optional(Type.String()),
lastUsedAt: Type.Optional(Type.Integer({ minimum: 0 })),
lastUsedCommand: Type.Optional(Type.String()),
lastResolvedPath: Type.Optional(Type.String()),
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Accept allowlist source metadata in exec approvals schema

addAllowlistEntry now persists allow-always entries with source: "allow-always" (see src/infra/exec-approvals.ts), but this schema still rejects any extra allowlist keys via additionalProperties: false and does not permit source. That breaks exec.approvals.set / exec.approvals.node.set round-trips after an allow-always decision: exec.approvals.get can return entries containing source, then the same payload is rejected as invalid params when sent back. The protocol schema needs to include the persisted metadata (or redact it before transport) to keep approvals editing/sync working.

Useful? React with 👍 / 👎.

@steipete steipete requested a review from a team as a code owner April 2, 2026 15:07
@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation channel: telegram Channel integration: telegram app: macos App: macos scripts Repository scripts docker Docker and sandbox tooling labels Apr 2, 2026
@steipete steipete force-pushed the fix/windows-exec-allowlist branch from fadb65d to 30e2953 Compare April 2, 2026 15:09
@openclaw-barnacle openclaw-barnacle Bot removed docs Improvements or additions to documentation channel: telegram Channel integration: telegram app: macos App: macos scripts Repository scripts docker Docker and sandbox tooling labels Apr 2, 2026
@steipete steipete merged commit eb261fa into openclaw:main Apr 2, 2026
3 checks passed
@steipete
Copy link
Copy Markdown
Contributor

steipete commented Apr 2, 2026

Landed via temp rebase onto main.\n\n- Gate: pnpm check && pnpm build && pnpm test\n- Land commit: 30e2953\n- Merge commit: eb261fa\n\nThanks @kpngr!

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: 30e29535bf

ℹ️ 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 on lines +549 to +553
// Note: cmd /c is intentionally NOT stripped here. If a command is wrapped
// with `cmd /c`, its inner payload would later be executed by PowerShell, which
// changes semantics for cmd.exe builtins (dir, copy, etc.). Callers that submit
// `cmd /c <thing>` must have an explicit allowlist entry for `cmd` itself, or
// the command will require user approval.
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Keep cmd /c wrapper handling consistent with allow-always

On Windows, this branch intentionally leaves cmd /c wrappers unstripped during analysis/enforcement, but allow-always persistence still derives and stores the inner executable via shell-wrapper inline-command extraction. That mismatch means approving cmd /c "node app.js" as allow-always persists a node allowlist entry, while later evaluations still resolve the executable as cmd, so the exact same command misses the allowlist and prompts again (or is denied under allowlist-only). Please align these paths by either persisting cmd for this wrapper style or unwrapping cmd /c consistently in matching/enforcement.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling app: web-ui App: web-ui gateway Gateway runtime size: XL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Regression of #25376 - Exec allowlist returns 'unsupported platform' on Windows (v2026.3.12)

2 participants