Claude Code 'Don't Ask Again' Leaks: GitLab's 4-Layer Fix

Claude Code 'Don't Ask Again' Leaks: GitLab's 4-Layer Fix

Enterprise Developer Platforms

Apiiro found 104,185 copies of Claude Code’s .claude/settings.local.json in public repositories, and 1,122 of them held at least one secret. The cause is a convenience button: approving a shell command with “Yes, and don’t ask again” saves that exact command, token included, to a file that the project’s own .gitignore doesn’t exclude. GitLab has now published the fix for group owners, and it shows how much of the clean-up sits outside any single developer’s laptop.

What Happened

GitLab’s guide explains the mechanism. When a developer picks “Yes, and don’t ask again,” Claude Code writes the approved command to .claude/settings.local.json in the project folder and runs it without asking in future. If the command contained a password or a token, so does the file. Claude Code keeps the file out of Git through the developer’s personal global excludes, not the repository’s .gitignore, so the protection lives on one laptop and “does not travel with the repository.” The result, in GitLab’s words, is that the file “gets committed and pushed wherever the repository lives.”

The figures come from Apiiro’s research, published in early November, which GitLab cites. Hundreds more secrets were found only in history, in files that had since been deleted. GitLab says its own infrastructure secrets are protected.

Why It Matters

GitLab’s fix is four layers, each a setting a group owner changes once. The first is a .gitignore line for .claude/settings.local.json in every repository, and on Premium and Ultimate, in the group’s file templates project so new projects inherit it. The second is a push rule under Prohibited filenames that rejects any push adding the file on any branch. Two caveats apply: push rules only check files being added, not changes to a file already tracked, and a group rule is copied only into projects created afterwards, so existing projects need it set individually or through the API.

The third layer, Secret Push Protection, inspects the content of every push for known token formats regardless of file name. The fourth is a scan execution policy on the top-level group that runs Secret Detection in every project, including those with no CI file, with a weekly scheduled run that can cover full history.

What This Means for Builders

Finding past exposure takes more than search. Code search shows only the default branch as it stands today, so deleted copies and other branches are invisible. GitLab’s answer is the commits API with all=true and, crucially, follow=false; without it, a repository with more than a page of commits can come back empty even though the file is in its history. Forks keep their own copies and histories, so each needs the same check. GitLab Duo Agentic Chat can run the audit and open clean-up merge requests across a group, pausing twice for approval.

The order of clean-up is fixed: rotate, then remove, then purge. GitLab says to treat every secret the file ever held as public from the date of its first commit, and to rotate it at the provider before touching the file, since deleting the file leaves the value in history and in every fork. Purging uses Remove blobs, then housekeeping, and forks sharing an object pool must be detached first. Stack Archive’s look at Betterleaks, the open-source secrets scanner, covers detection beyond GitLab’s built-in tools.

The So What

Group owners whose developers use Claude Code should run the history check across every project and fork this week, rotate any secret the file ever contained, and only then remove and purge it. Then add the push rule to existing projects as well as the group, turn on Secret Push Protection, and put .claude/settings.local.json in each repository’s .gitignore so the protection travels with the code.

Source: GitLab

Content created with AI assistance and reviewed for accuracy.

💬

Join the conversation

Stack Insiders is our free community for readers who want to go deeper — share resources, ask questions, and connect with others across every vertical we cover.

Join Stack Insiders →

Newsletter coming soon.

Curated digests across AI, biohacking, photography, travel, and more. Be the first to know when we launch.