Apiiro published a count this month that every Claude Code user should check against their own machine: 2,539 real secrets in 1,994 public GitHub repositories, most of them traced to one choice on a permission prompt. When you pick "Yes, and don't ask again" for a shell command, Claude Code stores an allow rule in .claude/settings.local.json. If the command had a password in it, the rule can have the password too.

iOS projects have their own version of this. A session that repairs signing or uploads a build can run commands holding a fastlane match passphrase, an app-specific password or the password for a .p12. This post gives you a script that finds those values, the order to clean them up in, and a hook that blocks the next one.

One limit before the code. The script, the git commands and the hook were tested on Linux against a throwaway repo filled with made-up values. They were not run on a Mac or on a real project, and the prompt behaviour described here comes from Apiiro's report and Anthropic's documentation.

What Apiiro counted

Apiiro listed every public copy of the file it could find on GitHub between November 1 and 3: 104,185 copies in 103,617 repositories. Of those, 1,122 files (1.1%) held a real secret, for 1,379 distinct values. Adding the file's git history, shared settings.json files and saved agent transcripts brings the total to 2,539.

"Real" has a specific meaning in that report. A value counts if it matches a known provider format, or if it is a password or token sitting next to a public host. Apiiro did not try any credential, so it can't say how many still work. One organization it contacted confirmed its key had been live.

The breakdown is mostly server access. More than a third of the values open a database directly, including 379 database passwords and 122 Supabase service-role keys. Another 103 are Supabase account tokens. There are also 43 SSH logins, 42 GitHub, GitLab and npm tokens, 23 AWS keys and 6 private keys.

Three other numbers matter for the cleanup:

  • File size tracks risk. One in ten files over 8 KB held a real secret, against fewer than one in 500 under 500 bytes. A long allow list means a long history of clicking through.
  • Deleting the file doesn't remove the problem. Older versions of it held 734 secrets, in 509 repositories, that appear in no current copy. Another 211 forks of 74 repositories carry the same values.
  • Ordinary scanners miss a lot of this. Of the 1,122 files, gitleaks flagged 564 and TruffleHog 643, and neither flagged 215. Both look for key formats, and a password after PGPASSWORD= or sshpass -p looks like any other word on a command line.

Those figures cover public repositories only. A private repo was outside the study, and so is the copy of the file sitting on your laptop.

How a password ends up in an allow rule

Anthropic's permissions page says a "don't ask again" approval for a Bash command lasts permanently per repository and command, and is saved to .claude/settings.local.json at the root of the git repository. Sometimes the prompt offers a prefix such as npm test *. Apiiro's finding is about the other case, where the saved rule is the command string itself.

The secret gets into the command because the agent needs it to do the job. Ask for a look at why a staging login fails and the proposed command may carry a connection string from a config file. It is one word in a long line, shown in the middle of a session with many prompts.

Claude Code does try to keep this file out of git. The settings documentation says that the first time it writes the file in a repository that doesn't already ignore it, it adds **/.claude/settings.local.json to your global git excludes. That protection lives on one computer. Apiiro lists the gaps: a folder that becomes a repo later, a clone on another machine, and a file that was already committed. The rule never goes into the repository's own .gitignore.

In 539 of the 1,105 repositories Apiiro traced, a commit co-authored by Claude changed the file.

Boris Cherny, Anthropic's head of Claude Code, replied on Hacker News on November 7, according to Apiiro's update. He said the team is "looking into what we can do to prevent this" and named auto mode catching it and basic secret scanning as ideas to prototype. He also said Claude Code ignores the file when it creates it, so in his view the exposed copies were created by hand and checked in. As of Apiiro's November 8 update no fix had shipped. Your cleanup is the same however the file got there.

What to look for in an iOS repo

Apiiro's list leans toward web backends, because that is what public repositories hold most of. These are the values to add for an Apple project.

ValueHow it appears in a commandWhy it matters
MATCH_PASSWORDSet inline before fastlane matchThe passphrase that decrypts your certificates and profiles in a match git repo
FASTLANE_SESSIONSet inline before a laneAn Apple session cookie. fastlane says validity can run from 1 day to 1 month
FASTLANE_APPLE_APPLICATION_SPECIFIC_PASSWORDSet inline before an uploadLets the holder upload binaries under your Apple Account
App-specific passwordAfter -p in older altool commandsSame password, in the format xxxx-xxxx-xxxx-xxxx
.p12 passwordsecurity import ... -PWith the file, it gives the private key that signs your builds
Keychain passwordsecurity unlock-keychain -pOpens the keychain that holds signing identities
App Store Connect API keyUsually a path to a .p8, sometimes pastedApple says team keys reach all apps, and Admin keys can create and delete users

GitHub's guide for signing on macOS runners shows those two security commands reading from environment variables, which is the shape you want. A session that retypes them with real values is the shape to look for.

