Normalize fd redirects in command safety check#208
Closed
backnotprop wants to merge 2 commits intomainfrom
Closed
Conversation
The `>` redirect detection in isSafeCommand() was falsely blocking common curl patterns like `curl ... 2>/dev/null` and `curl ... 2>&1 | head`. This prevented agents from fetching web content (e.g. via jina.ai or markdown.new) during planning mode. Fix: strip safe fd redirects (2>/dev/null, 2>&1, &>/dev/null) from the command before checking against destructive patterns, while still blocking actual file redirects like `> output.txt`. https://claude.ai/code/session_01Jk1P5aZPERSzrmA9urfb4B
The planning phase system prompt says "bash (read-only commands only)" which causes models to self-censor and not attempt curl/wget for web content fetching (e.g. jina.ai, markdown.new). Update the prompt to explicitly mention curl/wget is allowed, and mention web fetching in the explore step instructions. https://claude.ai/code/session_01Jk1P5aZPERSzrmA9urfb4B
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Updated the
isSafeCommandfunction to normalize file descriptor redirects before checking against destructive patterns. This prevents legitimate commands with safe output redirections from being incorrectly flagged as unsafe.Key Changes
N>/dev/null- redirects any file descriptor to /dev/nullN>&M- file descriptor merges (e.g.,2>&1)&>/dev/null- bash shorthand for redirecting all output to /dev/nullImplementation Details
The fix addresses a false positive issue where commands like
curl ... 2>/dev/nullorcurl ... 2>&1 | headwould be incorrectly blocked by the>destructive pattern rule. By removing these safe redirections before pattern matching, we allow legitimate commands while maintaining security checks for actual destructive operations.https://claude.ai/code/session_01Jk1P5aZPERSzrmA9urfb4B