Skip to content

Make confine read only what it needs in the home directory - #4

Merged
penberg merged 1 commit into
mainfrom
confine-home-allowlist
Oct 28, 2026
Merged

penberg merged 1 commit into
mainfrom
confine-home-allowlist

Conversation

@penberg

@penberg penberg commented Oct 28, 2026

Copy link
Copy Markdown
Owner

confine kept a confined command from reading ~/.ssh, ~/.aws, ~/.gnupg and ~/.config/gh, and let it read everything else. A list of what may not be read must name every secret, and four do not: ~/.netrc, ~/.git-credentials, ~/.docker/config.json, ~/.kube/config, ~/.npmrc, tokens exported in ~/.zshrc, and the rest could all be read, and, with the network not confined, sent anywhere.

Now the command may read nothing in the home directory but what it may write to, paths given with the new -r option, and a short list of what commands need to run: git's configuration, ~/.claude.json, toolchains and what they install (~/.local/bin, ~/.local/share/claude, ~/.nvm, and so on), and on macOS the keychains, which Claude Code keeps its login in, and whose items the keychain itself guards. Secrets are kept from the command without knowing where each one is. Outside the home directory, reading is still allowed.

On macOS, the profile denies reading the home directory, and then allows reading the readable and writable paths in it. On Linux, the home directory is the one hidden path, and reading is granted to the readable paths, and reading and writing to the writable ones, by name.

What may be written to may still be read, such as a registry token in ~/.cargo/credentials.toml.

Suggested by shadidcodes on X (https://x.com/shadidcodes), who pointed out that the paths a command may read should be an allowlist.

`confine` kept a confined command from reading `~/.ssh`, `~/.aws`,
`~/.gnupg` and `~/.config/gh`, and let it read everything else. A list of
what may not be read must name every secret, and four do not: `~/.netrc`,
`~/.git-credentials`, `~/.docker/config.json`, `~/.kube/config`,
`~/.npmrc`, tokens exported in `~/.zshrc`, and the rest could all be read,
and, with the network not confined, sent anywhere.

Now the command may read nothing in the home directory but what it may
write to, paths given with the new `-r` option, and a short list of what
commands need to run: git's configuration, `~/.claude.json`, toolchains and
what they install (`~/.local/bin`, `~/.local/share/claude`, `~/.nvm`, and
so on), and on macOS the keychains, which Claude Code keeps its login in,
and whose items the keychain itself guards. Secrets are kept from the
command without knowing where each one is. Outside the home directory,
reading is still allowed.

On macOS, the profile denies reading the home directory, and then allows
reading the readable and writable paths in it. On Linux, the home
directory is the one hidden path, and reading is granted to the readable
paths, and reading and writing to the writable ones, by name.

What may be written to may still be read, such as a registry token in
`~/.cargo/credentials.toml`.

Suggested by shadidcodes on X (https://x.com/shadidcodes), who pointed out
that the paths a command may read should be an allowlist.
@penberg
penberg merged commit c0f7f08 into main Oct 28, 2026
2 checks passed
@penberg
penberg deleted the confine-home-allowlist branch October 28, 2026 11:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant