[BUG] Claude Code requesting sudo in Mac OS terminal
Preflight Checklist
- [x] I have searched existing issues and this hasn't been reported yet
- [x] This is a single bug report (please file separate reports for different bugs)
- [x] I am using the latest version of Claude Code
What's Wrong?
Claude is requesting sudo, which it couldn't have accomplish without a password, but if I had done sudo in the past 5 minutes it could have. With prompt injection being a real risk for a security issue. I don't have a screeenshot but I have this log from Claude action log when it said it would update itself to prevent that in the future.
What Should Happen?
Claude should request me to do sudo commands, fully explain what they are, and provide justification for doing them. It should then tell me it will interpret the events. This is for all users benefit, especially new users putting Cllaude Code in their terminal/powershells.
Error Messages/Logs
Fair point — I should not have reached for sudo without your explicit go-ahead each time. Holding off until you've made the call on the bug report. I'll stay out of sudo entirely from here on and give you commands to run yourself when root is needed.
Saving that as feedback so future sessions don't repeat the mistake.
⏺ Write(/Users/(redacted)/.claude/projects/-Users-inthebay/memory/feedback_no_unprompted_sudo.md)
⎿ Wrote 14 lines to /Users/inthebay/.claude/projects/-Users-(redacted)/memory/feedback_no_unprompted_sudo.md
1 ---
2 name: feedback-no-unprompted-sudo
3 description: Never run sudo commands without an explicit per-command go-ahead from the user; print the command for them to run instead
4 metadata:
5 node_type: memory
6 type: feedback
7 originSessionId: e7a88420-8545-4ea3-92d0-72ba9b9861a5
8 ---
9
10 Do not invoke `sudo` from Bash even when the user has approved a task that "needs root." Instead, print the exact command in a code block and ask the user to run it.
11
12 **Why:** User flagged on 2026-05-24 that Claude having any standing sudo capability is itself the problem, regardless of task approval — they were going to file it as a bug with Anthropic. A general "yes, do the re-chown" should not be i
nterpreted as "you may sudo to do it."
13
14 **How to apply:** When a step requires root (chown across TCC paths, `pmset` writes, `littlesnitch list-preferences`, kext/system extension actions, `/etc/*` edits, etc.) — surface the command as copyable text for the user to paste. Non-
root operations on user-owned files (`~/.bashrc`, `~/.bash_profile`, `~/Library` reads, `~/.claude/*`) are fine via Edit/Write/Read as normal. If sudo is genuinely needed and the user explicitly says "go ahead and run sudo for this," tha
t one invocation is permitted; the next sudo needs the next ack.
🤘 (redacted)@~ $ claude --version
2.1.150 (Claude Code)
Steps to Reproduce
I am happy to provide more logs to Anthropic directly, I don't know how to reproduce a model asking for sudo privileges, this should be bred into the design, not something a model can decide on its own.
Claude Model
Sonnet (default)
Is this a regression?
I don't know
Last Working Version
_No response_
Claude Code Version
2.1.150
Platform
Anthropic API
Operating System
macOS
Terminal/Shell
Terminal.app (macOS)
Additional Information
_No response_
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