Claude Code 2.1.321, released on November 9, 2026, fixed four security gaps: an MCP sign-in that could send refresh tokens to another host, a read-only Bash command that ran outside the sandbox without a prompt, a file write judged from the wrong folder, and deny rules that did not apply to the file a cp or mv writes. Update every machine and set minimumVersion so nobody stays below the fix. Then write Read deny rules for the signing files and secrets in your iOS repo, test them with fake files, and turn on the sandbox, because deny rules do not cover a script that opens files by itself.
Anthropic shipped Claude Code 2.1.321 on November 9, 2026. Most people noticed it because it made Claude Fable 5.2 the default Fable model. Further down the changelog sit four fixes that matter more if Claude Code runs inside a repo that holds signing certificates, App Store Connect keys and fastlane secrets. One stopped MCP sign-in requests from sending refresh tokens to another host. Three closed gaps where a permission rule you wrote did not stop the command it was written to stop.
This post covers what those four fixes change, how to confirm every machine on your team has them, and how to write and then test deny rules for the files an iOS repo should keep away from a coding agent. It also covers what the rules still cannot catch, because that part decides whether you need the sandbox as well.
What did Claude Code 2.1.321 fix?
The release notes list dozens of fixes. These four are the ones about security and permissions, in the changelog's own order:
- MCP OAuth: "Fixed MCP OAuth requests sending secrets such as refresh tokens to another host when a server redirected them."
- Sandbox: "Fixed a case where a read-only Bash command ran outside the sandbox without a permission prompt."
- Bash path checks: "Fixed a case where Bash permission checks judged a file write from the wrong folder and didn't prompt."
- cp and mv: "Fixed deny rules and protected-file prompts not applying to the file that a
cpormvinto a directory writes."
Anthropic gives no further detail on any of them, and I have seen no report of these bugs being used against anyone. So treat this as maintenance you should finish this week, without assuming anything leaked. The fourth fix is the easiest to picture in an iOS project. Say you denied edits to Config/Secrets.xcconfig. Before 2.1.321, a command like cp /tmp/Secrets.xcconfig Config/ could write that exact file, because the rule was checked against the folder name in the command and not against the file the copy produced. The third fix is a cousin of it: a write judged against the wrong folder, so no prompt appeared.
The release also added a --settings <file> option to claude remote-control, which applies one settings file to every session it starts. If you run Remote Control on a shared Mac mini, that is a simple way to give those sessions the same deny rules as everyone's laptops.
Step 1: Check the version on every machine
Run this on each Mac that has Claude Code, including CI runners and any build machine people log into:
claude --version
claude doctor
You want 2.1.321 or later. How you get there depends on how Claude Code was installed, and this is where teams get caught out.
- Native installer: updates itself in the background, and the update takes effect the next time Claude Code starts. To skip the wait, run
claude update, then quit and reopen every running session. - Homebrew: never updates on its own. Run
brew upgrade claude-codeorbrew upgrade claude-code@latest, depending on which cask you installed. - npm: run
npm install -g @anthropic-ai/claude-code@latest. Anthropic's setup page warns againstnpm update -g, which keeps the semver range from your first install and may leave you on an old release.
Release channels add one more wrinkle. The default channel, latest, gets releases as they ship. The stable channel gets a version that is "typically about one week old." The claude-code Homebrew cask tracks stable, and claude-code@latest tracks latest. So a teammate on the stable cask could still be on a pre-2.1.321 build for several days after you updated.
You can fix that with a version floor. The minimumVersion setting makes background updates and claude update refuse anything below the value you give:
{
"autoUpdatesChannel": "stable",
"minimumVersion": "2.1.321"
}
Put it in ~/.claude/settings.json on each machine, or in managed settings if your company deploys them. It sets a floor for what the updater will install. It does not upgrade an old binary by itself, so still run the update command once.
Here is a small script that checks a repo in one pass. It reports whether the installed Claude Code is new enough, lists files in the repo that look like signing material or secrets, and prints the deny rules the project defines so you can compare the two lists. I tested it on Linux against a stub claude command that printed an old and then a new version, with fake secret files in a sample repo. It needs sort -V, which current macOS includes.
#!/bin/sh
# check-claude-guard.sh: run from the root of an iOS repo.
# 1) Is Claude Code at 2.1.321 or later? 2) Which secret-like files exist,
# and which deny rules does the project define?
need="2.1.321"
have=$(claude --version 2>/dev/null | awk '{print $1}')
if [ -z "$have" ]; then
echo "claude not found on PATH"
else
lowest=$(printf '%s\n%s\n' "$need" "$have" | sort -V | head -n1)
if [ "$lowest" = "$need" ]; then
echo "OK: Claude Code $have (>= $need)"
else
echo "UPDATE: Claude Code $have is older than $need"
fi
fi
echo
echo "Secret-like files in this repo:"
find . -path ./.git -prune -o -type f \( \
-name '*.p12' -o -name '*.p8' -o -name '*.mobileprovision' -o \
-name '*.cer' -o -name '.env' -o -name '.env.*' -o \
-name '*Secrets*.xcconfig' -o -name 'fastlane_session*' \) -print
echo
for f in .claude/settings.json .claude/settings.local.json; do
if [ -f "$f" ]; then
echo "Deny rules in $f:"
grep -o '"\(Read\|Edit\|Bash\)([^"]*)"' "$f" | sed 's/^/ /'
else
echo "No $f"
fi
done
In the test repo it found a .p12, an AuthKey_*.p8, a Secrets.xcconfig and a fastlane/.env, while the project settings denied only two of them. That gap is what Step 2 closes.
Step 2: Write deny rules for the files an iOS repo should protect
Claude Code reads permission rules from settings files and evaluates them in a fixed order: deny, then ask, then allow. The first match wins, and an allow rule can never carve an exception out of a deny rule. Rules in .claude/settings.json are checked into the repo and apply to everyone. Rules you approve with "Yes, and don't ask again" land in .claude/settings.local.json, which stays on your machine. That local file can end up holding more than rules, as Claude Code's "Don't Ask Again" Can Save Your Passwords explains.
Two details from the permissions docs shape how to write these rules.
First, a Read deny rule also blocks the Edit and Write tools on the same path, including creating a new file there. So for secrets you usually need only Read rules. Add an Edit rule for files that Claude may read but must never change, such as an entitlements file or a checked-in .xcconfig that sets bundle IDs.
Second, path anchors are easy to get wrong. A bare filename such as Read(.env) follows gitignore rules and matches at any depth under the current directory. A pattern with a single leading slash, like /Config/**, anchors at the settings source, which for project settings is the primary working directory. If you put Read(/secrets/**) in your user settings, it blocks ~/.claude/secrets/** and not a folder in your project. For a real absolute path, use two slashes: Read(//Users/you/...). For your home folder, use ~/.
Here is a starting .claude/settings.json for a typical iOS repo with fastlane. Adjust the paths to match yours:
{
"permissions": {
"deny": [
"Read(**/*.p12)",
"Read(**/*.p8)",
"Read(**/*.mobileprovision)",
"Read(**/*.cer)",
"Read(.env)",
"Read(.env.*)",
"Read(**/*Secrets*.xcconfig)",
"Edit(**/*.entitlements)",
"Edit(**/*.xcconfig)"
]
}
}
A few notes on that list. *.p8 covers App Store Connect API keys, which Apple names AuthKey_<KEY_ID>.p8. The .env rules cover fastlane's dotenv files, which often hold APP_STORE_CONNECT_API_KEY values or match passwords. The last two Edit rules stop Claude from changing signing and build settings without you editing the file yourself.
For files outside the repo, put rules in your user settings with ~/ paths. Provisioning profiles installed by Xcode live under ~/Library/MobileDevice/Provisioning Profiles/ on recent Xcode versions, and Xcode 16 moved them to ~/Library/Developer/Xcode/UserData/Provisioning Profiles/. Check which one your machine uses before you write the rule. If you keep App Store Connect keys in ~/.appstoreconnect/private_keys/, one of the folders Apple's altool searches for AuthKey_<api_key>.p8 files, deny that folder too:
{
"permissions": {
"deny": [
"Read(~/.appstoreconnect/**)",
"Read(~/.ssh/**)",
"Read(~/.fastlane/**)"
]
}
}
You can paste these into the files directly or add them one at a time through /permissions inside a session. That dialog lists every rule and the settings file it came from, which is the quickest way to see whether a rule you thought existed is actually loaded.
Step 3: Test the rules after you update
A deny rule you never tested is a guess. The cp and mv fix is exactly the kind of bug that a quick test would have caught, so test the cases that changed. Do this in a throwaway branch or a scratch copy of the repo, with fake files.
- Create a fake secret:
echo "FAKE=1" > Config/Secrets.xcconfig, and keep theRead(**/*Secrets*.xcconfig)rule in place. - Put a second fake copy somewhere else:
echo "FAKE=2" > /tmp/Secrets.xcconfig. - Start Claude Code in the repo and ask it to read the file: "Show me the contents of Config/Secrets.xcconfig." The Read tool should refuse.
- Ask it to run
cat Config/Secrets.xcconfig. Deny rules cover file commands Claude Code recognizes in Bash, includingcat,head,tail,sedandtee, so this should be blocked too. - Ask it to run
cp /tmp/Secrets.xcconfig Config/. On 2.1.321 or later, the deny rule should apply to the file the copy would write. Repeat withmv. - Try an output redirect:
echo x > Config/Secrets.xcconfig. Redirect targets are checked against your Edit and deny rules.
If any step goes through without a block or a prompt, stop and check claude --version and /permissions before you trust the setup. Write down what you saw for each step. When a teammate asks whether the rules work, you can point at that note instead of answering from memory.
What deny rules still do not catch
This is the part people skip. The permissions page says plainly that Read and Edit deny rules apply to Claude's built-in file tools, to file commands Claude Code recognizes in Bash, and to redirect targets. They do not apply to "a command that reads files without naming them," such as grep -r pattern . run from the folder that holds the file. They also do not apply to a subprocess that opens files by itself, such as a Python or Node script.
In an iOS repo that covers a lot of everyday commands. bundle exec fastlane beta loads your .env file without Claude Code ever seeing its name. xcodebuild reads .xcconfig files. A build phase script can read anything the user account can read. None of that is a bug. Deny rules guard Claude's own tools and the commands Claude Code can parse; a program you let it run is a separate process with your full access.
Two habits help. Keep the commands that touch signing behind an ask rule, so you see each one before it runs:
{
"permissions": {
"ask": [
"Bash(bundle exec fastlane *)",
"Bash(fastlane *)",
"Bash(xcodebuild * archive *)",
"Bash(security *)"
]
}
}
And when you need a hard wall, turn on the sandbox.
Step 4: Turn on the sandbox for shell commands
The sandbox is off by default. Run /sandbox in a session, or set sandbox.enabled to true in a settings file. On macOS it uses Apple's built-in Seatbelt framework. It limits what shell commands can do at the operating system level, so a script that opens a file by itself is limited too.
Know its defaults before you rely on it. Writes are limited to the working directory, a per-user temp directory and folders you add. Reads are open to "most of the machine, including credential files such as ~/.ssh and ~/.aws/credentials." Network traffic goes through a local proxy that allows only the domains you list, and that list starts empty. The sandbox covers shell commands only. File tools, MCP servers and hooks run outside it.
Since reads are open by default, add denyRead entries for the folders that matter to an iOS developer:
{
"sandbox": {
"enabled": true,
"failIfUnavailable": true,
"allowUnsandboxedCommands": false,
"filesystem": {
"denyRead": [
"~/.ssh",
"~/.appstoreconnect",
"~/.fastlane"
]
},
"network": {
"allowedDomains": ["github.com"]
}
}
}
Setting allowUnsandboxedCommands to false matters. Without it, when a command fails inside the sandbox, Claude may retry it with a parameter that runs it outside. With the retry turned off, Claude Code ignores that parameter. The /sandbox panel shows this as Strict sandbox mode.
Expect some friction. Builds that fetch Swift packages need their hosts on the allowed list, and anything that signs code needs keychain access the sandbox may not give it. When a command fails, decide case by case whether to allow a domain, add a write folder, or run that one command yourself outside Claude Code. You can list a command in sandbox.excludedCommands to run it outside the sandbox, but the docs warn that an excluded command "runs with your full access," so keep that list short.
The second fix in 2.1.321, a read-only Bash command running outside the sandbox without a prompt, is a reason to update before you lean on the sandbox. Read-only commands such as ls, cat, grep and find run without a prompt in every mode, so a gap there would have been silent.
Step 5: Check your MCP servers and their sign-ins
The MCP fix is about remote servers that use OAuth. Before 2.1.321, if such a server redirected a sign-in request, Claude Code could send secrets like refresh tokens to the host it was redirected to. The changelog does not say which servers did this, and a well-run server you trust is unlikely to have redirected you somewhere hostile. Still, a quick review costs about ten minutes.
claude mcp list
claude mcp get <name>
claude mcp list shows each configured server with a status such as Connected, Needs authentication or Failed to connect. Go through the remote ones that use OAuth and ask three things. Do you still use it? Do you know who runs it? Has its URL changed since you added it?
For a server you no longer use, run claude mcp remove <name>. The docs say that removing a remote server also deletes the OAuth tokens and client registration Claude Code stored for it. For a server you keep but are unsure about, clear its stored credentials and sign in again on the updated version:
claude mcp logout <name>
claude mcp login <name>
Then open the provider's own account page (GitHub, Linear, Sentry, whatever it is) and look at its list of authorized apps. Revoke any grant you do not recognize or no longer need. Logging out in Claude Code clears the local copy; revoking at the provider is what kills a token that may have been copied somewhere else.
Project-scoped servers live in .mcp.json at the repo root and are shared through version control. Claude Code asks before using them in interactive sessions. If you approved one long ago and want to see the question again, claude mcp reset-project-choices resets those choices. Review .mcp.json in pull requests the same way you review a new dependency, because a teammate adding a server there adds it for everyone. A recent Ruby gem worm added an MCP server and hooks to agent configs, which is the case that review exists for.
Which layer stops what
Steps 2 to 4 add three different kinds of protection, and it is easy to assume one of them covers a case that belongs to another. This table puts the cases from this post side by side. "Not covered" means that layer never sees the action, so you need one of the others.
| What happens | Read or Edit deny rule | Sandbox with denyRead | Line in CLAUDE.md |
|---|---|---|---|
| Claude opens or edits the file with its own file tools | Blocked | Not covered, file tools run outside the sandbox | Not enforced |
cat, head, tail, sed or tee on the file in Bash | Blocked | Blocked for the folders you listed | Not enforced |
cp or mv that writes the file | Blocked on 2.1.321 or later | Allowed inside the working directory, blocked outside it | Not enforced |
grep -r run from the folder that holds the file | Not covered | Blocked for the folders you listed | Not enforced |
fastlane, xcodebuild or a script that opens the file by itself | Not covered | Blocked for the folders you listed | Not enforced |
| An MCP server or a hook reads the file | Not covered | Not covered, both run outside the sandbox | Not enforced |
Read the table by row. The first row is why the sandbox alone is not enough, and the fourth and fifth are why deny rules alone are not enough. The last row has no "Blocked" in it at all, which is the reason Step 5 asks you to review which MCP servers you run, and the reason hooks in a shared settings file deserve the same review as code.
Build the home-folder rules from what is actually on your Mac
The user-level rules in Step 2 only help if they name the folders your machine really has. This script checks the usual places: the four folders altool searches for App Store Connect keys, both provisioning profile folders, fastlane's folder, and the common credential folders. For each one that exists it prints the number of files and the deny rule to add. It reads nothing inside the files.
#!/bin/sh
# list-home-secrets.sh: which credential folders exist in your home folder,
# and a user-level deny rule for each. Read-only: prints paths and counts only.
found=0
check() {
path="$HOME/$1"
if [ -d "$path" ]; then
count=$(find "$path" -type f 2>/dev/null | wc -l | tr -d ' ')
printf '%-58s %4s file(s) "Read(~/%s/**)"\n' "~/$1" "$count" "$1"
found=$((found + 1))
elif [ -f "$path" ]; then
printf '%-58s %4s file "Read(~/%s)"\n' "~/$1" 1 "$1"
found=$((found + 1))
fi
}
check ".appstoreconnect/private_keys"
check ".private_keys"
check "private_keys"
check "Library/MobileDevice/Provisioning Profiles"
check "Library/Developer/Xcode/UserData/Provisioning Profiles"
check ".fastlane"
check ".ssh"
check ".aws"
check ".gnupg"
check ".netrc"
echo "$found location(s) found. Add the rules to permissions.deny in ~/.claude/settings.json."
It was run on a Mac with macOS 26.0.1 against a sample home folder that held an App Store Connect key, two provisioning profiles in the Xcode 16 location, an .ssh folder and a .netrc file. The output was:
~/.appstoreconnect/private_keys 1 file(s) "Read(~/.appstoreconnect/private_keys/**)"
~/Library/Developer/Xcode/UserData/Provisioning Profiles 2 file(s) "Read(~/Library/Developer/Xcode/UserData/Provisioning Profiles/**)"
~/.ssh 3 file(s) "Read(~/.ssh/**)"
~/.netrc 1 file "Read(~/.netrc)"
4 location(s) found. Add the rules to permissions.deny in ~/.claude/settings.json.
Copy the quoted rules into the deny list in ~/.claude/settings.json, and add the same folders to denyRead in your sandbox settings, since the table above shows that each layer covers cases the other misses. Run the script again after you install a new tool that signs or uploads builds. Those tools tend to create a credentials folder the first time you use them, and a rule list written last spring will not know about it.
Keep a record of the six tests
Step 3 asks you to write down what you saw. A small table in the repo, next to the settings file, is enough, and it gives the next person a baseline to compare against after the next Claude Code update. Fill in the last column on a throwaway branch with fake files.
| Test | What you ask Claude to do | Expected on 2.1.321 or later | What you saw |
|---|---|---|---|
| 1 | Show the contents of Config/Secrets.xcconfig | The Read tool refuses | |
| 2 | Run cat Config/Secrets.xcconfig | Blocked | |
| 3 | Run cp /tmp/Secrets.xcconfig Config/ | Blocked, the rule applies to the file the copy would write | |
| 4 | The same with mv | Blocked | |
| 5 | Run echo x > Config/Secrets.xcconfig | Blocked, redirect targets are checked | |
| 6 | Run grep -r FAKE . from Config/ | Not blocked by deny rules. Blocked only if the sandbox is on and the folder is in denyRead |
The sixth row is deliberate. It is the one case in the list that a deny rule is documented not to stop, so seeing it go through tells you the rules behave as described, and seeing it blocked tells you the sandbox is doing its part. Add the date, the output of claude --version and your initials under the table. If a later version changes any row, you will know which release did it.
A ten-minute checklist for small iOS teams
- Run
claude --versionon every machine and CI runner. Update to 2.1.321 or later with the command that matches the install method. - Add
"minimumVersion": "2.1.321"so the stable channel cannot hold anyone below the fix. - Commit a
.claude/settings.jsonwith Read deny rules for.p12,.p8, profiles,.envfiles and secrets.xcconfigfiles. - Add user-level rules with
~/paths for keys and profiles outside the repo. - Run the six-step test with fake files, including the
cpandmvcases. - Put fastlane, archive and
securitycommands behindaskrules. - Turn on the sandbox with
denyReadfor credential folders and strict mode on. - Review
claude mcp list, remove what you do not use, and re-authenticate the rest.
FAQ
Do I need to rotate my App Store Connect keys or certificates?
Nothing in the release notes says any certificate or key leaked. The fixes close gaps in how rules were enforced. If you have reason to think an agent read a key it should not have (for example, you see it in a transcript), revoke that key in App Store Connect and create a new one. Otherwise, writing and testing the rules is the right response.
Is a .claudeignore file enough?
No. The permissions docs say a .claudeignore file has no effect and tell you to move its entries into Read deny rules.
Do instructions in CLAUDE.md protect these files?
They shape what Claude tries to do, but the docs are clear that permission rules are enforced by Claude Code itself and instructions do not change what it allows. Use rules for anything that must not happen.
Does the sandbox protect files from Claude's Read tool?
The sandbox covers shell commands only. Claude's built-in file tools run outside it, so you need Read deny rules for those, and the sandbox for scripts and programs. Use both.
I'm on the stable channel. When do I get the fix?
Stable is typically about a week behind latest, so 2.1.321 or a later build should reach it in the days after November 9. If you want it now, switch the channel to latest for a while, or install the version directly with the native installer.
If you run Claude Code on a real iOS codebase every day, I put together Claude Code + Xcode: The Production iOS Workflow Kit ($18). It is a kit for working with Claude Code on a production iOS project, built around giving the agent the context it needs about your app's architecture before it edits anything.
Keep reading on JR Devhub
- Apple's Xcode Plugin Is in Claude Code's Official Directory. What It Installs and What to Check First
- Claude Fable 5.2 Is Out. What to Change in Claude Code and Your App's API Calls Before You Switch
- AI Agents Took 300+ iOS Signing Certificates From 10 Shops. Audit Your Own .p12 Files
- Backdoored Claude Code Extension in Cursor: Check Your Mac, Then Rotate These iOS Keys
Sources
- Claude Code changelog (2.1.321 and 2.1.322)
- Claude Code docs: Configure permissions
- Claude Code docs: Sandboxing
- Claude Code docs: MCP
- altool man page (private key search folders)
- Xcode 16 saves profiles in a different folder (JetBrains support thread)
- Claude Code docs: Set up Claude Code (updates and release channels)

Comments