openclaw - ✅(Solved) Fix [Bug]: heredoc (<<) triggers approval prompt in allowlist mode [3 pull requests, 1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openclaw/openclaw#68661Fetched 2026-04-19 15:08:59
View on GitHub
Comments
1
Participants
2
Timeline
9
Reactions
0
Timeline (top)
cross-referenced ×3referenced ×3labeled ×2commented ×1

The heredoc fix from PR #13811 appears to have regressed. Commands with << heredoc syntax trigger an approval prompt even when the target binary is in the agent's allowlist.

Root Cause

The heredoc fix from PR #13811 appears to have regressed. Commands with << heredoc syntax trigger an approval prompt even when the target binary is in the agent's allowlist.

Fix Action

Fixed

PR fix notes

PR #68754: fix: remove unconditional heredoc approval in allowlist mode

Description (problem / solution / changelog)

Problem

Closes #68661

In allowlist security mode, any command containing a heredoc (<<) unconditionally triggers an approval prompt, even when:

  1. The target binary is in the allowlist (allowlistSatisfied === true)
  2. Command analysis passes (analysisOk === true)
  3. The heredoc is safe (quoted <<'EOF' or no command substitution)

Example that should auto-execute but prompts instead:

cat <<'EOF
hello world
EOF

This is a regression — PR #13811 previously fixed heredoc handling, but the extra requiresHeredocApproval gate was added later and overrides the analysis result.

Root Cause

src/agents/bash-tools.exec-host-gateway.ts:161-165:

const requiresHeredocApproval =
    hostSecurity === "allowlist" && analysisOk && allowlistSatisfied && hasHeredocSegment;

This unconditionally forces approval for ALL heredoc commands when in allowlist mode, regardless of whether the heredoc has already been validated as safe by the analysis layer.

Fix

Remove the requiresHeredocApproval gate entirely:

  • Delete hasHeredocSegment and requiresHeredocApproval variables
  • Remove from the requiresAsk condition
  • Remove the associated warning message

The analysis layer (exec-approvals-analysis.ts) already fully validates heredoc safety:

  • Quoted heredoc (<<'EOF'): no expansion → safe ✓
  • Unquoted, no substitution: safe ✓
  • Unquoted with $(...) or backticks: rejected by analysis
  • Unterminated heredoc: rejected by analysis

Dangerous heredocs never reach this code path, so the extra gate is redundant.

Testing

# Should now auto-execute (was prompting before):
cat <<'EOF
hello world
EOF

# Should still be blocked by analysis:
cat <<EOF
$(whoami)
EOF

Impact

  • 1 file changed, 2 insertions(+), 13 deletions(-)
  • Only affects allowlist mode + heredoc commands
  • No changes to analysis or non-heredoc approval paths

Changed files

  • src/agents/bash-tools.exec-host-gateway.ts (modified, +2/-13)

PR #68824: fix: remove blanket heredoc approval gate in allowlist mode

Description (problem / solution / changelog)

Fixes #68661

Summary

Removes the overly broad requiresHeredocApproval gate in bash-tools.exec-host-gateway.ts that forces an approval prompt for all heredoc commands in allowlist mode, even when the target binary is already in the allowlist.

Root Cause

A security hardening added after PR #13811 introduced a blanket requiresHeredocApproval check that fires whenever any segment contains a << token — regardless of whether the heredoc is safe (quoted delimiter, no expansion tokens). This regressed the original fix.

Why This Is Safe

The analysis layer (splitShellPipeline in exec-approvals-analysis.ts) already handles security:

  • Unquoted heredocs containing $(...), backticks, or ${...} return ok: false with reason "command substitution in unquoted heredoc"
  • This causes analysisOk to be false, which makes requiresExecApproval return true and force approval

Safe heredocs (quoted delimiters like <<'EOF') parse as ok: true and should pass through the allowlist without an extra approval prompt.

Changes

  • Removed hasHeredocSegment and requiresHeredocApproval variables
  • Removed requiresHeredocApproval from the requiresAsk OR chain
  • Removed the heredoc warning push

Net: 11 lines deleted, 0 lines added.

Test Plan

  • Configure an agent with security: "allowlist" and ask: "off"
  • Add /usr/bin/cat to the allowlist
  • Run cat <<'EOF'\nhello world\nEOF
  • Verify: command runs without approval prompt
  • Run cat <<EOF\n$(whoami)\nEOF (unquoted with expansion)
  • Verify: approval is still required (handled by splitShellPipeline)

Changed files

  • src/agents/bash-tools.exec-host-gateway.ts (modified, +0/-11)

PR #68854: fix(security): allow quoted heredocs in allowlist mode without extra approval

Description (problem / solution / changelog)

Summary

Fixes #68661

Commands with << heredoc syntax trigger an approval prompt in allowlist mode even when the target binary is in the allowlist. This regressed from the original fix (#13811) after a security hardening (f23da067).

Root Cause

The hardening commit added requiresHeredocApproval that triggers for any heredoc token (token.startsWith("<<")), without distinguishing between safe (quoted) and potentially unsafe (unquoted) heredocs.

Fix

  • Quoted heredocs (<<'EOF', <<"EOF", <<-'EOF', <<-"EOF"): No longer require extra approval. The shell treats the body as literal text — no variable expansion, no command substitution.
  • Unquoted heredocs (<<EOF, <<-EOF): Still require explicit approval. $() and backtick commands inside the body get evaluated by the shell, which is a real security concern.

Examples

CommandBeforeAfter
cat <<'EOF'\nhello\nEOF❌ Approval required✅ Auto-approved (binary in allowlist + quoted heredoc)
cat <<EOF\n\$HOME\nEOF❌ Approval required❌ Approval required (unquoted = expansion)
echo hello✅ Auto-approved✅ Auto-approved (no change)

Testing

  • Updated warning message test to match new wording
  • Existing ReDoS guard test still passes (uses quoted heredoc)

Changed files

  • src/agents/bash-tools.exec-host-gateway.test.ts (modified, +95/-0)
  • src/agents/bash-tools.exec-host-gateway.ts (modified, +11/-4)
  • src/agents/pi-embedded-subscribe.handlers.tools.test.ts (modified, +1/-1)

Code Example

exec-approvals.json has:
Agent config: security: "allowlist", ask: "off"
"pattern": "/usr/bin/cat"
RAW_BUFFERClick to expand / collapse

Bug type

Regression (worked before, now fails)

Beta release blocker

No

Summary

The heredoc fix from PR #13811 appears to have regressed. Commands with << heredoc syntax trigger an approval prompt even when the target binary is in the agent's allowlist.

Steps to reproduce

  1. Configure an agent with security: "allowlist" and ask: "off"
  2. Add a binary to the allowlist, e.g.: openclaw approvals allowlist add --agent worker /usr/bin/cat
  3. Run a heredoc command: cat <<'EOF' hello world EOF

Expected behavior

Command runs without approval prompt (heredoc is stdin input, per PR #13811).

Actual behavior

Approval required (id 7c36466c) Command: cat <<'EOF' hello world EOF

OpenClaw version

2026.4.14

Operating system

ubuntu

Install method

npm global

Model

glm

Provider / routing chain

openrouter

Additional provider/model setup details

No response

Logs, screenshots, and evidence

exec-approvals.json has:
Agent config: security: "allowlist", ask: "off"
"pattern": "/usr/bin/cat"

Impact and severity

No response

Additional information

No response

extent analysis

TL;DR

The heredoc fix regression can be worked around by re-examining the allowlist configuration for the target binary.

Guidance

  • Verify that the binary path in the allowlist matches the actual path used in the heredoc command, considering any potential differences in path resolution.
  • Check the exec-approvals.json file to ensure the allowlist pattern correctly includes the binary, and consider updating the pattern if necessary.
  • Test the command without heredoc syntax to confirm the allowlist is functioning as expected for the binary.
  • Review the changes introduced in PR #13811 to understand the intended behavior and potential areas where the regression might have occurred.

Example

No code snippet is provided due to the lack of specific implementation details in the issue.

Notes

The provided information suggests a configuration or pattern matching issue rather than a code-level problem, but without more details on the allowlist implementation or the changes in PR #13811, it's challenging to provide a definitive fix.

Recommendation

Apply workaround: Reconfigure the allowlist to ensure accurate matching of the target binary path, as the issue seems to stem from a mismatch or misconfiguration rather than a version-related problem.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

FAQ

Expected behavior

Command runs without approval prompt (heredoc is stdin input, per PR #13811).

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

openclaw - ✅(Solved) Fix [Bug]: heredoc (<<) triggers approval prompt in allowlist mode [3 pull requests, 1 comments, 2 participants]