Secure Credential Management: Prevent Unintended Config File Exposure

Status Fixed / completed
Maintainer reply ✓ Yes — bcherny
Activity 10 comments · opened Mar 21, 2025 · closed Mar 21, 2025
💡 Likely answer: A maintainer (bcherny, collaborator) responded on this thread — see the highlighted reply below.

Bug Description
How to avoid Claude to read secrets files, without asking the permissions, like .env, config.yaml, secret.yaml, etc..?
~~I don't see exclude_files list configuration~~ on the Anthropic Claude Documentation.. I saw only this part at the end with Claude config

Environment Info

  • Platform: macos
  • Terminal: iTerm.app
  • Version: 0.2.52
  • Feedback ID: e007ac78-14ca-469d-88c8-f3ff6d065333

Errors

[]

I don't know if it's similar with the github issue #401 😉
Maybe it's more related with #79 👍

View original on GitHub ↗

10 Comments

bcherny collaborator · 1 year ago
davidaparicio · 1 year ago

Yes, but why Claude doesn't ask the permissions before reading these files, as it already does when Clause using commands such as grep, sed, go test or bash?
Indeed, it was my great surprise, it was the first time, after weeks as a user, that Claude had read this file, for no specific reason..

bcherny collaborator · 1 year ago

Claude does not ask for permissions to read files in the directory you started it in. We could special case files that start with a . to ask for permission the first time.

cc @rboyce-ant for thoughts

max-sixty · 1 year ago

a better way of discriminating — to the extent we sometimes want to ask permission — would be to ask permission for files which aren't in the git index

a file with secrets, such as .env, shouldn't be in the git index

but standard files that we want Claude to read, such as .github/, will be in the git index

davidaparicio · 1 year ago

Yes, this file was a new file, I forgot to modify my .gitignore (as I forgot to set ignorePatterns)
So Claude took it, without asking permission...
Only, because my query was a big open question: "fix that bug" 😉

I think all the files stagged once on git are usable by Claude (if there are no secrets.... 🤔)

.github/ can have secrets on it @max-sixty or you are giving a conter-example to @bcherny ?

max-sixty · 1 year ago
.github/ can have secrets on it @max-sixty or you are giving a conter-example to @bcherny ?

files committed to the repo are much less likely to contain secrets

davidaparicio · 1 year ago

Totally agree, and I think, it's better to ask permissions for others.

In my case, CLAUDE would have alerted me to an inadvertent oversight on my part, and I would have taken an additional manual action to permanently ignore this file 😃

davidaparicio · 1 year ago
a better way of discriminating — to the extent we sometimes want to ask permission — would be to ask permission for files which aren't in the git index

But my file wasn't in the git index, so the CLI must ask the permission first for possible first-time use.
What do you think @max-sixty / @bcherny, especially when creating a freshly created file?

max-sixty · 1 year ago
What do you think @max-sixty / @bcherny, especially when creating a freshly created file?

(tbc, I'm a random user)

to answer: "not in the git index" might be better as "ignored by git". I agree if claude has just written a file and hasn't yet added it to the index, you don't want it asking permission there

github-actions[bot] · 1 year ago

This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.