/

CVE-2026-26268

Severity:

HIGH RISK

(8.0)

Improper Authorization / Access Control in Cursor AI Code

CVE-2026-26268

Analyzed

Vulnerability type

Category:

Improper Authorization / Access Control

CWE:

CWE-862

Impact:

Sandbox Escape and Remote Code Execution via Malicious Git Hooks

Severity:

HIGH RISK

(8.0)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

Cursor AI code editor versions prior to 2.5 allowed AI agents to write to unprotected .git configuration and hook files inside the project workspace.

A malicious or prompt-injected agent could persist malicious Git hooks that lead to remote code execution outside the intended sandbox when Git operations later trigger those hooks, without additional user interaction.

Affected context

The issue affects Cursor environments where:

  • The AI agent (or tools it invokes) can write to the project filesystem, including .git directories.
  • Git is installed and used in the environment, and its hooks are executed in the host context rather than inside the same restricted sandbox as the AI.
  • Git configuration and hook files are not isolated, filtered, or subject to stricter permissions than general project files.

In such setups, the AI sandbox boundary does not align with Git's execution model, allowing configuration changes inside .git to influence later host-level Git operations.

Exploit preconditions

  • Attack surface: The AI assistant and tools invoked through Cursor that can write files into the project workspace.
  • Required access: Logical ability for an AI agent or prompt-injected tool to create or modify files under .git/, including hook scripts and Git config files.
  • Trigger point: Subsequent Git commands (e.g., commit, push, merge, checkout, receive) that cause Git to run hooks automatically using the host's execution context.
  • Why exploitation is possible: The AI sandbox was treated as untrusted but was still permitted to write to Git's configuration and hook locations. Git then trusts and executes these hook scripts without re-enforcing the sandbox boundary, effectively bridging from a constrained AI environment to a more privileged host environment.

Why this happens

The core problem is an improper authorization boundary between AI-generated file writes and sensitive Git control files. Under CWE-862: Missing Authorization, the system fails to enforce additional checks for operations that modify privileged configuration, treating writes to .git directories as equivalent to regular project files.

Conceptually, Git hooks and config represent executable policy and code, not just data. By allowing an untrusted component (the AI agent, influenced by prompt injection or malicious instructions) to freely modify these assets, the editor creates an indirect code execution path. The sandbox model assumes file writes are safe but overlooks that some files (Git hooks) are automatically executed later in a different, more trusted context.

Potential impact

  • AI-induced modification or creation of Git hook scripts that execute arbitrary commands.
  • Sandbox escape when Git runs the malicious hooks outside the original constrained environment.
  • Remote code execution in the user's development environment with the user's OS-level privileges.
  • Persistent compromise of the repository, where malicious hooks survive editor restarts and continue to execute on future Git operations.
  • Potential exfiltration of sensitive data such as SSH keys, access tokens, or source code via the malicious hooks.
  • Lateral movement to other repositories or services if compromised hooks interact with external tooling or CI systems.

General mitigation guidance

Effective mitigation focuses on treating Git metadata and configuration as sensitive control surfaces, not ordinary project files, and enforcing strict boundaries around them:

  • Introduce explicit authorization layers for any write access to .git directories, Git config files, and hook scripts from untrusted components.
  • Segregate AI-generated content from repository control files by design, e.g., limiting the AI to a dedicated working directory that excludes .git and other control paths.
  • Implement path-based allowlists so the AI can only create or modify files in non-sensitive locations, blocking or requiring elevated confirmation for operations targeting .git/.
  • Run Git commands and any resulting hooks in a similarly constrained environment, aligning the execution context of hooks with the AI sandbox where feasible.
  • Apply least-privilege principles to the AI process and tools it can invoke, minimizing the impact if configuration boundaries are accidentally crossed.
  • Treat configuration-as-code surfaces (hooks, CI configs, toolchains) as high-risk and subject them to extra scrutiny compared to ordinary source files.

How teams detect issues like this

Detection can combine both preventative and forensic techniques:

  • Static policy enforcement: Implement file-system guards or middleware that log or block writes to .git/ and hook locations from AI or automation processes.
  • Code review and policy checks: Incorporate checks in review workflows to flag changes to Git hooks and configuration files, especially if initiated by AI tools or automated agents.
  • Runtime monitoring: Monitor filesystem events for unexpected modifications under .git/hooks/ or .git/config during AI-driven sessions and raise alerts on suspicious patterns.
  • Configuration scanning: Periodically scan repositories for non-standard or newly added Git hooks, anomalous scripts, or unexpected commands embedded in hook files.
  • Automated tooling: Use security scanners or internal tools that understand repository structure and can enforce policies (e.g., "no AI process may write to .git") across development environments.

Sources

SourceLink
github.comgithub.com/cursor/cursor/security/advisories/GHSA-8pcm-8jpx-hv8r

Frequently asked

questions

It can be influenced remotely through prompt injection or malicious instructions provided to the AI, but actual exploitation occurs on the developer's machine or environment where Git is run. The attacker typically needs a way to control or influence what the AI writes into the repository.

The attacker needs the ability to drive the AI into writing or modifying files under .git/, which can happen via crafted prompts, injected content in code or documentation, or other untrusted project inputs that the AI is instructed to follow.

Enforce strict authorization around sensitive repository control files: block or tightly gate writes to .git directories and hook scripts from AI or other untrusted components, and ensure that any automatically executed scripts originate only from trusted, reviewed sources.

Design AI-assisted development environments with explicit trust boundaries: isolate untrusted AI output to non-control areas, treat configuration and hooks as protected resources, align sandbox boundaries with all execution paths (including tools like Git), and add policy enforcement plus monitoring around any file that can lead to code execution.

Find out what's already
exploitable in your codebase.