Open-source guardrail
Opening a file that holds credentials
AgentTrail Guard asks you about this by default: you decide before the call runs. Where an agent cannot ask, the call is refused instead.
- Default action
- Ask
- Severity
- High severity
- Pack
- Secret exposure
- Library version
- 0.2.8 · Nov 11, 2026
Mapped to the OWASP Top 10s
ASI02Tool Misuse and ExploitationASI03Identity and Privilege AbuseLLM02Sensitive Information Disclosure
An id names a risk this guardrail addresses where it becomes a command or a file read or write, never the whole risk.
What it does
What it catches, and what it misses
Written into the rule itself, next to what it matches, so you can judge it before you trust it.
Holds a file tool opening a path where credentials live — an SSH private key, an AWS credentials file, a PEM/P12/PFX/JKS keystore, .npmrc or .pypirc (which hold registry tokens), a Docker config, or a kubeconfig. Public keys are excluded (*.pub). It matches the PATH ONLY: it cannot tell whether the file actually holds a secret, so a .pem that is a public certificate is held too, and a credential in a file named something else is missed entirely. .env files are covered separately by block-env-file-read. It also holds READING — the Read and Grep tools, nothing else — of files whose edit another guardrail already holds and which commonly carry a secret: /etc/shadow, /etc/gshadow, their - backups, /etc/sudoers and /etc/sudoers.d/; SSH host private keys (/etc/ssh/ssh_host_*_key and the legacy /etc/ssh/ssh_host_key); /etc/ssl/private/ and /etc/pki/tls/private/; Kubernetes admin configs (/etc/kubernetes/*.conf) and private keys (/etc/kubernetes/pki/**/*.key); the k3s kubeconfig (/etc/rancher/k3s/k3s.yaml); a repository's .git/config, where a remote URL or extra header can carry a token; agent configuration that often holds API keys — .mcp.json, .claude/settings.local.json, .claude.json, .cursor/mcp.json and .codex/config.toml; and production configuration: a .yml, .yaml, .json, .toml, .env, .ini, .conf, .properties, .tf or .tfvars file named *.prod.*, prod.*, *.production.* or production.*, or under a prod/ or production/ folder, unless any folder in the path, an absolute path's leading folders included, is named exactly node_modules, dist or vendor (so /srv/vendor/app/config/database.prod.yml is not held). A Grep anywhere under /etc, including a search of the folder itself or with a wildcard, is held too; a Read of an /etc file not named here is not. Editing those files is held by the guardrail that owns the path, not by this one. NOT held on read by this guardrail: a shell command such as cat, on any agent (Codex has no read tool, so its reads are always shell commands); a file tool other than Read and Grep, such as Claude Code's Glob or another Cursor tool, which the guardrail that owns the path still holds under its own title, except on .claude.json, which no other guardrail names; .claude/settings.json, at project or user level; other secrets under /etc such as Kerberos keytabs and VPN or Wi-Fi connection files, which are held on Grep only; a Grep of a production folder with no file pattern, or with a pattern whose extension is a wildcard; production files of other types, such as .key, .tfstate, .hcl, .cfg, .xml, .config or Angular's environment.prod.ts; and production code or prose, such as webpack.prod.js or a runbook in docs/production/.
Examples
Tested on every build
The rule must match every command on the left and none on the right, or the library does not build. Catching the real thing is easy; staying quiet on the near-miss is the hard part.
Catches (72)
- Read/home/dev/.ssh/id_rsa
- Read/Users/dev/.aws/credentials
- Readcerts/server.pem
- Write.npmrc
- Edit/home/prod/.ssh/id_rsa.txt
- Read/home/prod/.ssh/id_rsa.txt
- Write/srv/production/.ssh/id_ed25519.md
- Readvendor/certs/server.pem
- Read/home/dev/keys/id_rsa
- Writebackup/id_ed25519
- Readcerts/client.p12
- Editandroid/app/release.jks
- Read/home/dev/.pypirc
- Read/home/dev/.docker/config.json
- Grep/home/dev/.kube/config
- Read/etc/shadow
- Grep/etc/gshadow
- Read/etc/sudoers
- Read/etc/shadow-
- Read/etc/gshadow-
- Read/etc/sudoers.d/90-cloud-init-users
- Grep/etc/sudoers.d/admins
- Read/etc/ssh/ssh_host_ed25519_key
- Grep/etc/ssh/ssh_host_rsa_key
- Read/etc/ssh/ssh_host_key
- Grep/etc/ssh/ssh_host_key
- Read/etc/ssl/private/server.key
- Grep/etc/ssl/private/ca.key
- Read/etc/pki/tls/private/server.key
- Grep/etc/pki/tls/private/localhost.key
- Read/etc/kubernetes/admin.conf
- Grep/etc/kubernetes/controller-manager.conf
- Read/etc/kubernetes/pki/ca.key
- Grep/etc/kubernetes/pki/etcd/ca.key
- Read/etc/rancher/k3s/k3s.yaml
- Grep/etc/rancher/k3s/k3s.yaml
- Grep/etc
- Grep/etc/ssh
- Grep/etc/kubernetes
- Grep/etc/ssh/*_key
- Grep/etc/shadow*
- Grep/etc/hosts
- Read/repo/.git/config
- Grep/repo/.git/config
- Read.mcp.json
- Grep.mcp.json
- Read/repo/.claude/settings.local.json
- Grep/repo/.claude/settings.local.json
- Read/Users/dev/.claude.json
- Grep/Users/dev/.claude.json
- Read/repo/.cursor/mcp.json
- Grep/Users/dev/.cursor/mcp.json
- Read/Users/dev/.codex/config.toml
- Grep/Users/dev/.codex/config.toml
- Readconfig/database.prod.yml
- Grepdocker-compose.prod.yml
- Readconfig/prod.json
- Grepconfig/prod.env
- Readconfig/app.production.json
- Grepconfig/app.production.toml
- Readconfig/production.yaml
- Grepconfig/production.env
- Readdeploy/prod/values.yaml
- Grepinfra/envs/prod/main.tfvars
- Readdeploy/prod/app.properties
- Readk8s/production/secrets.yaml
- Grepk8s/production/configmap.yml
- Readdistribution/prod.json
- Grepvendors/config/production.yml
- Readinfra/prod/main.tf
- Readconfig/nginx.prod.conf
- Grepconfig/app.prod.ini
Stays quiet on (66)
- Read/home/dev/.ssh/id_rsa.pub
- Readcerts/server.crt
- Editsrc/index.ts
- Editpackage.json
- Read/etc/passwd
- Read/etc/passwd-
- Read/etc/group
- Read/etc/hosts
- Read/etc/sudo.conf
- Read/etc/ssh/ssh_host_ed25519_key.pub
- Read/etc/ssh/ssh_host_key.pub
- Read/etc/ssh/sshd_config
- Read/etc/ssl/certs/ca-certificates.crt
- Read/etc/pki/tls/certs/server.crt
- Read/etc/kubernetes/manifests/kube-apiserver.yaml
- Read/etc/kubernetes/pki/ca.crt
- Read/etc/rancher/k3s/config.yaml
- Grep/opt/etc/app.conf
- Read/repo/.git/HEAD
- Read/repo/.gitconfig.example
- Readmcp.json.example
- Read/repo/.claude/settings.json
- Read/repo/claude.json
- Read/repo/.cursor/rules/style.mdc
- Read/repo/codex/config.toml
- Readconfig/database.staging.yml
- Readnode_modules/react/cjs/react.production.min.js
- Grepnode_modules/react-router/dist/production/index.d.ts
- Readnode_modules/some-lib/config/app.prod.json
- Readdist/prod.json
- Grepnode_modules/some-lib/config/app.production.json
- Readvendor/config/production.yml
- Readdist/prod/app.json
- Grepvendor/production/config.yml
- Readsrc/Settings.prod.test.tsx
- Readinfra/bin/prod.ts
- Grepwebpack.prod.js
- Readconfig/database.prod.md
- Readconfig/prod.md
- Readconfig/app.production.mdx
- Readconfig/production.txt
- Grepdeploy/prod/RUNBOOK.txt
- Readdocs/production/README.md
- Edit/etc/shadow
- Write/etc/shadow-
- Write/etc/sudoers.d/admins
- Write/etc/ssh/ssh_host_ed25519_key
- Edit/etc/ssh/ssh_host_key
- Edit/etc/ssl/private/server.key
- Write/etc/pki/tls/private/server.key
- Write/etc/kubernetes/admin.conf
- Write/etc/kubernetes/pki/sa.key
- Edit/etc/rancher/k3s/k3s.yaml
- Edit/etc/hosts
- Edit/repo/.git/config
- Edit.mcp.json
- Write/repo/.claude/settings.local.json
- Write/Users/dev/.claude.json
- Edit/repo/.cursor/mcp.json
- Edit/Users/dev/.codex/config.toml
- Editconfig/database.prod.yml
- Writeconfig/prod.json
- Editconfig/app.production.json
- Writeconfig/production.yaml
- Editdeploy/prod/values.yaml
- Writek8s/production/secrets.yaml
In your agent
What "ask" means in each app
The guard runs as a hook in each app, and each app gives a hook different powers. Here is what this rule's default action does in each one.
- Claude Code
- You are asked before the call runs. If your settings.json already allows the tool outright, Claude Code runs it with no prompt.
- Cursor
- A terminal command that reaches the guard gets Cursor's approval card. Any other call that needs approval, such as a file edit or a read, is refused, because Cursor cannot ask there.
- Codex CLI
- Codex cannot ask, so the call is refused, and the reason says a person has to approve it.
This rule matches file paths. In Codex CLI, reading a file fires no hook, and in Cursor, reads shown as Explored are not checked, so there it sees fewer calls than in Claude Code. Each app hands the guard a different set of calls: in a Cursor sandbox run mode, for one, some terminal commands run without reaching the guard at all. Read the notes for Cursor and for Codex CLI before you rely on a rule there.
Make it yours
Change what it does in one command
Turn it off, change its action, or silence it on one command shape. The narrow one is allow: the rule keeps catching everything else.
Run it locally
Put these guardrails in front of your agent.
AgentTrail Guard is free and open source. It checks every command and file change against the whole library before your agent runs it, on your machine, with no account.
npm i -g @agenttrail/guard