Repository navigation
Make confine read only what it needs in the home directory - #4
Merged
Merged
Conversation
`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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
confinekept a confined command from reading~/.ssh,~/.aws,~/.gnupgand~/.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
-roption, 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.