🎉 75% of content is free forever — Unlock Premium from $10/mo →
CW
NEWSLIVESearch All Content
đŸ’ŧ Servicesâ„šī¸ Aboutâœ‰ī¸ ContactView Pricing Plansfrom $10
Security AlertAI Security14 min read

Plugin4Shell: Zero-Click RCE in Four AI Coding Agents

C
ChatWhole AI Team|2026-09-19

Plugin4Shell: Zero-Click RCE Vulnerability Hits Claude Code, Copilot, and Gemini CLI

Security researchers at AIR have disclosed Plugin4Shell — a critical zero-click remote code execution (RCE) vulnerability that allows attackers to swap malicious plugin code past SHA-pinning checks in four major AI coding agents: Claude Code, OpenAI Codex, GitHub Copilot, and Gemini CLI.

âš ī¸

This is a critical security vulnerability. If you use any AI coding agent, update immediately. Anthropic has patched in Claude Code 2.1.179 and OpenAI in Codex 0.146.0. Google deprecated Gemini CLI without patching. Microsoft has not shipped a Copilot fix.

What is Plugin4Shell?

Plugin4Shell exploits a fundamental flaw in how Git handles branch names that match commit hashes. The attack allows a malicious actor to:

  1. Create a Git branch whose name matches a legitimate commit hash
  2. Push the branch to a repository
  3. When the AI agent checks out the branch, Git resolves it as a branch name, not a commit
  4. The SHA-pinning check passes because the agent sees a "clean" checkout
  5. Malicious plugin code is executed with full agent permissions

The Attack Flow

Architecture Diagram
Attacker creates branch named "a1b2c3d4e5f6" (matches a legitimate commit SHA)
    ↓
Pushes branch to repository
    ↓
AI agent performs git checkout a1b2c3d4e5f6
    ↓
Git resolves as branch (not commit) — malicious code is loaded
    ↓
SHA-pinning check reports "clean install"
    ↓
Malicious plugin executes with agent permissions
Plugin4Shell Attack FlowAttackerCreates malicious branchnamed after commit SHARepositoryBranch pushed withlegitimate SHA nameAI AgentExecutes git checkoutwith SHA referenceGit ResolutionBranch takes priorityover commit SHASHA-Pinning BypassCheck passes becausebranch name matches SHAMalicious ExecutionCode runs with fullagent permissionsImpactData exfiltrationCode injectionDeveloperUnsuspecting victimuses AI agent normallyAttack Vector SummaryMalicious ComponentSystem ComponentVulnerability PointLegitimate UserCritical: Zero user interaction required — agent automatically checks out branch

Affected Products

ProductStatusPatched Version
Claude CodePatched2.1.179
OpenAI CodexPatched0.146.0
GitHub CopilotNot patchedN/A
Gemini CLIDeprecatedNo fix planned

â„šī¸

Anthropic and OpenAI responded quickly with patches. Google chose to deprecate Gemini CLI rather than fix the vulnerability. Microsoft has not shipped a fix for GitHub Copilot.

Technical Deep Dive

Git's Branch vs. Commit Ambiguity

The vulnerability exploits Git's behavior when a branch name matches a SHA-1 hash prefix:

# Creating a malicious branch
git checkout -b a1b2c3d4e5f6
# ... make malicious changes ...
git push origin a1b2c3d4e5f6

# When someone runs:
git checkout a1b2c3d4e5f6

# Git resolves as BRANCH (not commit)
# If a1b2c3d4e5f6 matches a commit SHA prefix, Git prefers the branch

How SHA-Pinning Works

AI coding agents use SHA-pinning to verify plugin integrity:

  1. Record the expected commit SHA for each plugin
  2. Before loading, verify the current SHA matches
  3. If mismatch, refuse to load the plugin

The flaw: running git checkout against a commit SHA resolves to a branch if one exists with that name, bypassing the integrity check entirely.

The Bypass

python
# Simplified attack demonstration
# 1. Legitimate plugin at commit a1b2c3d4e5f6
# 2. Attacker creates branch named "a1b2c3d4e5f6" with malicious code
# 3. Agent runs: git checkout a1b2c3d4e5f6
# 4. Git checks: does branch "a1b2c3d4e5f6" exist? YES → check out branch
# 5. SHA check: current SHA matches expected? YES (it's the branch name)
# 6. Malicious code loads as if it were the legitimate plugin

Impact Assessment

What Attackers Can Do

With Plugin4Shell, an attacker can:

  • Read all files the AI agent has access to
  • Execute arbitrary code on the developer's machine
  • Steal credentials and API keys
  • Modify source code silently
  • Exfiltrate data from private repositories
  • Pivot to other systems on the network

