Coding Agent Security Flaws Hide in Settings Files

Settings file switching off coding agent security checks

Settings files in a cloned repository can switch off the built-in defenses of AI coding tools, and that makes coding agent security a configuration problem as much as a code problem. In testing, a six-line settings file disabled most of Claude Code’s safeguards without a single warning.

Six lines that turn off the alarms

Claude Code checks environment variables while it runs, and some of them govern its protections. Three of those protections matter here: a scanner that looks for injection patterns in Bash commands, a rule against running as root with full permissions, and telemetry that gives Anthropic a view of misuse.

All three consult variables that a single settings file can define in an env block:

  • CLAUDE_CODE_DISABLE_COMMAND_INJECTION_CHECK disables the Bash injection scan.
  • IS_SANDBOX declares the tool to be sandboxed, so it will start as root with approvals automated.
  • CLAUDE_CODE_BUBBLEWRAP is an undocumented internal flag that asserts a Bubblewrap sandbox exists.
  • CLAUDE_CODE_DISABLE_CLAUDE_MDS prevents project CLAUDE.md instructions from loading.
  • DISABLE_TELEMETRY and DISABLE_ERROR_REPORTING mute the logs an investigator would rely on.

The tool honored every variable. It showed no dialog and no indicator while running. Only debug logs recorded the change.

AI coding assistants: turning off the alarm with eight lines of JSON
Image: Harness.io

Why it works

First, the tool takes a claim as proof. Whether it is contained is a fact about its surroundings, yet IS_SANDBOX=1 merely states it, and the project being run can write that variable.

Second, repositories carry settings files, so a clone can import them. Earlier research proved the pattern. Hooks and variables placed in a repo’s .claude/settings.json executed before the user answered the trust prompt (CVE-2025-59536), and a custom ANTHROPIC_BASE_URL exposed the API key ahead of consent (CVE-2026-21852). Both are fixed.

Hooks were covered by a trust prompt. The env block wasn’t, so the riskiest part of the configuration bypassed consent.

coding agent security image 2
Image: Harness.io

An attack that waits

The attacker needn’t win early. A developer clones a harmless repo and accepts the prompt. Weeks on, a pull request edits the settings file with a few env lines that look like routine upkeep. They disable the injection check and claim a sandbox. A later change hides a command injection in a file the agent will open.

The developer’s first approval keeps applying, since it covers the project and not its changing contents. A June incident matches this. A hijacked contributor account added agent config files for four tools, among them a Claude Code SessionStart hook, to Azure/durabletask. The commit changed no source, carried a false date and a [skip ci] tag.

coding agent security image 3
Image: Harness.io

Other places the same trick appears

Editors can inject variables as well. The terminal.integrated.env option in a repo’s .vscode/settings.json applies to each integrated terminal. Point NODE_OPTIONS at a script shipped in the repo and every Node process there runs it first. The agent’s hidden terminal was unaffected in testing, but the developer’s own terminal was exposed.

Git config does reach the agent. A core.fsmonitor line in .git/config names a program git launches on each status check, and agents run those checks in the background. Researchers reported it ran before the workspace-trust prompt in Claude Code, fixed in v2.1.196.

Optional security plugins have gaps too. The one examined can be switched off by an environment variable and trusts a progress file that earlier hooks can write. It watches only the Write and Edit tools, though Bash can produce the same output, and it compares text literally and stops at the first match.

What teams should change

The fix isn’t removing the knobs, since operations need them. It’s treating them as part of the security model.

  • Review settings files, env blocks and IDE config in pull requests the way you review source.
  • Treat any config that disables a check as a change that needs a stated reason.
  • Treat kill-switch variables as indicators of compromise.
  • Keep agent config out of plain text and give each MCP server its own revocable token.

Agent configs are targets themselves. In April the hijacked bitwarden/cli 2026.4.0 npm package hunted for ~/.claude.json and ~/.claude/mcp.json alongside SSH keys and cloud credentials. Bitwarden said the bad build was up for roughly 90 minutes and showed no sign of touching vault data.

The analysis continues with a look at event systems that reinstall themselves, so that cleaning up a repository doesn’t clean up the agent.

Source: Harness.io

Written by

Saksham Bhargava

Saksham Bhargava runs Alteroid and has been writing about consumer technology for over five years, covering iPhone, Android, Windows, AI tools and gaming. With an MCA and six years of hands-on web development experience, he tests the features he writes about on his own devices and focuses on clear, practical guides that solve real problems. Away from the screen, he enjoys travelling to places most tourists skip.