Credentials saved in Claude Code's local settings
Claude Code’s local settings file can hold approved commands with secrets, and git can be told to include it.
Why it is risky
Section titled “Why it is risky”When you choose “Yes, and don’t ask again” for a command, Claude Code saves the exact command to .claude/settings.local.json in the project. If the command contained a token or password, the file now holds it in plain text. Claude Code expects that file to stay out of git, but whether it does depends on an ignore rule that may be missing in a repository or on another machine, and a file that was committed once stays in the history.
Example
Section titled “Example”A developer approves a curl command with a bearer token and chooses “don’t ask again”. The token is saved in .claude/settings.local.json. Later an agent runs git add .claude/settings.local.json in a repository that does not ignore the file, and the token reaches a commit.
This is a fictional example, not an event from a customer.
What Omnodex Detects
Section titled “What Omnodex Detects”Omnodex checks this in two ways.
- At session start, the Claude Code hook reads the project’s
.claude/settings.local.json. If it holds a recognized credential, Omnodex records a finding,RULE_CREDENTIAL_IN_SETTINGS_LOCAL, that names the credential types and says whether the repository’s own.gitignorefiles (or.git/info/exclude) cover the file and whether git already tracks it. It never records the value. The severity is HIGH if git tracks the file, MEDIUM if the project is in a repository that does not ignore the file, and LOW otherwise. The same state is reported once, not at every session. Your global git ignore is not counted, because it protects only your machine. - In a command, a rule reports a
git add,commit,stashorrmcommand that names the local settings file.
| Rule ID | Event category | Tier | Base severity |
|---|---|---|---|
RULE_CREDENTIAL_SETTINGS_LOCAL_GIT | credential_exposure | Community | HIGH |
Base severity is the rule default. A finding involving content saved for later execution may have a lower severity. Your loaded rule version and event details determine the finding you see.
The credential patterns are the same ones used for credentials in tool parameters. The session-start check is for Claude Code projects.
What to check next
Section titled “What to check next”Open the file and remove entries that contain a secret, then rotate the credential, since it was stored in plain text. Add .claude/settings.local.json to the repository’s .gitignore. If git tracks the file, remove it from the index and treat the secret as exposed, including any commit that already left your machine. Prefer approving commands that read a secret from the environment rather than containing it.
False positives
Section titled “False positives”A test or placeholder value that looks like a credential is reported, as is a credential that is intentionally kept in a private repository. An explicit git add of the file for a deliberate reason also matches the command rule.
False negatives
Section titled “False negatives”The session-start check runs once a session begins, so a secret saved during a session is reported at the next one. It does not read other agents’ settings, and it does not find a secret in a format the credential patterns do not cover. The command rule does not see git add ., git add -A or git commit -a, which do not name the file; the session-start report on the ignore state covers that case. Neither check removes a secret from a file or from git history.
Technical details
Section titled “Technical details”The command rule has a base severity of HIGH. It reads the command text and does not check the file’s contents. The session-start finding is written when a Claude Code session starts, from a read of the file at that moment.
A finding describes a pattern in captured activity. Review the original call, its result, and the task context before concluding that harm occurred. Absence of a finding does not establish that an operation is safe.