gloss

One Space in --allowedTools Turns Your Rule Into All of Bash

A space before the parenthesis in --allowedTools 'Bash (make *)' made a headless Claude Code run allow every shell command, and four other typos in --disallowedTools blocked nothing while the job exited 0.

A closed steel padlock hangs from the hasp on a galvanised wire cage gate that stands slightly open, with server racks blurred behind the mesh.
  • I passed --allowedTools 'Bash (make *)', with one space before the parenthesis, to a headless Claude Code run. It ran touch. Claude Code split the value into Bash and a leftover, and a bare Bash lets shell commands run without asking.
  • Four other typos in --disallowedTools blocked nothing: a missing ), text after the ), a lowercase bash, and a rule cut in two by an unquoted shell variable. The command I meant to block ran, and the job exited 0.
  • Claude Code 2.1.326, published 16 November, adds a startup warning for most of these. It prints in text mode only. With --output-format json, none of my runs printed it.

Yesterday I wrote that for CI I'd pass --allowedTools for the commands a job needs. That evening 2.1.326 went to npm with 367 changelog entries. One of them adds a startup warning when an --allowedTools, --disallowedTools or --tools value has an entry that "doesn't look like a complete rule".

So until this week an incomplete rule got no such warning. I tested what one did on 2.1.325, and what 2.1.326 changes.

What I ran

The same setup as yesterday: a scratch git repository with a Makefile, and one claude -p call per test on Haiku 5.5, asking for exactly one shell command. Only project settings loaded, no MCP servers, no sandbox block. I used the native macOS binaries of 2.1.325 and 2.1.326.

That came to 88 runs. The 47 that report a cost add up to 3 cents.

With no flags at all, touch build.marker is refused, because nobody is there to approve it.

The allow list

The rule I meant was "allow make, nothing else". I wrote it six ways and asked for make test and for touch build.marker.

--allowedTools value make test touch build.marker
'Bash(make *)' ran refused
'Bash(make *' refused refused
'Bash (make *)' ran ran
'Bash(make' '*)' as two arguments refused refused
'bash(make *)' refused refused
'Bash(make *)x' refused refused

Both versions gave the same result in every row.

Four of the five typos allow nothing. The job does no work and still exits 0, which is annoying and safe.

The space fails the other way. Claude Code separates list entries on commas and on spaces outside parentheses, so Bash (make *) becomes Bash and (make *). The second piece is thrown away. The first is a complete rule, and a bare Bash on the allow list lets shell commands run without asking. touch ran, and the result listed no denials.

The documented forms are fine. A comma list like 'Bash(make *), Read' printed no complaint, and neither did a rule with parentheses inside it.

The deny list

For the deny side I allowed all of Bash and tried to carve out one command: --allowedTools Bash with a --disallowedTools entry for touch.

--disallowedTools value touch build.marker
'Bash(touch *)' refused
'Bash(touch *' ran
'Bash (touch *)' Bash removed from the session
'Bash(touch' '*)' as two arguments ran
'bash(touch *)' ran
'Bash(touch *)x' ran

Again the two versions matched. In four rows the command I meant to block ran, and each of those runs exited 0 with "subtype": "success".

The space row went the other way. The docs say a bare tool name on the deny list removes that tool from Claude's context, and Bash (touch *) contains a bare Bash. Neither touch nor make test ran. Claude replied that the Bash tool was disabled for the session.

That run also had an empty permission_denials array, because no command was ever submitted for approval. The check I recommended yesterday passes on a job that did none of its work.

How a rule gets cut in two

The two-argument row looks artificial. It is what bash does to an unquoted variable:

DENY='Bash(touch *)'
claude -p "$PROMPT" --disallowedTools $DENY

On macOS's bash 3.2, $DENY reaches Claude Code as Bash(touch and *). With quotes around it, it arrives whole.

zsh does not split unquoted variables. The same line works in a zsh terminal on a Mac and breaks in a CI step that runs bash.

What each version printed

In text mode, 2.1.325 already printed something for some of these. On the allow list, four of the five typos got a line starting Ignoring --allowedTools rule, followed by a remark that wildcard tool names are "not supported in allow rules". That describes a different mistake.

On the deny list, 2.1.325 printed nothing for the missing parenthesis, the space, or the trailing text. The split rule and the lowercase one got a line saying the rule "matches no known tool".

2.1.326 adds this, for both lists:

--disallowedTools: "Bash(touch *" doesn't look like a complete rule, so a tool you meant to block may still run. A rule looks like Bash or Bash(git *). Check for a missing ")", a space before "(", or text after ")".

The allow-list version says "this list may allow more or less than you meant". The new line covered the missing parenthesis, the space, the split and the trailing text. Lowercase bash got no new line on either list.

It is a warning. The run continues and exits 0, and the commands ran or didn't exactly as in the tables above.

JSON output prints none of it

Everything in the last section came from text-mode runs. With --output-format json, 34 of my runs had a malformed entry, 17 on each version. stderr was zero bytes in every one, the older messages included.

On 2.1.326 I also tried stream-json, and json with --verbose. No event in the output carried the warning.

JSON output is what a pipeline parses, and it is where permission_denials lives. A CI job built that way never sees the line 2.1.326 added.

One thing does show up there. The first stream-json event lists the session's tools, and in the space case Bash was missing from it.

A settings file skips the rule too

The new warning suggests moving the rule to permissions.deny in a settings file. I put Bash(touch * in a file and passed it with --settings.

In text mode, both versions printed "These settings entries were skipped; the rest of each file is in effect" and named the rule. In a JSON run with the same file, touch ran, the job exited 0, and stderr was empty.

The prompt that became a rule

A second entry in 2.1.326 fixes "a prompt typed after --add-dir, --allowedTools or another list option being dropped without a message". A list option takes every word that follows it, so a prompt at the end of the line becomes one more rule.

With empty stdin, both versions stop with exit 1 and say no input was provided. You'd notice that.

With piped input you wouldn't. I piped in "Reply with the single word pineapple." and put a prompt asking for mango after --allowedTools. Both versions answered pineapple and exited 0. 2.1.325 printed nothing. 2.1.326 says the mango prompt "was read as a value of --allowedTools, not as a prompt".

git diff | claude -p --allowedTools Read "Review this diff" has the same shape. Claude would get the diff and no instruction.

What I'd do

Put the prompt directly after -p, and quote every rule and every variable that holds one.

Check rule strings before the run, one rule per array element. This test passed my good rules, including the one with inner parentheses, and failed all six broken pieces:

re='^([A-Z][A-Za-z]*|mcp__[A-Za-z0-9_*-]+)(\(.*\))?$'
for rule in "${RULES[@]}"; do
  [[ "$rule" =~ $re ]] || { echo "bad rule: $rule"; exit 1; }
done

For a deny rule that matters, test the rule itself. Send one probe run that asks for the blocked command, and check that permission_denials names it. On Haiku 5.5 each of mine cost a fraction of a cent.

If your job runs in text mode on 2.1.326, fail it when stderr contains "doesn't look like a complete rule".

I didn't test --tools, the GitHub Action, the SDK options, or Linux and Windows. npm's latest tag is 2.1.326 and stable is still 2.1.311, so a pipeline pinned to stable has neither of the new messages yet.

In JSON mode, four of my six deny rows gave exactly one sign of the typo: the blocked command ran.