Heuristic:1ay1 Agentty Credential Masking
| Knowledge Sources | |
|---|---|
| Domains | Security, Configuration |
| Last Updated | 2026-10-28 14:00 GMT |
Overview
Exhaustive deny-list of credential paths (SSH keys, cloud tokens, shell history) applied after every sandbox grant to ensure an approved command can never read a credential it was never given.
Description
The credential masking heuristic uses two lists: `kAlwaysMasked` (absolute paths under $HOME that are never exposed regardless of filesystem scope) and `kAlwaysMaskedNames` (basenames masked anywhere they appear, including inside the workspace). The lists are applied AFTER every grant — including HostReadable scope and user-added read_paths — so the credential deny-list is the final word. Landlock makes this cheap and exact: a deny rule on a subtree beats the grants above it. On platforms without landlock, mounts (tmpfs over the directory, empty file over the file) achieve the same effect.
The lists are deliberately exhaustive: they cover not just the obvious cases (.ssh, .aws, .gnupg) but also shell/REPL history files (where pasted tokens end up), browser profiles (key material + data leave together), other agents' sign-in files (.codex, .claude), and package manager tokens (.npmrc, .pypirc, .netrc). The `.env` family is matched on basename so a repo-local secret is masked even in the read-write workspace.
Usage
Use this heuristic when designing any sandbox that binds filesystem paths. The key insight: a careful read set (binding ~/.cargo/bin instead of ~/.cargo) is the right outcome but is fragile — it holds because somebody chose the narrow path, and the next person adding a config dir could take credentials with it. A deny list applied after every grant is structural, not accidental.
The Insight (Rule of Thumb)
- Action: Maintain two lists: `kAlwaysMasked` (absolute $HOME paths) and `kAlwaysMaskedNames` (basenames matched anywhere). Apply them after every filesystem grant.
- Value: The lists cover: SSH keys, cloud CLI configs, package manager tokens, shell history, browser profiles, other agent sign-ins, and the `.env` family (matched on basename, including `*.tfvars` and `*.pem` suffixes).
- Trade-off: A build that reads .env for configuration will not see it inside the sandbox. The user can explicitly allowlist a path if needed, but the default is deny.
- Compatibility: Landlock: deny rule on subtree. macOS seatbelt: same. Mount ns without landlock: tmpfs over directory, empty file over file. Windows: AppContainer default-deny + skip (no ACL to stamp).
Reasoning
The one property the sandbox is built around: "an approved command must not be able to read a credential it was never granted." Every source in the 2026 sandbox literature lists secret hygiene as a separate control ("no ambient production secrets"). The lists are exhaustive because a wall with one door next to it is no wall — masking `.env` while leaving `.env.production` is a wall with a door. The basename match catches the `.env` family everywhere, including inside the read-write workspace where scope does not save you.
Code Evidence
Always-masked absolute paths from `include/agentty/domain/sandbox_config.hpp:144-193`:
inline constexpr const char* kAlwaysMasked[] = {
"/.ssh", "/.aws", "/.gnupg", "/.kube", "/.docker/config.json",
"/.config/gh", "/.config/gcloud", "/.azure", "/.netrc",
"/.npmrc", "/.pypirc", "/.cargo/credentials",
"/.codex/auth.json", "/.claude/.credentials.json", "/.claude.json",
"/.config/github-copilot", "/.config/op",
"/.local/share/keyrings", "/.config/google-chrome", "/.mozilla",
"/.bash_history", "/.zsh_history", "/.python_history",
"/.agentty/memory.jsonl", "/.agentty/credentials",
// ...
};
Always-masked basenames from `include/agentty/domain/sandbox_config.hpp:201-243`:
inline constexpr const char* kAlwaysMaskedNames[] = {
".env", ".env.local", ".env.production", ".envrc.local",
".env.development", ".env.staging", ".env.test", ".env.dev", ".env.prod",
"id_rsa", "id_ed25519", "id_ecdsa", "id_dsa",
".npmrc", ".pypirc", ".netrc", ".git-credentials", ".dockercfg",
".pgpass", "credentials.json", "service-account.json",
"*.tfvars", "*.pem",
};
Mask implementation (mounts, not landlock deny) from `src/tool/util/sandbox_claybin.cpp:109-120`:
// A mount, not a landlock deny, and that distinction cost me an
// afternoon. landlock has no negative rule: add_rule() with zero rights
// is ENOMSG, and omitting the rule means the path INHERITS its ancestor's
// grant. So "bind $HOME, deny $HOME/.aws" is not expressible in landlock
// at all... What DOES work is making the path not be the file: bind
// something empty over it.