Understanding Claude Code “Don’t Ask Again” Risk: When Permission Rules Expose Secrets

Claude Code có thể lưu quy tắc cho những thao tác được người dùng chọn “Yes, and don’t ask again” vào tệp .claude/settings.local.json. Cơ chế này giúp giảm số lần hỏi quyền, nhưng nghiên cứu mới của Apiiro cho thấy câu lệnh được lưu có thể chứa mật khẩu, khóa API hoặc token rồi bị đưa lên kho GitHub công khai.

Claude Code permission dialog with the don't ask again option
Claude Code's permission dialog can save repository-scoped rules. Source: Claude Code documentation.

What does “Don’t Ask Again” actually store?

Theo tài liệu chính thức, quyền đọc thường không cần phê duyệt trong thư mục làm việc, trong khi lệnh shell, truy cập web và một số hành động khác có thể yêu cầu xác nhận. Với lệnh Bash hoặc miền WebFetch, lựa chọn không hỏi lại có thể tạo quy tắc tồn tại lâu dài theo từng repository trong .claude/settings.local.json.

The problem is not the configuration file itself but the command content placed in a rule. If a developer pastes a secret directly into a command line, the whole string may become persistent plaintext configuration data.

What scale of exposure did Apiiro find?

Apiiro cho biết đã khảo sát 104.185 bản sao công khai của .claude/settings.local.json trên 103.617 repository. Nhóm nghiên cứu tìm thấy 1.122 tệp chứa 1.379 bí mật riêng biệt; khi mở rộng sang lịch sử commit, cấu hình chia sẻ và transcript của agent, tổng số được báo cáo tăng lên 2.539 bí mật trong 1.994 repository.

These figures represent data detected as secrets, and Apiiro noted that it did not test whether every credential remained active. Even so, a key that once appeared in Git history should be treated as an incident and rotated.

Why can a file named “local” still reach GitHub?

The name can imply that the data stays on one machine. In practice, whether a file is committed depends on Git state, ignore rules, user actions, and automation. Project copying, configuration templates, or commands that stage all files can pull local data into a commit.

The risk can remain after deletion from the latest revision because secrets may persist in older commits, other branches, forks, caches, or synchronized transcripts.

The risk chain for development teams

Depending on its scope, an exposed token may allow access to private source code, cloud services, package registries, CI/CD systems, or customer data. An attacker with write access could also alter workflows, inject malicious code into builds, or steal additional credentials.

This is a clear intersection of AI coding assistants, permission management, and secret hygiene. The agent does not necessarily disclose the key by itself; persistent approval turns a convenient command into durable data, and Git amplifies its distribution.

How to inspect a repository safely

  • Tìm mọi bản sao của .claude/settings.local.json trong cây làm việc, nhánh, lịch sử commit và các bản fork.
  • Review Bash rules, URLs, headers, and parameters for tokens, passwords, access keys, or connection strings.
  • Run secret scanning on developer machines, pre-commit hooks, pull requests, and CI, not only on the default branch.
  • Check service logs for unusual access involving credentials suspected of exposure.

If a secret is found, deleting the file is not enough

Revoke or rotate the key first, because rewriting Git history cannot invalidate copies already downloaded. Then remove the data from history where appropriate, notify owners of forks, and determine which resources the credential could access.

Treat data that appeared in a public repository as exposed even without observed abuse. High-privilege keys require log investigation, rotation of dependent credentials, and an assessment of lateral movement.

Durable prevention measures

Do not place secrets directly in commands that may be saved as rules. Use a secret manager, runtime-provided environment variables, short-lived credentials, and least privilege. Allow rules should be limited to specific tools, commands, and domains, while teams should periodically remove broad or obsolete permissions.

Trong repository, bổ sung quy tắc bỏ qua phù hợp cho cấu hình cá nhân, nhưng không coi .gitignore là lớp bảo vệ duy nhất. Kiểm soát hiệu quả cần kết hợp đào tạo, secret scanning, bảo vệ nhánh, cảnh báo lịch sử và quy trình luân chuyển khóa nhanh.

The broader lesson for AI coding agents

Every “don’t ask again” decision is a policy change that can outlive one session. Convenient interfaces therefore need observability, narrow scope, and sensitive-data checks before persistence. Enterprises should govern agent configuration and transcripts like source code and operational logs, with classification, retention limits, access control, and leak monitoring.

VNCyberS compiled from Apiiro, The Hacker News, and Claude Code documentation

Contact Us

Email: [email protected]
Phone: +84 903260277