chore(hardening): widen sensitive-file coverage and apply it to Grep/Glob - #3
Merged
Conversation
…Glob Treat credential directories as sensitive whatever the file inside is called (.ssh, .gnupg, .aws, .azure, .kube, .config/gcloud, and the CLI's own credentials dir). Private keys and cloud credential files are routinely given local names like deploy_key or work-cluster.json, which a basename list cannot predict. Public keys, known_hosts, .ssh/config and .aws/config carry no secret and stay readable; the `config` exemption is per-directory because .kube/config IS the credential. Add the common credential files by name: .git-credentials, .netrc, .npmrc, .pypirc, .docker/config.json, kubeconfig, and the CLI's own config.toml, which holds the provider API key. Apply the check to Grep and Glob, which previously passed checkSensitive: false and so could search the contents of files Read, Write and Edit refuse to open. Applied to both engine copies of the policy. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.
Problem
The sensitive-file policy that guards the file tools was narrow in two ways:
.env*,id_rsa/id_ed25519/id_ecdsa,credentials, and.aws|.gcp/credentials. But private keys and cloud credential files are routinely given local names —deploy_key,work-cluster.json,sso-cache.json— which no basename list can predict. Common credential files (.git-credentials,.netrc,.npmrc,.docker/config.json,kubeconfig) were not covered either, nor was the CLI's own~/.kimi-code/config.toml, which holds the configured provider API key.checkSensitive: false. So a search could return the contents of files that Read/Write/Edit refuse to open.What changed
SENSITIVE_DIRECTORY_SEGMENTS): anything under.ssh,.gnupg,.aws,.azure,.kube,.config/gcloud, or the CLI's owncredentialsdir is sensitive regardless of filename.*.pub,known_hosts,.ssh/config(host aliases) and.aws/config(region settings) stay readable. Theconfigexemption is per-directory on purpose —.kube/configis the credential, so it stays blocked..git-credentials,.netrc/_netrc,.npmrc,.pypirc,.dockercfg,.docker/config.json,kubeconfig,.kimi-code/config.toml.checkSensitive: true, matching the other file tools.agent-coreandagent-core-v2).Testing
known_hosts,.ssh/config,.aws/config,*.pub) still read.agent-core+agent-core-v2). No suite depended on Grep/Glob skipping the check.hostFsWatchService.test.ts(a timing-sensitive fs-watcher test); it passes on re-run and has no reference to this policy.oxlintandtsc --noEmitclean for both packages.Note on scope
This PR covers which paths are treated as sensitive. It does not change how paths are canonicalised — that guard is still lexical (no
realpath), so a symlink inside the workspace is still resolved by name only. Closing that is a separate change with a real design decision behind it (the path-access module is pure and synchronous, whilerealpathis async through the host FS abstraction), so it is deliberately not bundled here.Checklist
minor— more paths are refused than before).