Who Is at Risk

  • Developers using AI coding agents with third-party plugins
  • Organizations with shared repositories where contributors could be compromised
  • Open-source projects where plugin provenance isn't fully trusted
  • CI/CD pipelines that use AI agents for code generation

âš ī¸

If your AI coding agent has access to production credentials, SSH keys, or API tokens, assume they are compromised until you've verified the agent's plugin integrity.

Remediation

Immediate Actions

  1. Update Claude Code to version 2.1.179 or later
  2. Update OpenAI Codex to version 0.146.0 or later
  3. Uninstall Gemini CLI — Google has deprecated it without patching
  4. Audit GitHub Copilot usage — no fix is available

Verify Plugin Integrity

# Check for suspicious branches matching commit SHAs
git branch -a | grep -E '^[a-f0-9]{7,40}$'

# Remove any matching branches
git branch -D <suspicious-branch-name>

Long-Term Protections

  1. Pin plugins to full 40-character SHAs (not 7-character abbreviations)
  2. Use git checkout --detach to avoid branch resolution
  3. Implement branch naming policies that prohibit SHA-like names
  4. Enable Git's checkout.default to prefer commits over branches

None of those four steps requires a vendor patch, which is the point for Copilot users who have no fix to install. Applied together they remove the ambiguity itself rather than this one exploit: a ref that merely looks like a hash can no longer stand in for the hash, so the next variant of the same class has nothing left to resolve against.

# Add to .gitconfig
[checkout]
    default = detach

Detecting a SHA-Named Branch Today

Run this inside every clone your agent can touch. The pattern matches any local or remote branch whose name is a plausible object id:

git for-each-ref --format='%(refname:short)' refs/heads refs/remotes \
  | grep -E '^[0-9a-f]{7,40}$'

Empty output means no branch can shadow a commit in that repository. A hit is not automatically malicious — abbreviated names such as a1b2c3d occur by accident — but any match in a repo you did not create deserves a look at git log timestamps and the committer identity behind it.

The same check belongs in CI as a failing condition, and the hosting provider should reject new branches that are pure hex at the ref update layer rather than relying on reviewers to notice.

The Bigger Picture

AI Agent Security

Plugin4Shell highlights a broader issue: AI coding agents are becoming high-value attack targets because they have:

  • Access to source code repositories
  • Permissions to execute commands
  • Credentials for deployment and CI/CD
  • Trust from developers who don't scrutinize every action

Supply Chain Risks

The attack is a supply chain vulnerability — malicious code enters through a trusted channel (Git) that the AI agent trusts implicitly.

What Needs to Change

  1. Git providers should implement branch naming policies
  2. AI agents should verify full SHA hashes, not abbreviated ones
  3. Developers should treat AI agents with the same suspicion as any external dependency
  4. Organizations should audit AI agent permissions and access

💡

Treat your AI coding agent like a junior developer with admin access — it needs supervision, code review, and restricted permissions until we have better security primitives.

Key Takeaways

  • Zero-click RCE vulnerability affects Claude Code, OpenAI Codex, GitHub Copilot, and Gemini CLI
  • Git branch naming exploit bypasses SHA-pinning integrity checks
  • 2 of 4 agents patched — Anthropic and OpenAI responded quickly
  • Google deprecated Gemini CLI without patching; Microsoft unpatched
  • 925 skills hijacked via SkillJacking technique, 134K agents affected
  • First supply chain vulnerability targeting the AI agent ecosystem
  • Immediate action required: Update Claude Code to v2.1.179, Codex to v0.146.0

Lessons Learned

  1. Zero-click attacks are real: No user interaction required beyond normal workflow
  2. Git is not a security boundary: Branch naming can be exploited
  3. AI agents are high-value targets: They have access and permissions that attackers want
  4. Rapid response matters: Anthropic and OpenAI patched within days; Google deprecated instead

Resources

Common Mistakes

Assuming SHA-pinning validates the code that was checked out

Fix: Detach at the full 40-character hash before verifying — git checkout --detach cannot resolve to a branch.

Leaving Gemini CLI installed because Google deprecated it

Fix: Deprecation shipped without a patch; uninstall the tool, rotate its tokens and remove its service account keys.

Hunting for malicious diffs instead of malicious refs

Fix: Enumerate branch names matching hex patterns first; the payload hides behind an innocent-looking ref, not in the diff.


Last updated: September 21, 2026

Explore More Articles

Search across 3100+ tutorials and news articles.