claude-code icon indicating copy to clipboard operation
claude-code copied to clipboard

Allow curl

Open jmaddington opened this issue 1 year ago • 19 comments

I don't know how many times I see this: Command 'curl' is not allowed for security reasons

After which Claude promptly figures out it can do the exact same request with python's requests library.

Or write the command to a bash script and run that.

Disallowing curl just adds an unnecessary step, eats tokens, and eats context window space.

If the security team feels strongly about it, then I suggest adding a user confirmation first, like users are prompted for when using git, cp, ls etc. for the first time that session.

jmaddington avatar Feb 26 '25 22:02 jmaddington

make it a user option. You can have claude-code installed with it disabled, but at least give us the option to enable it. or at least require us to approve each usage of it.

brianthompson-sarcat avatar Feb 27 '25 16:02 brianthompson-sarcat

alexeygoncharov avatar Feb 28 '25 05:02 alexeygoncharov

Here is an example of Code bypassing it:

#!/bin/bash

# Get the API key from environment
API_KEY="XXX"

# Create a JSON payload for the contact
read -r -d '' PAYLOAD << EOM
{
  "first_name": "Curl",
  "last_name": "Test",
  "job_title": "Tester"
}
EOM

# Make the curl request
echo "Creating contact via curl..."
curl -v -X POST \
  "http://localhost:8000/api/v1/my_endpoint/" \
  -H "Content-Type: application/json" \
  -H "X-API-KEY: $API_KEY" \
  -d "$PAYLOAD"

echo "

I understand and appreciate the security concerns and absolutely support Anthropic for keeping it in mind, this just does not seem like an effective measure.

jmaddington avatar Feb 28 '25 12:02 jmaddington

My use case for using curl is to provide documentation page into the context via bash mode, e.g.

!curl -s https://r.jina.ai/https://www.npmjs.com/package/subtitle

Right now it says:

⏺ Command 'curl' is not allowed for security reasons

There is an easy workaround: prefix the command with env

!env curl -s https://r.jina.ai/https://www.npmjs.com/package/subtitle

dtinth avatar Mar 04 '25 16:03 dtinth

My use case for using curl is to provide documentation page into the context via bash mode, e.g.

!curl -s https://r.jina.ai/https://www.npmjs.com/package/subtitle Right now it says:

⏺ Command 'curl' is not allowed for security reasons

There is an easy workaround: prefix the command with env

!env curl -s https://r.jina.ai/https://www.npmjs.com/package/subtitle

where to put this !env line? > !env curl -s https://r.jina.ai/https://www.npmjs.com/package/subtitle

alexeygoncharov avatar Mar 04 '25 21:03 alexeygoncharov

@alexeygoncharov Use the “bash mode”.

In the Claude Code prompt

Image

type ! to activate bash mode

Image

then you can put in the command

Image

its result will be in Claude Code's context

dtinth avatar Mar 05 '25 06:03 dtinth

@igorkofman, sorry, but this seems like a completely different issue?

while #76 is already covered by a simple MCP server like fetch, disabled curl currently makes debugging http APIs (even local) difficult

Aivean avatar Mar 07 '25 02:03 Aivean

+1 it's really not helpful for local API development, it could at least allow this on localhost. Would love user confirmation for this path, it doesn't feel right that Claude Code would not be aware of its own limitation and run a command that will always fail, and proceed with a python workaround to make the request. Helpful to know about the !env option but generally feels like the current state isn't the optimal solution for this issue

ries9112 avatar Mar 23 '25 11:03 ries9112

Guys any progress here? Really need to allow potentially "dangerous" commands in config

puzanov avatar Apr 06 '25 08:04 puzanov

A general enhancement to provide Claude Code a list of URLs that are "pre-approved" and CLI commands "pre-approved" would be great.

JohnFlyIII avatar Apr 08 '25 16:04 JohnFlyIII

@JohnFlyIII CLI commands can be pre-approved, see allowedTools at https://docs.anthropic.com/en/docs/agents-and-tools/claude-code/overview

jmaddington avatar Apr 08 '25 16:04 jmaddington

excellent, I see that curl and wget are just on your internal blocklist. Thank you.

It would be nice to allow them :)

JohnFlyIII avatar Apr 08 '25 17:04 JohnFlyIII

@JohnFlyIII hah, I'm with you! I opened the request, sadly I'm not with Anthropic!

There is a claude YOLO npm package that removes basically all restrictions but I haven't tried it.

jmaddington avatar Apr 08 '25 18:04 jmaddington

I've just made an alias "claudeCurl" and embedded instructions in the project for claude code to run "claudeCurl" anytime it would use "curl". Seems to work and greatly helped in some local API bug fixing

JohnFlyIII avatar Apr 09 '25 14:04 JohnFlyIII

I've just made an alias "claudeCurl" and embedded instructions in the project for claude code to run "claudeCurl" anytime it would use "curl". Seems to work and greatly helped in some local API bug fixing

the presence of multiple workarounds just proves that disallowing curl is not working as a "safety feature", it just hurts the UX. would make much more sense to have it as an option (disabled by default)

Aivean avatar Apr 09 '25 16:04 Aivean

Good news. We've removed this restriction from the latest version of Claude Code (0.2.70)

Enjoy!

igorkofman avatar Apr 15 '25 14:04 igorkofman

@igorkofman Hey Igor, even though the curl restriction has been lifted, curl commands still aren’t executing automatically on my end. Is there anything I need to change in my settings to make it work?

Oliver-Richter avatar Jul 05 '25 10:07 Oliver-Richter

Should just work. If not, please open a new issue with a detailed repro.

igorkofman avatar Jul 05 '25 17:07 igorkofman

This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.

github-actions[bot] avatar Aug 14 '25 14:08 github-actions[bot]