Signing material has buyers. Check Point reported on November 5 that one operator, between October 14 and 29, used AI agents to break into 10 iOS certificate shops and collect more than 300 .p12 files with their passwords. Three passed validation and could sign arbitrary iOS apps. That campaign had nothing to do with Claude Code settings. It shows what a .p12 and its password are worth together.

Step 1: Scan your machine

Save this as tools/claude_allow_audit.py. It needs only Python 3. It walks a folder, reads every settings.json and settings.local.json inside a .claude directory, and prints masked results: the first two characters and the length, so the output is safe to paste into a ticket.

#!/usr/bin/env python3
"""Find secrets saved in Claude Code settings files. Prints masked values only."""
import json, os, re, sys

NOT_VAR = r"(?!\$|@env:|@keychain:)"
PATTERNS = [
    ("Postgres password", rf"PGPASSWORD=['\"]?{NOT_VAR}([^\s'\"]+)"),
    ("sshpass password", rf"sshpass\s+-p\s*['\"]?{NOT_VAR}([^\s'\"]+)"),
    ("MySQL password", rf"mysql\b[^|;&]*?\s-p{NOT_VAR}([^\s'\"]+)"),
    ("password in URL", rf"[a-z][a-z0-9+.-]*://[^/\s:@]+:{NOT_VAR}([^@\s/]+)@"),
    ("curl -u password", rf"curl\b[^|;&]*?\s-u\s*['\"]?[^\s:'\"]+:{NOT_VAR}([^\s'\"]+)"),
    ("bearer token", rf"[Bb]earer\s+{NOT_VAR}([A-Za-z0-9._~+/=-]{{12,}})"),
    ("fastlane or match secret",
     rf"\b(?:MATCH_PASSWORD|FASTLANE_PASSWORD|FASTLANE_SESSION|"
     rf"FASTLANE_APPLE_APPLICATION_SPECIFIC_PASSWORD|MATCH_GIT_BASIC_AUTHORIZATION)"
     rf"=['\"]?{NOT_VAR}([^\s'\"]+)"),
    ("app-specific password", r"\b([a-z]{4}-[a-z]{4}-[a-z]{4}-[a-z]{4})\b"),
    ("keychain password", rf"security\s+unlock-keychain\s+-p\s*['\"]?{NOT_VAR}([^\s'\"]+)"),
    (".p12 password", rf"security\s+import\b[^|;&]*?\s-P\s*['\"]?{NOT_VAR}([^\s'\"]+)"),
    ("known key format",
     r"\b((?:sk_live_|rk_live_|sk_|sk-ant-|sk-proj-|ghp_|gho_|github_pat_|npm_|glpat-|"
     r"sbp_|AKIA|xox[bap]-)[A-Za-z0-9_-]{12,})"),
    ("JWT, check its role", r"\b(eyJ[A-Za-z0-9_-]{12,}\.[A-Za-z0-9_-]{12,}\.[A-Za-z0-9_-]{8,})"),
    ("secret-named variable",
     rf"\b[A-Z0-9_]*(?:TOKEN|SECRET|PASSWORD|PASSWD|API_KEY|PRIVATE_KEY)=['\"]?{NOT_VAR}([^\s'\"]{{8,}})"),
]
COMPILED = [(name, re.compile(rx)) for name, rx in PATTERNS]
SKIP_DIRS = {"node_modules", "Pods", "DerivedData", ".build", ".git", "Carthage", "build"}
TARGET_FILES = {"settings.local.json", "settings.json"}


def mask(value):
    return f"{value[:2]}...({len(value)} chars)"


def findings(text):
    found, seen = [], set()
    for name, rx in COMPILED:
        for match in rx.finditer(text):
            value = match.group(1)
            if value not in seen:
                seen.add(value)
                found.append((name, mask(value)))
    return found


def strings_in(node):
    if isinstance(node, str):
        yield node
    elif isinstance(node, list):
        for item in node:
            yield from strings_in(item)
    elif isinstance(node, dict):
        for item in node.values():
            yield from strings_in(item)


def scan_file(path):
    with open(path, encoding="utf-8", errors="replace") as handle:
        raw = handle.read()
    try:
        lines = list(strings_in(json.loads(raw)))
    except json.JSONDecodeError:
        lines = raw.splitlines()
    return [hit for line in lines for hit in findings(line)]


def run_hook():
    event = json.load(sys.stdin)
    command = event.get("tool_input", {}).get("command", "")
    hits = findings(command)
    if not hits:
        return 0
    kinds = ", ".join(sorted({name for name, _ in hits}))
    print(f"Blocked: this command has a literal secret ({kinds}). "
          "Read it from an environment variable or the keychain instead.", file=sys.stderr)
    return 2


