CVE-2026-45033: GitHub Copilot CLI: Nested Bare Repository Can Execute Arbitrary Commands via core.fsmonitor
GitHub Copilot CLI (@github/copilot) runs git without protection against nested bare repositories. A bare repo buried in a project can set core.fsmonitor to run a command whenever the agent runs git status or diff. Upgrade to 1.0.43.
Published May 11, 2026 · Updated Jun 9, 2026 · Analysis Oct 27, 2026
What an attacker can do
Git finds bare repositories on its own while it walks up and down directories. When it uses one, it reads that repo's config. Keys such as core.fsmonitor, core.hookspath, diff.external and merge.tool can name commands, and git runs them during routine operations like status, diff or rev-parse.
An attacker plants a bare repository inside a project, for example in vendor/malicious.git/, with core.fsmonitor pointing at a payload. The route can be a pull request that adds the directory, a dependency that ships one, or a cloned repo that already contains one. When Copilot CLI runs git in or near that directory, or uses grep or glob tools that trigger git in subdirectories, the payload runs with the user's rights. The user sees no prompt or approval. The advisory names data exfiltration, credential theft and file changes as outcomes. The attacker needs no account, only a way to get files into a repo the user opens with the agent.
Who is affected
Affected: @github/copilot up to 1.0.42 per the package data. The advisory prose says "prior to 1.0.42", so the two statements disagree about 1.0.42; treat it as affected. Check:
npm ls -g @github/copilot
copilot --versionAlso search your repositories for unexpected bare repos, especially in vendor/ and third_party/.
@github/copilot
- Ecosystem
- npm
- Affected
- <= 1.0.42
- Fixed in
- 1.0.43
- Check
npm ls @github/copilot
How to fix it
Upgrade GitHub Copilot CLI to 1.0.43 or later:
npm install -g @github/copilot@latestThe fix sets safe.bareRepository=explicit through git's GIT_CONFIG_COUNT, GIT_CONFIG_KEY_* and GIT_CONFIG_VALUE_* environment variables, which override every config file. Git then uses only explicitly allowed bare repositories. The advisory also advises caution in repos with nested bare repositories and a review of project directories for unexpected ones.
How to tell if you were hit
Look for directories that are bare git repos (they contain HEAD, objects/ and refs/ with no .git folder) inside projects, and check their config for fsmonitor, hookspath, external or tool keys that name commands. Review process trees for unexpected children of git processes started by the agent. Beam records agent shell commands and file access, which shows what git ran and where.
Original advisory
From the GitHub Advisory Database (CC BY 4.0).
Summary
A security vulnerability has been identified in GitHub Copilot CLI where a malicious bare git repository nested inside a project directory can achieve arbitrary code execution when the agent performs git operations. By exploiting git's automatic bare repository discovery during directory traversal, an attacker can set core.fsmonitor or other executable config keys to run arbitrary commands without user awareness or approval.
Details
Git supports bare repositories — repositories without a working tree — which can be discovered automatically when git traverses the directory hierarchy looking for a .git directory. When git discovers a bare repository, it reads and applies its configuration, including keys that specify external commands to execute.
The vulnerability arises because git's core.fsmonitor config key (and 15+ similar keys such as core.hookspath, diff.external, merge.tool, etc.) can specify arbitrary shell commands that git will execute as part of normal operations like status, diff, or rev-parse.
Attack Scenario
An attacker can exploit this by:
- Creating a bare git repository nested inside a seemingly normal project directory (e.g.,
vendor/malicious.git/or a deeply nested subdirectory) - Configuring
core.fsmonitor(or similar keys) in that bare repository to execute a malicious command - When GitHub Copilot CLI performs any git operation that traverses into or through that directory, git auto-discovers the bare repository, reads its config, and executes the attacker's command
This can occur when:
- The agent navigates into a subdirectory containing the buried bare repo
- The agent runs
git status,git diff, or other routine git commands - The agent uses tools like
greporglobthat may trigger git operations in subdirectories
Prior to the fix, the CLI had no protection against git auto-discovering bare repositories during directory traversal.
Impact
An attacker who can place a malicious bare repository inside a project — for example, through:
- A pull request adding a directory that contains a bare repository
- A compromised or malicious dependency that includes a bare repository
- A cloned repository that already contains nested bare repositories
— could achieve arbitrary code execution on the user's workstation whenever GitHub Copilot CLI performs git operations in or near the malicious directory.
Successful exploitation could lead to data exfiltration, credential theft, file modification, or further system compromise.
Affected Versions
- GitHub Copilot CLI versions prior to 1.0.42
Remediation and Mitigation
Fix
The fix sets safe.bareRepository=explicit via git's GIT_CONFIG_COUNT / GIT_CONFIG_KEY_* / GIT_CONFIG_VALUE_* environment variable mechanism, which has the highest precedence over all config file sources. This prevents git from automatically discovering and using bare repositories during directory traversal — only explicitly allowlisted bare repositories will be used.
User Actions
- Upgrade GitHub Copilot CLI to 1.0.43 or later.
- Exercise caution when working in repositories that contain nested bare git repositories.
- Review project directories for unexpected bare repositories, especially in
vendor/,third_party/, or deeply nested subdirectories.
Credited to syvb.
Questions
- Is Copilot CLI 1.0.42 affected?
The advisory is inconsistent: the metadata lists up to 1.0.42, the text says prior to 1.0.42. Upgrade to 1.0.43 to be safe.
- Does the user have to approve anything?
No. The advisory says the command runs without user awareness or approval when git touches the bare repo.
- How does the attacker get the repo in place?
Through a pull request, a malicious dependency that includes a bare repository, or a cloned repository that already contains one.
- What does the fix do?
It sets safe.bareRepository=explicit through git environment config, so git no longer auto-discovers bare repositories.
References
How this page is made: the data panel comes from the GitHub Advisory Database, CISA’s KEV catalog, the NVD and FIRST EPSS, and updates twice a day. The analysis is written by an AI model from the sources listed above and checked by automated rules before it is published. Check versions against the vendor's advisory before you act. Methodology
