Skip to content
Security

How to Clone Untrusted Git Repositories Safely After CVE-2026-111760

Git’s latest clone-time flaw shows why untrusted repositories need care. Here’s how to update Git, clone safely, sandbox unknown code and keep AI coding agents in check.

Topic
Security
Reading time
5 min
Length
2,008 words
Published
Nov 11, 2026
12:11 pm IST
In this article
  1. What exactly went wrong in Git this time?
  2. Step 1: Check and update your Git version
  3. Step 2: Stop cloning untrusted repositories recursively
  4. Step 3: Look before you fetch submodules
  5. Step 4: Turn on Git's safety checks
  6. Step 5: Open unknown code in a disposable container
  7. Step 6: Don't run a project's scripts before you read them
  8. Step 7: What if an AI coding agent is doing the cloning?
  9. Step 8: Protect the credentials that make clones dangerous
  10. Step 9: Make your CI safe for pull requests
  11. What if you already cloned something suspicious?
  12. A simple checklist you can follow today
  13. Why these habits matter more than any single patch

Cloning a Git repository feels like downloading files. It isn't always. Git just fixed CVE-2026-111760, a flaw that lets a malicious repository run code on your machine during a recursive clone. This post is a practical guide to cloning and reviewing untrusted code safely, including when an AI coding agent does the cloning for you.

I recently wrote a longer analysis on ByteMuni about why cyberattacks keep happening and the 8 root causes behind 2026's biggest CVEs, using this Git bug as the starting point. That piece explains the "why". This one is the "how": the habits and commands that keep a developer's machine safe when code comes from people you don't know.

What exactly went wrong in Git this time?

The short version: a very long path in a malicious repository could pass Git's safety check, but Git then wrote it to disk under a shorter name the attacker controlled, which could be .git. That let the attacker swap a submodule's .git file for a symbolic link pointing at a folder with malicious hooks or configuration. Hooks are scripts Git runs automatically, so the attacker's code ran during the clone.

The fix is in Git 2.56.1, with backports in 2.55.1, 2.54.1, 2.53.1, 2.52.1, 2.51.3 and 2.50.2, and in Git for Windows 2.56.1. GitHub.com was patched before the announcement. GitHub Enterprise Server has fixed releases too.

What makes this worth a whole post is that it's not new. It's the third recursive-clone code execution bug in Git in roughly two and a half years:

  • CVE-2024-32002 (May 2024): submodules plus symlinks could write into .git during clone.
  • CVE-2025-48384 (2025): a carriage-return handling bug in config files led to the same result, and CISA later listed it as exploited in the wild.
  • CVE-2026-111760 (November 2026): integer truncation, same outcome.

When the same outcome keeps returning through different bugs, the lesson isn't "patch this one". It's "change how you treat untrusted repositories".

Step 1: Check and update your Git version

Start with the obvious, on every machine you use: laptop, servers, CI runners and containers.

git --version

You want 2.56.1 or the fixed release in your series. Some places people forget:

  • Linux distributions often backport the fix without changing to 2.56.1, so check your distro's security tracker rather than only comparing numbers.
  • macOS: Apple's Command Line Tools ship their own Git. If you use Homebrew Git, run brew upgrade git and check which git to see which one you're actually running.
  • Windows: install Git for Windows 2.56.1. Desktop apps and IDEs can bundle their own Git, so update those too.
  • Docker images and CI runners: rebuild them. A container image built last month still has last month's Git.

Step 2: Stop cloning untrusted repositories recursively

The dangerous path is the recursive clone, the one that also fetches submodules. Make it a deliberate choice, never a habit:

# Safer default: clone without submodules
git clone https://example.com/some/repo.git

# Avoid this for repositories you don't trust
# git clone --recurse-submodules https://example.com/some/repo.git

A plain git clone doesn't fetch submodules unless you ask for them. Also make sure you haven't turned recursion on globally at some point:

git config --global --get submodule.recurse
# If this prints "true", consider turning it off:
git config --global submodule.recurse false

Step 3: Look before you fetch submodules

If you do need the submodules, inspect them first. They're listed in .gitmodules:

# See which submodules exist and where they come from
git config -f .gitmodules --get-regexp 'submodule\..*\.(path|url)'

# Look for symbolic links in the repository
find . -type l -not -path './.git/*'

Things that should make you stop:

  • submodule URLs pointing to unknown hosts or to local paths;
  • very long or odd-looking paths;
  • symbolic links pointing into .git or outside the project.

