Security researchers at Apiiro have uncovered a critical vulnerability in how developers interact with Claude Code, revealing that 1,122 public copies of the .claude/settings.local.json file contain exposed secrets. The issue stems from the convenience feature that allows users to approve shell commands with "Yes, and don't ask again," which inadvertently saves the entire command string—including any inline credentials—as a standing permission rule. This transforms a simple configuration file into an unencrypted credential store, posing a significant risk to teams using the LLM for automation.

The Mechanism of Exposure

The exposure occurs in two distinct stages. First, a developer approves a shell command containing a password, such as one with PGPASSWORD=EXAMPLE_ONLY. If the user selects the option to save this approval, the literal text of the command, including the credential, is persisted in settings.local.json. Second, if this local configuration file is committed to a shared repository, the secret becomes accessible to anyone who can read that repository. It is crucial to note that a local copy alone does not constitute a breach; the credential is only exposed once the file leaves the local environment.

Audit Your Repository History

Before deleting files, developers must determine where the secrets have traveled. Inspect the settings file in a private editor first to avoid leaking values on screen. Then, use Git commands to check if the file is currently tracked or exists in the history. Run git ls-files --error-unmatch .claude/settings.local.json to see if the file is in the index. If it is not tracked, check the history with git log --follow --all --oneline -- .claude/settings.local.json. This reveals if the file was committed in the past, even if it is absent from the current index.

Rotate Credentials Before Cleanup

The most important rule for remediation is to rotate the exposed credentials before deleting the file. Simply removing the file from the repository is insufficient because the credential may still exist in clones, forks, or local backups. Once the credential is rotated, use GitHub's sensitive-data removal guidance to clean the history. After confirming the local file contains no secrets, remove it from the Git index with git rm --cached .claude/settings.local.json. This ensures the file remains in the working tree for local use but is no longer tracked by Git.

Prevent Future Leaks

To prevent recurrence, teams should establish strict design rules. Avoid writing credentials directly into configuration files or commands that can be saved as permission rules. Instead, prefer using connection services, environment variables, or $DATABASE_URL for database clients. Claude Code also offers a safer pattern via the AskUserQuestion tool, which supports password types stored in the session transcript's secret store. Additionally, ensure that .claude/settings.local.json is added to a global exclude file, such as **/.claude/settings.local.json, to prevent accidental commits across different clients.

Key Takeaways

  • 1,122 public copies of .claude/settings.local.json were found containing secrets by Apiiro.
  • Saving shell command approvals can persist inline credentials in local settings files.
  • Always rotate exposed credentials before deleting files or cleaning Git history.
  • Use environment variables or the AskUserQuestion tool instead of hardcoding passwords in commands.

The Bottom Line

Convenience features in AI coding agents often trade security for speed; Claude Code's saved approvals are a prime example. Treat every saved command as a potential secret store, and enforce strict exclusion rules for local configuration files to prevent credential leakage.