def main():
    args = sys.argv[1:]
    if args == ["--hook"]:
        return run_hook()
    if args == ["-"]:
        hits = [hit for line in sys.stdin for hit in findings(line.replace('\\"', '"'))]
        for name, masked in hits:
            print(f"history: {name}: {masked}")
        return 1 if hits else 0
    root = os.path.expanduser(args[0] if args else ".")
    total = 0
    for folder, dirs, files in os.walk(root):
        dirs[:] = [d for d in dirs if d not in SKIP_DIRS]
        if os.path.basename(folder) != ".claude":
            continue
        for name in TARGET_FILES & set(files):
            path = os.path.join(folder, name)
            for kind, masked in scan_file(path):
                total += 1
                print(f"{path}: {kind}: {masked}")
    print(f"{total} possible secret(s) found.")
    return 1 if total else 0


if __name__ == "__main__":
    sys.exit(main())

Point it at the folder that holds your projects:

python3 tools/claude_allow_audit.py ~/Developer

On the test repo, with 13 planted values across two settings files, it reported all 13. Rules that used $DB_PASS or "$MATCH_PASSWORD" stayed silent, and a copy of the file under Pods was skipped.

Expect some noise and some misses. A lowercase slug shaped like abcd-efgh-ijkl-mnop will be reported as an app-specific password. A JWT might be a public Supabase anon key, which Apiiro excluded as public by design, so check its role before you panic. A password passed with no telltale flag or variable name will get through, so open the allow list and read it yourself as well, especially if the file is large.

Step 2: Check git history, GitHub and your transcripts

A clean working copy tells you nothing about the past. From the root of each repository, list every commit that touched these files, then scan the changed lines:

git log --all --format='%h %ad %s' --date=short -- ':(glob)**/.claude/settings*.json'

git log --all -p --format= -- ':(glob)**/.claude/settings*.json' \
  | grep '^[-+]' | python3 tools/claude_allow_audit.py -

git ls-files | grep -E '(^|/)\.claude/settings\.local\.json$'

The last command prints the path if the file is tracked right now. On GitHub, use code search with org:YOUR_ORG path:.claude/settings.local.json, then repeat it with settings.json. Apiiro recommends searching for both, since the shared file held secrets in 298 of 76,011 copies.

Your transcripts need the same check. Anthropic's documentation says files under ~/.claude are plaintext, are not encrypted at rest, and that a credential printed by a command is written to projects/<project>/<session>.jsonl. They are removed after 30 days by default, controlled by cleanupPeriodDays.

find ~/.claude/projects -name '*.jsonl' -exec cat {} + \
  | python3 tools/claude_allow_audit.py - | sort | uniq -c

Run claude purge ~/path/to/repo --dry-run to preview what Claude Code would delete for one project, including its transcripts and auto memory. Rotate first, though, because deleting the transcript does nothing for a value that has already been copied somewhere else.

Step 3: Rotate before you clean

Both Apiiro and GitHub put rotation first. Once a value can't be used, the copies in history, forks and old clones stop being dangerous, and GitHub notes that this may remove the need to rewrite history at all. Apiiro suggests starting with credentials paired with a public host, since those give direct access.

CredentialHow to replace itWhat to expect
App Store Connect API keyRevoke it in App Store Connect under Users and Access, Integrations, then generate a new key with the narrowest role that worksApple lets you download the private key once and keeps no copy. Update CI before you revoke if you can tolerate the exposure window
App-specific passwordaccount.apple.com, Sign-In and Security, App-Specific Passwords, then Remove or Revoke AllAnything using it signs out. Changing your Apple Account password revokes all of them
Match passphrasefastlane match change_passwordFiles are re-encrypted and each machine asks for the new password. An old clone of the repo still opens with the old passphrase, so if someone could read that repo too, treat the certificates as exposed
Distribution certificate and .p12Revoke and issue a new one, or use fastlane match nukeApple says existing App Store apps aren't affected if your membership is valid, but you can't upload with the revoked certificate, and uploaded builds not yet submitted may become Invalid Binary. In-house apps stop running
FASTLANE_SESSIONCreate a new one with fastlane spaceauthfastlane's docs describe no way to end a session early, so assume an exposed one lasts up to a month
Database, Supabase, GitHub, npm, AWSYour provider's consoleChange the value everywhere it is used, then confirm the old one fails

If you revoke a distribution certificate, do it between releases when you can, because of the Invalid Binary risk for builds waiting in App Store Connect.

Step 4: Take the file out of git

git rm --cached .claude/settings.local.json
echo '.claude/settings.local.json' >> .gitignore
git add .gitignore
git commit -m "Stop tracking Claude Code local settings"

The order matters. Adding a path to .gitignore does nothing while the file is tracked. In the test repo, git check-ignore returned no match for the tracked file and started matching only after git rm --cached. Anthropic's docs add a second effect: a tracked copy is treated as repository-supplied, so its rules wait until you trust the folder. Apiiro found that Claude Code records this in its debug log without telling the user, and keeps appending new approvals to the tracked file.

