claude-code - 💡(How to fix) Fix [BUG] False positive Ask prompt in sandbox auto-allow for python3 -c with inline # comments [2 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
anthropics/claude-code#45008Fetched 2026-04-09 08:15:32
View on GitHub
Comments
2
Participants
2
Timeline
8
Reactions
1
Author
Timeline (top)
labeled ×4commented ×2cross-referenced ×1subscribed ×1

Error Message

Error Messages/Logs

Code Example

Newline followed by # inside a quoted argument can hide arguments from path validation
RAW_BUFFERClick to expand / collapse

Preflight Checklist

  • I have searched existing issues and this hasn't been reported yet
  • This is a single bug report (please file separate reports for different bugs)
  • I am using the latest version of Claude Code

What's Wrong?

I ran a python3 -c command with a multiline string containing a standard Python # comment.

Claude displayed an Ask prompt with the warning:

Newline followed by # inside a quoted argument can hide arguments from path validation

This occurred even though sandbox is enabled with auto-allow for bash commands (/sandbox → auto-allow mode).

What Should Happen?

In sandbox auto-allow mode, this command should execute without an Ask prompt. The # character is a standard Python comment inside a quoted string argument, not a shell argument-hiding technique. The sandbox already provides OS-level filesystem and network isolation, making the additional Ask prompt redundant.

Error Messages/Logs

Newline followed by # inside a quoted argument can hide arguments from path validation

Steps to Reproduce

  1. Enable sandbox with auto-allow: run /sandbox and select auto-allow mode

Test 1 — Ask appears (false positive): python3 -c " print('a')

comment

print('b') " Result: Ask prompt displayed with "Newline followed by #" warning.

Test 2 — No Ask (control, no #): python3 -c " print('a') print('b') " Result: Executes immediately, no Ask prompt.

Test 3 — No Ask (control, # in file): cat > /tmp/test_comment.py << 'EOF' print('a')

comment

print('b') EOF python3 /tmp/test_comment.py Result: Executes immediately, no Ask prompt.

Isolation note: Each test was run in a separate session turn (after the previous response completed). This behavior occurs consistently across multiple runs.

Claude Model

Opus

Is this a regression?

I don't know

Last Working Version

No response

Claude Code Version

2.1.94

Platform

Anthropic API

Operating System

macOS

Terminal/Shell

Other

Additional Information

This behavior suggests that a heuristic may be matching \n# inside quoted arguments to detect potential shell argument hiding. However, this pattern is common in legitimate python3 -c usage, where # is simply a Python comment character. The same content in a .py file does not trigger the warning.

This creates practical friction: in sandbox auto-allow mode, the user expects uninterrupted execution for safe commands. Frequent false positives for routine Python one-liners can lead to approval fatigue, reducing the signal value of the prompt when it does flag genuinely risky commands.

One possible direction: when the # appears inside a quoted string argument to an interpreter (python3 -c, ruby -e, etc.), it is likely a language-level comment rather than a shell argument-hiding vector.

extent analysis

TL;DR

The issue can be addressed by refining the heuristic to distinguish between shell argument hiding and language-level comments in quoted string arguments.

Guidance

  • Review the current heuristic for detecting shell argument hiding and consider adding exceptions for language-level comments in quoted string arguments.
  • Test the updated heuristic with various Python one-liners containing # comments to ensure it correctly identifies legitimate usage.
  • Consider adding a whitelist for specific interpreter commands (e.g., python3 -c, ruby -e) to reduce false positives.
  • Evaluate the impact of this change on the overall security posture of the system, ensuring it does not introduce new vulnerabilities.

Example

No code snippet is provided as the issue does not require a specific code change, but rather a refinement of the existing heuristic.

Notes

The solution may require a deeper understanding of the Anthropic API and the Claude Code Version 2.1.94. Additionally, the fix should be carefully tested to avoid introducing new security vulnerabilities.

Recommendation

Apply a workaround by refining the heuristic to reduce false positives, as upgrading to a fixed version is not implied in the issue. This approach allows for a targeted solution to the specific problem, minimizing potential disruptions to the system.

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…

Still need to ship something?

×6

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

Back to top recommendations

TRENDING