Detecting Tampering in AI Coding Agent Config on macOS and Linux: Baselining and Watching AGENTS.md, CLAUDE.md, GEMINI.md and Settings

2026-11-09 · By H.A

Detecting Tampering in AI Coding Agent Config on macOS and Linux: Baselining and Watching AGENTS.md, CLAUDE.md, GEMINI.md and Settings

Build a hash baseline, risky-key review, real-time change alerts and optional immutable locks for the global instruction and settings files that steer Codex, Claude Code and Gemini CLI.

AI coding agents read a handful of plain-text files every time they start: global instructions, settings and MCP server lists. Whoever can write to those files can steer every session that follows. This week a "jailbreak pack" for OpenAI Codex was found rewriting the agent's global instructions to advertise a paid LLM gateway. Earlier, infostealers added AI-assistant config folders to their target lists. Tampering with these files is quiet. The agent keeps working, it just follows someone else's rules. This tutorial builds a small, practical integrity check for Codex, Claude Code and Gemini CLI config on macOS and Linux: an inventory, a hash baseline, a review of risky keys, real-time change alerts and optional locking.

Prerequisites

Step 1: Inventory the files that steer your agents

Each agent loads global files from your home directory and project files from the repository. The global ones matter most, because they apply to every project:

List what actually exists on your machine:

for f in "${CODEX_HOME:-$HOME/.codex}"/{AGENTS.md,AGENTS.override.md,config.toml} \
         "${CLAUDE_CONFIG_DIR:-$HOME/.claude}"/{CLAUDE.md,settings.json} "$HOME/.claude.json" \
         "$HOME/.gemini"/{GEMINI.md,settings.json}; do
  [ -e "$f" ] && ls -l "$f"
done

An AGENTS.override.md that you didn't create is a red flag. It silently replaces your normal global instructions.

Step 2: Review the content before you trust it

A baseline only helps if the starting state is clean. Read the instruction files in full. They are short. Then search all of them for the patterns tampering usually adds: new endpoints, proxy settings, shell commands and promotional text.

CFG="$HOME/.codex $HOME/.claude $HOME/.claude.json $HOME/.gemini"
grep -RnoE 'https?://[^" )]+' $CFG 2>/dev/null | grep -v '/projects/' | sort -u
grep -RnE 'base_url|BASE_URL|model_provider|apiKeyHelper|HTTPS?_PROXY|"hooks"|curl |wget |bash -c' \
  $HOME/.codex/config.toml $HOME/.claude/settings.json $HOME/.gemini/settings.json 2>/dev/null

Questions to ask about each hit:

If anything is unexplained, remove it, rotate any API keys stored on the machine, and check how it got there before you go on.

Step 3: Record a hash baseline

Store hashes and a copy of each file somewhere the agents don't write to:

mkdir -p ~/.agent-integrity/copies && chmod 700 ~/.agent-integrity
cat > ~/.agent-integrity/files.txt <<'EOF'
.codex/AGENTS.md
.codex/AGENTS.override.md
.codex/config.toml
.claude/CLAUDE.md
.claude/settings.json
.gemini/GEMINI.md
.gemini/settings.json
EOF

cd ~ && while read -r f; do
  [ -f "$f" ] && { mkdir -p ~/.agent-integrity/copies/"$(dirname "$f")"; cp -p "$f" ~/.agent-integrity/copies/"$f"; }
done < ~/.agent-integrity/files.txt

# sha256sum on Linux; shasum -a 256 on macOS
HASH=$(command -v sha256sum || echo "shasum -a 256")
cd ~ && xargs -I{} sh -c '[ -f "{}" ] && '"$HASH"' "{}"' < ~/.agent-integrity/files.txt \
  > ~/.agent-integrity/baseline.sha256

~/.claude.json is left out of the hash list on purpose. Claude Code rewrites it often with session state. Check its mcpServers section separately (Step 4).

Step 4: Write a check script

Save this as ~/.agent-integrity/check.sh and make it executable with chmod +x:

#!/usr/bin/env bash
set -u
cd "$HOME"
HASH=$(command -v sha256sum || echo "shasum -a 256")
status=0
# 1. Changed or deleted baseline files
$HASH -c --quiet "$HOME/.agent-integrity/baseline.sha256" 2>/dev/null || status=1
# 2. Files that appeared since the baseline (e.g. a new override file)
while read -r f; do
  if [ -f "$f" ] && ! grep -q " $f\$" "$HOME/.agent-integrity/baseline.sha256"; then
    echo "NEW FILE: $f"; status=1
  fi
done < "$HOME/.agent-integrity/files.txt"
# 3. MCP servers registered with Claude Code
if command -v jq >/dev/null && [ -f "$HOME/.claude.json" ]; then
  jq -r '.mcpServers // {} | keys[]' "$HOME/.claude.json" | sort > /tmp/mcp-now.$$
  [ -f "$HOME/.agent-integrity/mcp.txt" ] || cp /tmp/mcp-now.$$ "$HOME/.agent-integrity/mcp.txt"
  diff -u "$HOME/.agent-integrity/mcp.txt" /tmp/mcp-now.$$ || status=1
  rm -f /tmp/mcp-now.$$