Then open the local file and delete every rule that contains a secret, including rules that were never committed. If rotation isn't possible for some value, GitHub's documented way to rewrite history is:

git-filter-repo --sensitive-data-removal --invert-paths \
  --path .claude/settings.local.json
git push --force --mirror origin

It needs git-filter-repo 2.47 or later. The first command removed the file from a test clone's history, leaving zero commits touching that path; the push was not tested. GitHub warns that commit hashes change, signatures are removed, a collaborator's old clone can bring the data back, and any fork containing the commit still exposes it. Cached views need a request to GitHub Support.

Step 5: Keep new secrets out of the prompt

Start with the habit Apiiro recommends: reference the secret as a variable. Load it into your shell before starting Claude Code, and the approved rule stores the name.

# Saved in the rule as a name, which is harmless
Bash(MATCH_PASSWORD="$MATCH_PASSWORD" fastlane match appstore)

# Saved with the value, which is the problem
Bash(MATCH_PASSWORD=the-real-passphrase fastlane match appstore)

For notarization, Apple's notarytool takes a --keychain-profile name that you create once with store-credentials, so the password stays out of the command line entirely.

Prefer prefix rules such as Bash(fastlane match *) when the prompt offers one, and read the line before you pick "don't ask again". A prefix allows any arguments, so keep it to commands you would run unattended.

Next, stop the agent from reading credential files in the first place. This goes in the project's .claude/settings.json, which your team shares:

{
  "permissions": {
    "deny": [
      "Read(./.env)",
      "Read(./.env.*)",
      "Read(./**/*.p8)",
      "Read(./**/*.p12)"
    ]
  }
}

Know the limit of these rules. The docs say they cover Claude's file tools and shell commands that name the file, and that they don't reach a Python or Node script opening the file itself. For enforcement across every process, the docs point to the sandbox.

The script above doubles as a PreToolUse hook. Anthropic's hooks page says exit code 2 blocks the tool call and passes stderr back to Claude, so the agent gets told to use a variable before any prompt can save the value. Add this to .claude/settings.json:

{
  "hooks": {
    "PreToolUse": [
      {
        "matcher": "Bash",
        "hooks": [
          {
            "type": "command",
            "command": "python3 \"$CLAUDE_PROJECT_DIR/tools/claude_allow_audit.py\" --hook"
          }
        ]
      }
    ]
  }
}

With sample JSON on stdin, a command containing PGPASSWORD= and a literal value exited with 2 and the same command using a variable exited with 0. It was not run inside a live Claude Code session, so try one harmless fake password after you install it. It will also block a throwaway test command that happens to look like a secret, and it shares the scanner's blind spots.

Step 6: Add a check at commit time

A pre-commit hook covers the clones and new machines that the global exclude never reaches. Save this as .git/hooks/pre-commit and make it executable. To share it with a team, keep it in the repo and point core.hooksPath at that folder.

#!/bin/sh
if git diff --cached --name-only | grep -Eq '(^|/)\.claude/settings\.local\.json$'; then
  echo "Refusing to commit .claude/settings.local.json" >&2
  exit 1
fi
for f in $(git diff --cached --name-only | grep -E '(^|/)\.claude/settings\.json$'); do
  git show ":$f" | python3 tools/claude_allow_audit.py - || exit 1
done

In the test repo it stopped a commit of the local file and a commit of a shared settings.json holding a planted FASTLANE_PASSWORD. Add .claude/settings.local.json, *.p8 and *.p12 to your project's .gitignore at the same time, and to any template you start new repos from.

GitHub push protection is worth turning on as well, with one caveat. It blocks recognized provider credentials, while generic patterns must be enabled separately, and by default anyone with write access can bypass it by giving a reason. Apiiro's scanner numbers suggest treating it as one layer. Passwords typed into commands are the part format-based tools handle worst.

What to watch next

Anthropic has said only that it will prototype options before shipping something, so check the Claude Code changelog for secret scanning or a change to what "don't ask again" stores. When a change lands, your existing allow rules will still be sitting in the file, which is why the scan and the rotation are worth doing this week. Apiiro also found the same pattern in other places agents write: 120 transcript exports, 33 handoff and deploy notes and 9 repositories' memory files. If your agent keeps notes in the repo, feed those through the script's - mode too.

If you want a Claude Code setup for an iOS repo that starts from stricter defaults, Claude Code + Xcode: The Production iOS Workflow Kit is a paid kit from the JR Devhub store. Its page lists 8 rules (privacy and security and release safety among them), 6 commands, 10 iOS agents, and 2 optional local hook scripts with an example settings file, and says the hooks are opt-in and don't auto-approve commands. The page doesn't list a secret scanner, so keep the script above for that job.

Sources