If everything looks fine and you trust the sources, fetch submodules explicitly with git submodule update --init. If not, don't.

Step 4: Turn on Git's safety checks

Git has settings that make it stricter about what it accepts. They won't stop every bug, but they're cheap insurance:

# Verify objects when fetching and receiving
git config --global transfer.fsckObjects true
git config --global fetch.fsckObjects true

# Only allow the local "file" protocol when you run a command directly,
# not when a submodule asks for it (this is Git's default since 2.38.1)
git config --global protocol.file.allow user

You may see advice to disable hooks globally by pointing core.hooksPath at an empty folder. That can help against some tricks, but a malicious repository's own configuration may override it, and it can break legitimate tools you rely on. Treat it as a small extra layer, not a fix. Updating Git is the fix.

Step 5: Open unknown code in a disposable container

The most reliable habit is simple: don't open untrusted code directly on your main machine. Use a throwaway container with no access to your files or credentials.

# Clone inside a temporary container with no network after the clone
mkdir -p ~/untrusted && cd ~/untrusted
docker run --rm -it -v "$PWD":/work -w /work alpine/git \
  clone https://example.com/some/repo.git

# Review it in a separate container with networking turned off
docker run --rm -it --network none -v "$PWD":/work -w /work alpine sh

Key points:

  • Mount only one empty folder, never your home directory, SSH keys or cloud credentials.
  • Use --network none while reviewing, so nothing can phone home.
  • Throw the container away when you're done.

GitHub Codespaces, Dev Containers and a simple VM do the same job. The idea is that if something malicious runs, it runs somewhere that doesn't matter.

Step 6: Don't run a project's scripts before you read them

Git is only the first door. The next one is the project's own tooling. Many projects run code automatically during install or build:

  • npm install runs preinstall and postinstall scripts from package.json. Use npm install --ignore-scripts when reviewing something unknown.
  • Python packages can run code at install time, and .pth files run every time Python starts, as the LiteLLM 1.107.0 incident showed.
  • Build files such as Makefile, vite.config.js and Gradle scripts are code. Read them before running them.
  • Editors can trust a folder and run its tasks or extensions. Use your editor's restricted or untrusted mode for unknown projects.

Attackers have hidden loaders in places like vite.config.js behind long runs of whitespace, so a quick glance isn't always enough. Scroll horizontally, or use a diff tool that highlights whitespace.

Step 7: What if an AI coding agent is doing the cloning?

This is the part most people haven't thought about yet. AI coding agents increasingly clone repositories, install packages and run commands on your behalf. That means the agent's environment is now exposed to everything above.

Some practical rules:

  • Make sure the Git your agent uses is updated, especially inside its container or sandbox, not just on your laptop.
  • Don't let agents auto-approve recursive clones, package installs or shell commands for repositories you haven't reviewed.
  • Give agents a sandbox, not your real home directory, SSH keys or cloud credentials.
  • Watch instruction files. Researchers reported a malicious AGENTS.md file that tricked an AI coding agent into installing a rogue npm package. Files that agents are built to obey are now part of your attack surface.
  • Use short-lived, minimal tokens for anything an agent can access, so a mistake doesn't expose everything.

Step 8: Protect the credentials that make clones dangerous

Code running on your machine is bad. Code running on your machine with your tokens available is how small incidents become supply-chain attacks. In 2026 we've seen stolen GitHub tokens used to dump CI secrets (the Gheist campaign) and stolen GitHub CLI tokens used to publish a malicious LiteLLM release.

  • Find old tokens. Review your GitHub personal access tokens and delete ones you don't use.
  • Prefer fine-grained, expiring tokens limited to specific repositories, or GitHub Apps for automation.
  • Use OIDC in CI so pipelines get short-lived cloud credentials instead of stored secrets.
  • Keep secrets out of plain-text files like .env in your home folder. Use a credential manager where you can.
  • Check your laptop for infostealers if you ever installed cracked software or unknown browser extensions. Many stolen tokens start there.

Step 9: Make your CI safe for pull requests

Your CI system clones code from other people every day. A few settings make a big difference:

  • Update Git in your runner images, especially self-hosted runners.
  • Don't fetch submodules for pull requests from forks unless you need to.
  • Keep secrets away from untrusted pull requests. Put production secrets in deployment environments that need a reviewer's approval.
  • Use ephemeral runners that are destroyed after each job, so nothing persists between builds.
  • Give the built-in CI token minimal permissions, such as read-only by default.

GitHub now holds potentially suspicious workflow runs in public repositories until a collaborator approves them, which helps, but it doesn't cover private repositories or every case.

What if you already cloned something suspicious?

If you recently ran a recursive clone of a repository you don't fully trust, on an old Git version, don't panic, but do check. Most repositories are harmless. The goal is to rule out the rare bad one.

Quick checks on the affected machine:

  • Look inside the clone for symbolic links pointing into .git or outside the project: find . -type l -exec ls -l {} \;.
  • Check for unexpected hooks in the repository and its submodules: find . -path '*/hooks/*' -type f -not -name '*.sample'. Real hooks you didn't add are a red flag.
  • Review recent changes to your shell startup files (~/.bashrc, ~/.zshrc, ~/.profile), scheduled tasks (crontab -l) and SSH keys (~/.ssh/authorized_keys). These are common places for malware to persist.
  • Look at running processes and network connections for anything you don't recognise, for example with ps aux and ss -tunp on Linux.

If anything looks wrong:

  1. Disconnect the machine from the network.
  2. From a different, clean device, revoke and replace credentials the machine could reach: GitHub tokens, SSH keys, cloud keys, npm and PyPI tokens, and API keys in .env files.
  3. Check your GitHub account's security log and your cloud providers' audit logs for activity you didn't do.
  4. Tell your team or security contact if it's a work machine. Fast reporting matters more than being certain.
  5. Rebuild the machine from a clean state if you confirm compromise. Cleaning up by hand often misses something.

Rotating credentials feels like overkill until you realise how many incidents this year started with a single token taken from one developer's laptop.

A simple checklist you can follow today

  1. Run git --version everywhere and update to 2.56.1 or your series' fixed release.
  2. Rebuild Docker images and CI runner images.
  3. Make sure submodule.recurse isn't set to true globally.
  4. Turn on transfer.fsckObjects and fetch.fsckObjects.
  5. Review .gitmodules and symlinks before fetching submodules from unknown sources.
  6. Open unknown projects in a disposable container or VM, with no network and no credentials.
  7. Install dependencies with scripts disabled until you've reviewed them.
  8. Put AI coding agents in a sandbox and don't auto-approve their commands on unknown code.
  9. Replace long-lived tokens with fine-grained, expiring ones or OIDC.
  10. Keep production secrets behind reviewer approval in CI.

Why these habits matter more than any single patch

Every one of these steps maps to a deeper problem: software trusting input it shouldn't, memory-unsafe code in core tools, convenient defaults, and credentials that are too powerful and live too long. Git will fix this bug. The next one will look different but behave the same way. Good habits protect you from both.

If you want the bigger picture (how this Git flaw connects to PHP2Shell, HTTP2Shell, Gheist, LiteLLM, Tailworm and the Magento malware campaign, and how GitHub and the wider industry are changing in response), read the full analysis on ByteMuni: Why cyberattacks keep happening: the 8 root causes behind 2026's biggest CVEs.

None of these habits takes long. Updating Git is a one-minute job, checking .gitmodules takes seconds, and a disposable container becomes second nature after a week. Compared with rotating every credential after a compromise, that's a very good trade.

Update Git, clone carefully, and treat every unknown repository as untrusted input, because that's exactly what it is.

Sources

https://bytemuni.com/cyber-security/root-causes-of-cyberattacks-git-cve-2026-111760/?utm_source=officialdeepak&utm_medium=referral&utm_campaign=root_causes_nov2026

This is the source this article is based on. Many articles on this blog are drafted with AI and checked against their source automatically; the editorial policy explains how, and how to report a mistake.

Deepak Kumar

Written by

Deepak Kumar

Sr Software Engineer at India Today Group | Aaj Tak · MERN Stack · Generative AI

I have shipped the boring security work — auth flows, token handling, dependency upgrades after a CVE lands on a Friday. I write here about what those systems actually do once real traffic hits them. Hiring a software developer in India? Here is how I work.

Weekly newsletter

Liked this? Get the next one by email

One short email a week with new articles on React, Node.js, TypeScript and AI engineering. No spam. Unsubscribe in one click.

By subscribing you agree to the privacy policy · About the newsletter.

Further reading

Related tutorials from ByteMuni, my developer publication.

Message me