fi
[ $status -eq 0 ] && echo "agent config OK" || echo "agent config CHANGED - review with diff against ~/.agent-integrity/copies"
exit $status

When it reports a change, see exactly what changed:

diff -u ~/.agent-integrity/copies/.codex/AGENTS.md ~/.codex/AGENTS.md

If the change was yours, refresh the baseline by re-running the Step 3 commands.

Step 5: Run it automatically

Linux (cron): run the check hourly and send failures to the system log:

( crontab -l 2>/dev/null; echo '0 * * * * $HOME/.agent-integrity/check.sh >/dev/null || logger -t agent-integrity "AI agent config changed"' ) | crontab -

Real-time on Linux with auditd (as root). Every write is recorded with the process that made it:

sudo auditctl -w /home/alice/.codex/ -p wa -k ai-agent-config
sudo auditctl -w /home/alice/.claude/ -p wa -k ai-agent-config
sudo auditctl -w /home/alice/.gemini/ -p wa -k ai-agent-config
sudo ausearch -k ai-agent-config -i | grep -E 'name=|exe='

To keep the rules across reboots, put the same -w lines in /etc/audit/rules.d/ai-agent.rules and run sudo augenrules --load.

Real-time on macOS with fswatch:

fswatch -0 ~/.codex ~/.claude/CLAUDE.md ~/.claude/settings.json ~/.gemini | \
  while IFS= read -r -d '' path; do
    osascript -e "display notification \"$path changed\" with title \"Agent config\""
  done

Run it from a LaunchAgent if you want it to start at login. The exe= field from auditd is especially useful: an edit by your editor is expected, an edit by a downloaded binary is not.

Step 6 (optional): Lock the global instruction files

Instruction files rarely change, so you can make them immutable. The agent can still read them, but nothing can modify them until you unlock them:

# macOS (user immutable flag)
chflags uchg ~/.codex/AGENTS.md ~/.claude/CLAUDE.md
chflags nouchg ~/.codex/AGENTS.md          # to edit again

# Linux (root required)
sudo chattr +i /home/alice/.codex/AGENTS.md
sudo chattr -i /home/alice/.codex/AGENTS.md

Don't lock settings.json or config.toml if you change settings from inside the tools, because the agents need to write to them.

Verification

Troubleshooting

Wrapping Up

Your agent is only as trustworthy as the files it reads at startup. A reviewed starting point, a hash baseline, alerts on change and locked instruction files turn a silent compromise into a notification you can act on, with very little effort. Keep this in place alongside the usual measures: keys out of plaintext, a short MCP server list, and approval prompts left on.

COMPUTE NODE · · --:--:--

Fresh cybersecurity news,
daily threat intelligence.

Daily cyber news, live threat intel and exploited CVEs.

Everything in one place

Self-hosted, hardened, and yours.

RUN IT

Local AI console

Chat with a model on your own hardware via Ollama or any OpenAI-compatible server. No cloud, no key.

DEFEND

Cyber threat feed

Automatic daily intel from CISA KEV, NVD & GitHub advisories, a live cyber threat map, and your own notes.

NEWS

News & videos

Articles and updates on pentesting, AI, and cyber — with embedded video, including YouTube. Post your own.

DIRECTORY

Registry

Runtimes, models, MCP servers, agents, and a full security & pentest tooling section.

PUBLISH

Posts

Write, edit, publish, and share articles backed by a real database and your account.

COMMUNITY

Forum

Threads and replies across categories from Models to Hardware to Security.

CODE

Repos

Curated AI and security GitHub repos, plus a shelf for pinning your own.

DOWNLOAD

Skill packs

Agent starters, RAG scaffolds, and defensive security & VAPT report templates.

Registry

Runtimes, models, MCP servers, agent frameworks, and a security & pentest tooling section — all links out to the real projects.

Local AI console

Talk to a model running on your own machine through Ollama or an OpenAI-compatible server — your prompts and the model's replies always go straight from your browser to your local model, never through a Reef server. Attach files for context, and pick up saved chats where you left off.

Type /image a prompt in the box below to generate
Not connected

Local AI hardware benchmark

A spec-based compatibility advisor — tells you which local models your hardware can run well, which will be slow, and which to skip. Connect to Ollama below for a real, measured speed test instead of an estimate.

1. Your hardware

2. Live check against your local model server (optional)

If a local model server is running, this cross-references the table above with what you've actually got loaded — and runs a real, measured speed test instead of an estimate.

AI Database

A browsable catalog of AI models across providers — context windows, pricing, and capabilities.

Loading…

Cyber threat feed

Latest threats pulled automatically every day from CISA's Known-Exploited-Vulnerabilities catalog and NVD — plus threat intel you post yourself.

