According to The Hacker News on November 7, Apiiro researchers reported that a persistent approval can copy a credential-bearing command into .claude/settings.local.json. Committing that file can expose the secret. This is conditional: not every approval saves a complete command, and Claude Code does not publish the file by default.
Rotate credentials before cleaning files
If your credential reached a public repository, revoke or rotate it at its issuer first. Review access logs and permissions. Deleting files, ignoring them or rewriting history does not invalidate a leaked credential. Copies may remain in clones, forks and build artifacts. Coordinate history cleanup with repository owners; this guide does not perform it.
Read-only checks in your own repository
Run the script below only against a local repository you own or are authorized to inspect. It reads two fixed settings paths and their history reachable from current refs, without network requests or printing matched values or source lines. Heuristics can miss secrets or flag harmless text: no match does not prove safety. The default limit is 1000 distinct historical blobs, each at most 2 MiB. Follow up on skipped or truncated results. Chat logs, other paths and unreachable objects are outside its scope.
#!/usr/bin/env python3
"""Read-only heuristic check of exactly two files in one explicitly selected own repo.
Never prints matched values, source lines, remote URLs, or file contents.
Not a complete secret scanner. Do not use on other people's repositories.
"""
import argparse, json, os, re, subprocess
from pathlib import Path
ap=argparse.ArgumentParser(); ap.add_argument('repo'); ap.add_argument('--max-versions',type=int,default=1000)
a=ap.parse_args(); root=Path(a.repo).resolve()
env=os.environ.copy(); env.update(GIT_CONFIG_NOSYSTEM='1',GIT_CONFIG_GLOBAL=os.devnull,GIT_PAGER='cat',GIT_TERMINAL_PROMPT='0')
def git(*args):
p=subprocess.run(['git','--no-pager','-c','core.fsmonitor=false','-c','core.hooksPath=/dev/null','-C',str(root),*args],env=env,stdout=subprocess.PIPE,stderr=subprocess.DEVNULL)
return p.stdout if p.returncode==0 else None
top=git('rev-parse','--show-toplevel')
if top is None or Path(os.fsdecode(top).strip()).resolve()!=root:
raise SystemExit('Select the exact root of your own local repository; no contents printed.')
paths=['.claude/settings.local.json','.claude/settings.json']
rx=re.compile(r"""(?ix)(?:postgres(?:ql)?|mysql|mongodb(?:\+srv)?):\/\/[^\s"'/:]+:[^\s"'@]+@|(?:PGPASSWORD|MYSQL_PWD|password|passwd|api[_-]?key|token)\s*[=:]\s*(?!\$|\\?"?\$)[^\s,;}{]{4,}|\b(?:ghp_|github_pat_|sk-ant-|AKIA)[A-Za-z0-9_-]{8,}""")
limit=2*1024*1024
work=[]
for name in paths:
p=root/name
if p.is_symlink() or p.parent.is_symlink():
work.append({'file':name,'status':'symlink_skipped'}); continue
if not p.is_file(): work.append({'file':name,'status':'absent'}); continue
if p.stat().st_size>limit: work.append({'file':name,'status':'size_limit_skipped'}); continue
work.append({'file':name,'suspected_secret':bool(rx.search(p.read_text(errors='replace')))})
commits=git('log','--all','--format=%H','--',*paths) or b''
seen=set(); checked=0; hits=0; skipped=0; truncated=False
for rev in commits.decode().splitlines():
for name in paths:
oid=git('rev-parse',rev+':'+name)
if oid is None: continue
oid=oid.strip().decode()
if oid in seen: continue
seen.add(oid)
if checked>=a.max_versions: truncated=True; break
size=git('cat-file','-s',oid)
if size is None or int(size)>limit: skipped+=1; continue
blob=git('cat-file','blob',oid)
if blob is None: skipped+=1; continue
checked+=1; hits+=int(bool(rx.search(blob.decode(errors='replace'))))
if truncated: break
print(json.dumps({'working_tree':work,'history':{'distinct_blobs_checked':checked,'suspected_blobs':hits,'skipped_blobs':skipped,'truncated':truncated},'warning':'heuristic_only; no hit does not prove clean; reachable refs only'},ensure_ascii=False))
python3 selfcheck.py /absolute/path/to/your-own-repository
Removing today’s file does not remove history
After rotation, review and remove secret-bearing allow rules. Add the pattern below to the repository’s own .gitignore. For an already tracked file, the untracking command below affects future commits while preserving your working copy; it does not erase old commits. It is an example, not an operation performed here. Do not blindly ignore all of .claude/: shared configuration also needs secret review.
**/.claude/settings.local.json
git rm --cached .claude/settings.local.json
Variables and approval patterns have different limits
The official permissions documentation defines Bash(npm run lint) as an exact command and Bash(npm run *) as a wildcard pattern; a trailing :* is also supported. An exact rule is generally narrower, but the script it runs can still do sensitive work. Read the actual approval scope rather than granting Bash(*) to suppress prompts. The JSON example belongs in global ~/.claude/settings.json; merge it with existing settings instead of replacing them.
{
"permissions": {
"allow": [
"Bash(npm run lint)"
]
}
}
psql "$DB_URL" illustrates shell variable expansion, not a security guarantee. Inject variables into a local session through controlled secret management rather than embedding passwords in commands. Expanded values can still reach process arguments, tracing logs or tool output, and a model could generate a different command containing the value. Do not enable shell tracing, print the variable or place its value in an allow rule. No database connection was attempted here.
Claude Code, Codex and Cursor
The Claude Code settings documentation distinguishes global ~/.claude/settings.json, project-local .claude/settings.local.json and shared .claude/settings.json. On its first qualifying write, the client adds the local file to global Git excludes. That protection does not travel with a repository or untrack an existing file. Put the site’s Codex provider configuration in global ~/.codex/config.toml. The example shows provider metadata only and deliberately omits authentication values; it is not a complete runnable authentication configuration. Handle the actual experimental_bearer_token value only in your own private local configuration, never in this article or a commit.
The official Codex configuration reference and configuration basics define model_provider as the provider selector, name as its display name, base_url as its API base and wire_api = "responses" as its protocol. The reference still lists experimental_bearer_token, but explicitly discourages storing a token directly in configuration. This example follows the site’s field convention, not an official recommendation for secret storage. Once filled in, the global file itself contains a secret: keep it out of repositories, screenshots, sync bundles and shared files. We checked the documented fields and location, not an authenticated request.
model_provider = "aicodewith"
[model_providers.aicodewith]
name = "aicodewith"
base_url = "https://api.aicodewith.ai/chatgpt/v1"
wire_api = "responses"
According to Cursor’s security documentation, terminal commands require approval by default. Run Modes and allowlists are best-effort guardrails, not hard security boundaries. This does not establish an identical persistence format or immunity to secret leaks. Review configuration, logs, history and diffs with every client.
What this local demonstration actually tested
Installed versions were Claude Code 2.1.319 and Codex 0.167.0. In an isolated directory, a manually written fixture with an obvious fake password was committed only to a temporary local Git repository. The scanner reported a current-file hit; after replacing the rule, the current-file hit disappeared while the historical hit remained. Adding .gitignore did not untrack the file. The script demonstration took 0.115 seconds, excluding research. We did not click a persistent approval in the client UI, so this is not a reproduction of client persistence. No model, real key, remote push or publicly exposed credential was used.
Related guides
AGENTS.md download-directory hijack checks



