Repository navigation
fix(exec): accept POSIX \<newline> in allowlisted commands; distinct error for unparseable syntax - #71154
fix(exec): accept POSIX \<newline> in allowlisted commands; distinct error for unparseable syntax#71154scottgl9 wants to merge 2 commits into
\<newline> in allowlisted commands; distinct error for unparseable syntax#71154Conversation
The exec allowlist previously hard-rejected any command containing `\<newline>` (POSIX line continuation) before analysis. The gateway and node-host then surfaced that rejection as `exec denied: allowlist miss` (or `SYSTEM_RUN_DENIED: allowlist miss`), indistinguishable from a true unapproved-binary denial. Agents that issued legitimate multi-line `curl`/`ssh`/etc. invocations with allowlisted binaries concluded their binary was blocked or the downstream service was down and escalated incorrectly. Instead of rejecting, splice `\<newline>` before tokenization in `evaluateShellAllowlist` via a new `joinShellLineContinuations` helper that walks the command with the same quote/heredoc/comment state machine used by `splitShellPipeline`. Splicing matches POSIX 2.2.1: outside single-quotes and outside quoted-heredoc bodies, `\<newline>` is removed (joining the lines); inside single-quotes and `#` comments it is preserved verbatim. After splicing, downstream analysis sees exactly the tokens the shell would, so the allowlist decision cannot drift between analyzer and runtime. Also disambiguate the denial signal: when the command cannot be parsed (inside or outside allowlist mode), the gateway now throws `exec denied: unsupported shell syntax` and the node-host emits `SYSTEM_RUN_DENIED: unsupported shell syntax` with event reason `unsupported-shell-syntax`. `allowlist miss` is reserved for the true case where analysis succeeded but the resolved binary is not on the allowlist. Tests: new `exec-approvals-allowlist.test.ts` covers the helper and the multi-line-resolves-identically case; gateway and node-host policy tests pick up the new error branch.
🔒 Aisle Security AnalysisWe found 1 potential security issue(s) in this PR:
1. 🟠 Durable approvals bypass allowlist denial for unparseable shell commands (analysisOk=false)
DescriptionIn allowlist mode, commands that fail allowlist analysis ( This creates a policy bypass path:
Relevant code (allowing execution when if (params.security === "allowlist" && (!analysisOk || !allowlistSatisfied) && !approvedByAsk) {
if (params.durableApprovalSatisfied) {
return { allowed: true, ... };
}
if (!analysisOk && !shellWrapperBlocked) {
return { allowed: false, eventReason: "unsupported-shell-syntax", ... };
}
return { allowed: false, eventReason: "allowlist-miss", ... };
}The same bypass exists at the gateway layer because Impact depends on threat model, but in typical "allowlist" deployments this undermines the safety guarantee that only analyzable/allowlisted shell commands run; a previously persisted durable approval (especially exact-command based) can enable execution of commands whose syntax cannot be analyzed or segmented, which may also defeat inline-eval/segment-based controls. RecommendationMake For example: if (params.security === "allowlist" && !analysisOk && !shellWrapperBlocked) {
return {
allowed: false,
eventReason: "unsupported-shell-syntax",
errorMessage: formatSystemRunUnsupportedShellSyntaxMessage(),
...
};
}
if (params.security === "allowlist" && !allowlistSatisfied && !approvedByAsk) {
if (params.durableApprovalSatisfied) {
return { allowed: true, ... };
}
return { allowed: false, eventReason: "allowlist-miss", ... };
}Also align gateway logic ( Analyzed PR: #71154 at commit Last updated on: 2026-04-24T15:46:06Z |
Greptile SummaryThis PR fixes multi-line shell command handling in the exec allowlist by splicing POSIX Confidence Score: 5/5Safe to merge; the one identified issue is a narrow edge case with no security impact. All findings are P2. The src/infra/exec-approvals-analysis.ts — the Prompt To Fix All With AIThis is a comment left during a code review.
Path: src/infra/exec-approvals-analysis.ts
Line: 179-186
Comment:
When a `\<newline>` continuation is encountered inside an **unquoted heredoc body**, `heredocLine` is reset to `""` instead of preserving the content accumulated so far on the same logical line. This means a heredoc terminator that is itself split across lines (e.g. `EO\<LF>F` for `<<EOF`) is never recognized as the terminator: after the reset, only `F` is accumulated, the delimiter check `"F" === "EOF"` fails, and the parser continues treating subsequent lines as heredoc body. This does not cause a security bypass (downstream analysis would fail, producing `unsupported-shell-syntax`) but causes a confusing result for any command that uses a continuation inside a heredoc terminator row.
```suggestion
if (current && !current.quoted) {
const skip = isContinuation(i);
if (skip) {
// Do NOT reset heredocLine: the continuation joins lines, so the
// characters already accumulated on this logical line must be kept
// to correctly detect a delimiter like "EO\<LF>F" for <<EOF.
i += skip;
continue;
}
}
```
How can I resolve this? If you propose a fix, please make it concise.Reviews (1): Last reviewed commit: "fix(exec): accept POSIX line continuatio..." | Re-trigger Greptile |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 4e64cf5bc0
ℹ️ 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".
Review feedback on openclaw#71154: - Do not reset the accumulated heredoc logical line when splicing a `\<newline>` inside an unquoted heredoc body. Bash joins the lines, so a terminator whose characters are split across a continuation (`EO\<LF>F` for `<<EOF`) should still terminate the heredoc, and conversely a continued body line whose tail happens to equal the delimiter (`foo \<LF>EOF`) should *not* terminate. The previous code cleared `heredocLine` on splice and mis-classified both edges. (Greptile / Codex reviews.) - Build the output and heredoc-line buffers via `string[]` + `join("")` instead of `+=` concatenation in a loop, so very large commands (big heredoc bodies) stay linear regardless of engine concatenation strategy. (Aisle security review.) Tests extended: new cases for the `EO\<LF>F` terminator and the `foo \<LF>EOF` non-terminator edges.
|
Addressed the Aisle Security flag in b1c80c3: |
|
Thanks for the context here. I swept through the related work, and this is now duplicate or superseded. Close as superseded: the merged planner rewrite now owns POSIX exec authorization and intentionally treats line-continuation syntax as unplanned/approval-gated, so this stale legacy-parser splice should not remain a landing candidate. Root-cause cluster Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Canonical path: Keep the shipped planner policy as canonical; if maintainers want to accept line continuations later, implement it as a new planner-scoped, security-reviewed PR with real exec proof. So I’m closing this here because the remaining work is already tracked in the canonical issue. Review detailsBest possible solution: Keep the shipped planner policy as canonical; if maintainers want to accept line continuations later, implement it as a new planner-scoped, security-reviewed PR with real exec proof. Do we have a high-confidence way to reproduce the issue? Yes by source inspection: current main marks line-continuation shell commands as an unanalyzable planner risk and tests assert they stay out of allow-always approval. I did not run live exec in this read-only review. Is this the best way to solve the issue? No. This was a plausible old-parser fix, but the best current path is either the shipped planner policy or a new planner-scoped change, not reviving join-before-analysis in the legacy allowlist analyzer. Security review: Security review needs attention: The diff touches the exec authorization boundary and conflicts with shipped planner policy for line-continuation syntax.
AGENTS.md: found and applied where relevant. What I checked:
Likely related people:
Codex review notes: model internal, reasoning high; reviewed against 8ed6c78b7891. |
|
ClawSweeper PR egg 🎁 Pass real behavior proof to wake the egg and unlock a hatchable treat. Where did the egg go?
|
|
This pull request has been automatically marked as stale due to inactivity. |
Summary
\<newline>line continuations before exec-allowlist analysis so multi-line invocations with an allowlisted leading binary resolve the same as their single-line form (fixes exec allowlist: multi-line (\<newline>) commands fail with "allowlist miss" even when binary is allowlisted #71153).exec denied: unsupported shell syntaxand the node host emitsSYSTEM_RUN_DENIED: unsupported shell syntaxwith event reasonunsupported-shell-syntax.allowlist missis reserved for the true case where analysis succeeded but the resolved binary is not on the allowlist.joinShellLineContinuationshelper walks the command once with the same quote/heredoc/comment state machine used bysplitShellPipeline, so splicing respects single-quoted strings, quoted-heredoc bodies, and#comments. Inside double quotes and unquoted heredoc bodies,\<newline>is spliced (matching bash).Why the old behavior
evaluateShellAllowlist()previously rejected any command containing\<newline>before analysis and emittedallowlist miss. Agents with allowlisted binaries but multi-line commands therefore concluded their binary was blocked (or the downstream service was down), and escalated incorrectly.The comment at the old guard noted a concern that line-continuation semantics "can rewrite token boundaries at runtime". POSIX 2.2.1 is unambiguous: outside single-quotes and outside quoted-heredoc bodies,
\<newline>is removed before tokenization. Pre-splicing produces exactly the tokens the shell would see, so the allowlist decision cannot drift between analyzer and runtime — provided the splicing walker respects single-quote and quoted-heredoc exceptions, which it does.Key files
src/infra/exec-approvals-analysis.ts— newjoinShellLineContinuationshelper,parseHeredocDelimiterlifted to module scope for reuse.src/infra/exec-approvals-allowlist.ts— drop the early-reject, normalize viajoinShellLineContinuationsbefore analysis.src/agents/bash-tools.exec-host-gateway.ts— split error-string path:unsupported-shell-syntaxvsallowlist-miss.src/node-host/exec-policy.ts,src/node-host/invoke-system-run.ts,src/agents/exec-approval-result.ts— matching reason/message additions.Test plan
src/infra/exec-approvals-allowlist.test.ts: multi-line allowlistedcurlwith\<LF>and\<CRLF>resolves identically to single-line; non-allowlisted binary still misses cleanly; directjoinShellLineContinuationsunit tests cover quote state, comments, heredoc bodies (quoted and unquoted), unterminated quote fallback, and CRLF.src/agents/bash-tools.exec-host-gateway.test.ts: new assertion that unparseable input throws the distinctexec denied: unsupported shell syntaxmessage while the true allowlist-miss case still throws the original string.src/node-host/exec-policy.test.ts: parallel coverage forSYSTEM_RUN_DENIED: unsupported shell syntaxwitheventReason: "unsupported-shell-syntax".pnpm check:changedgreen (typecheck, lint, import cycles, changed-test lanes).pi-tools.safe-bins,exec-approvals-parity,exec-approvals-safe-bins,exec-approvals-policy,invoke-system-run,server-node-events, andexec-approval-resultsuites: all passing.Risk notes
#comments, so splicing matches bash semantics.evaluateShellAllowlist+ one error-string split; small diff.unsupported shell syntaxsignal.Fixes #71153.