⇩ Export STIX
Loading threat feed…

Cyber threat map

Attacks happening right now, all over the world.

Connecting…
LIVE · MAURITIUS TIME--:--:--
attack route, country to country attack route into Mauritius attacker reported worldwide
Loading live data…
attackers reported per minute · click to rewindnow

Top attack routesweb

Attackers based inlast hour

Networkslast hour

Click any dot, feed row or table row to see that IP's profile.

Mauritius

Who attacks Mauritius

Loading…

Web attacks malicious requests to Mauritian websites that were blocked
Network DDoS floods meant to knock Mauritian servers offline

    Mauritius · last 24 h

    How Mauritius is attacked

    Network-level attacks (DDoS) aimed at Mauritius, by method. They try to knock servers and networks offline by sheer volume.

    • Loading…

    The ports or services these floods aimed at aren't published.

    Mauritius · last hour

    Attackers located in Mauritius

    0attackers located in Mauritius were reported in the last hour

    This counts attacks coming from Mauritius, not attacks on it: IPs in Mauritius that servers elsewhere reported for attacking them. Usually zero or one; when it rises, it's often a hacked local server or router.

    Worldwide today

    What attackers are knocking on

    Ports most targeted across a worldwide network of sensors .

    Worldwide today

    Most active attackers

    Ranked by how many separate sensors they hit. Click a row for its profile.

    IPCountryNetworkSensors hitReports
    What you're looking at
    Blue routes

    Share of attack traffic from one country to another. Thicker, faster streams carry more. Particles show volume, not one per attack.

    Every 15 min · published 1–2 h behind
    Amber flashes

    An attacking IP that servers around the world reported in the last minute, placed where the IP is. Its targets aren't published, so there's no line.

    Every minute · shown about 1 min behind
    Locations

    IP locations are approximate (city level at best) and show where the machine is hosted, not who controls it.

    Approximate · city level at best

    News

    Articles, guides and updates on pentesting, AI, and cybersecurity — with embedded video. Add your own, including YouTube.

    Loading…

    Posts

    Loading…

    Loading posts…

    Forum

    Questions, answers, and talk about running AI locally.

    Loading forum…

    GitHub repositories

    Curated AI and security repos, plus your own pinned shelf.

    Command board

    One-liners, configs, and advice worth keeping — shared by everyone here.

    ⚠ Commands are shared with all users. Never include credentials, tokens, or internal hostnames. Review anything before you run it.
    Loading commands…

    Skill packs

    Starter files served from the API — AI agent scaffolds plus defensive security & VAPT reporting templates. Click to download.

    Loading skills…

    Threat Library

    Threat actors, malware and tools — their attack techniques, Reef Sentinel coverage and indicators of compromise.

    Loading…

    Threat Intelligence

    Curated threat write-ups, advisories and analysis — with cover media.

    Loading…

    Tutorials

    Step-by-step guides for running local AI, using the console, and tracking threats. Admins can add their own.

    Loading…

    Downloads

    Direct links to the official homepage/download page for well-known cybersecurity, penetration-testing, and local-AI software. Always verify checksums/signatures from the vendor before running anything.

    Loading…

    Terms & Conditions

    Loading…

    Help & FAQ

    Answers to common questions about Reef Sentinel, plus a formatting guide for posts, articles, and comments.


    Formatting guide

    Commands you can type into the body of a post, comment, or reply — no HTML needed. Comments and short replies only support bold, italic, and inline code.

    Contact us

    Questions, feedback, or a security disclosure? Reach us directly, or send a message and we'll get back to you by email.

    Loading…

    Send a message

    VAPT Report Generator

    Build an engagement, add findings with a live CVSS calculator, and generate a branded, print-ready report.

    Recon Toolkit

    Passive OSINT lookups for the recon phase of an engagement, plus offline hash identification and a payload cheatsheet.

    Website Checker

    Reads a website's HTTP response headers to identify its framework and server, shows any known CVEs for the exposed versions with details, and recommends what to do.

    Control panel

    Manage everything shown on the site — news & videos, posts, homepage headlines, and subscribers. Admin only.

    Overview
    Content
    Site
    Account & Security

    Email settings

    SMTP on ports 25/465/587 is blocked outbound by some hosts (e.g. DigitalOcean droplets by default) — Resend and Brevo send over their HTTPS API instead, so they work even then. Only the selected provider is used to send; the others stay saved but idle, so you can switch back any time without losing settings.

    Get a key from resend.com/api-keys. Uses the "From address" below as the sender — it must be on a domain you've verified with Resend.

    Get an API key (not an SMTP key) from app.brevo.com/settings/keys/api. Uses the "From address" below as the sender — it must be a verified sender in your Brevo account.

    "From address" and "Site name/URL" are shared by SMTP, Resend, and Brevo — they control what recipients see, regardless of which provider is active.

    Send a test email

    Sends through whichever provider is currently active above. Save your settings first if you just changed them.