Skip to content

fix(exec): splice shell line continuations before allowlist analysis - #71225

Closed
udaymanish6 wants to merge 1 commit into
openclaw:mainfrom
udaymanish6:fix/fix-exec-allowlist-rejecting-backslash-newlin
Closed

udaymanish6 wants to merge 1 commit into
openclaw:mainfrom
udaymanish6:fix/fix-exec-allowlist-rejecting-backslash-newlin

Conversation

@udaymanish6

Copy link
Copy Markdown
Contributor

No description provided.

@greptile-apps

greptile-apps Bot commented Apr 24, 2026 •

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR replaces the blanket rejection of commands containing shell line continuations (\<newline>) with a quote-aware splicing pass that removes continuations before allowlist analysis, enabling multi-line commands like /usr/bin/git \<newline> commit to be correctly evaluated.

The implementation correctly handles single-quote preservation (no splicing inside '...'), double-quote escape sequences (\", \$, etc.), and CRLF continuations. The four new test cases cover the most important safety-sensitive paths — injected subshells, chain operators exposed by splicing, unapproved binaries, and single-quote preservation.

Confidence Score: 5/5

Safe to merge — the splicing logic is quote-aware, the security-critical $<newline>(cmd) bypass case is explicitly tested and caught, and chain-operator injection after splicing is correctly blocked.

All findings from the prior review thread are already addressed in the new implementation (single-quote context is preserved, not spliced). No new P0/P1 issues were found. Remaining observations are at P2 or below.

No files require special attention.

Reviews (2): Last reviewed commit: "fix(exec): splice shell line continuatio..." | Re-trigger Greptile

Comment thread src/infra/exec-approvals-allowlist.ts Resolved

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

Copy link
Copy Markdown
Contributor

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: b9d2f95e10

ℹ️ 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 on lines +1104 to +1106
const command = hasShellLineContinuation(params.command)
? spliceShellLineContinuations(params.command)
: params.command;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P1 Badge Preserve comment-context newlines during command splicing

This unconditional pre-pass strips every \+newline pair, but POSIX shells do not treat that pair as a line continuation in all contexts (notably comments), so analysis can diverge from runtime execution. For example, /usr/bin/echo ok # note \\\n/usr/bin/rm -rf / executes the second line as a separate command in the shell, while the spliced string turns it into part of the comment and can incorrectly satisfy an /usr/bin/echo allowlist entry. That creates a policy-bypass path for multiline input; splicing needs to be syntax-aware (or fallback to reject when context is ambiguous).

Useful? React with 👍 / 👎.

@udaymanish6
udaymanish6 force-pushed the fix/fix-exec-allowlist-rejecting-backslash-newlin branch from b9d2f95 to 0fcf830 Compare April 24, 2026 19:35
@udaymanish6 udaymanish6 reopened this Apr 24, 2026
@vincentkoc vincentkoc added the triage: blank-template Candidate: PR template appears mostly untouched. label Apr 26, 2026
@clawsweeper

clawsweeper Bot commented Apr 26, 2026

Copy link
Copy Markdown
Contributor

Closing this as duplicate or superseded after Codex automated review.

PR #71225 is a narrower duplicate/superseded implementation for the same exec allowlist line-continuation problem already tracked by open issue #71153 and open PR #71154. Current main still rejects shell backslash-newline continuations before allowlist analysis, so this is not implemented-on-main; the best cleanup is to close #71225 and keep the maintainer-reviewed #71154/#71153 path as canonical.

Best possible solution:

Close #71225 as superseded by the canonical #71154 implementation for open issue #71153. Keep the remaining work on #71154/#71153, where maintainers can review the syntax-aware POSIX continuation normalizer, comment/heredoc/quote behavior, clearer unsupported-syntax errors, and required regression coverage before merging.

What I checked:

So I’m closing this here and keeping the remaining discussion on the canonical linked item.

Codex Review notes: model gpt-5.5, reasoning high; reviewed against 7e376e5aba32.

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

Labels

size: S triage: blank-template Candidate: PR template appears mostly untouched.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants