Mercurial 7.2.6: a repo you do not trust can run code on your machine

6 min read

How to fix HG-SA-2026-001 to HG-SA-2026-004: upgrade Mercurial to 7.2.6. Four flaws let a crafted repository or bundle run code on machines that clone, pull or read patches from sources they do not trust.

On this page

Mercurial's maintainers shipped version 7.2.6 on December 3, 2026 and called it a critical security release. Their instruction is blunt: all users should upgrade immediately.

Four flaws in the tool can be combined. Together they let a crafted repository or bundle run code on a developer's machine during ordinary work, and run code on servers that accept pushes from people the server does not trust.

The trap is in the normality of the commands. Cloning a project, pulling updates, opening a bundle or reading a patch with hg log --patch can be enough. You don't need to open up some weird executable or some weird file.

Affected product and versions

Every Mercurial version is affected by two of the four flaws. The other two encompass most current releases (cache poisoning for 7.1 - 7.2.5 and symlink write for 2.6 - 7.2.5). The fixed release is 7.2.6. No CVE numbers exist yet; Mercurial tracks the four as HG-SA-2026-001 through HG-SA-2026-004 on its security page.

The four flaws

HG-SA-2026-001 can go the furthest. Changesets carrying .hg/ paths, or writing through symlinks, could be exported and passed around, which leads to configuration injection or writes outside the working copy. It affects every version and fires through hg archive, hg cat, hg export and other everyday commands. Taylor Campbell from the NetBSD project reported it.

HG-SA-2026-002 is a cache poisoning bug. It's about poisoning of an in-memory cache. A crafted bundle can make Mercurial use content in the same process that was never validated, for example during hg clone or hg pull -u. It covers 7.1 through 7.2.5. Pierre-Yves David from the Mercurial project discovered it.

HG-SA-2026-003 is a race condition in parallel updating. During a parallel update, the symlink checks can be beaten, and a malicious changeset writes through a symlink to a place it should not reach. It covers 2.6 through 7.2.5. Thomas Chauchefoin from Trail of Bits reported it.

For HG-SA-2026-004 you hardly have to ask anything of the target. Line breaks hidden in a subrepository URL in a .hgsub file inject configuration into repositories Mercurial creates in the background, and paths handed to hg clone and hg share can do the same. Running hg log --patch on a hostile repo is enough, with nothing checked out. It affects all versions (including Windows). Özgün Kültekin from WakeField reported it.

Who is not in scope

If you have a repository that you and your team trust completely, then you're not vulnerable. For each bug you need attacker-generated data in the form of a repository, or a bundle, or a clone bundle. Mercurial used only on your own projects, with no outside code pulled in, gives nobody that opening. Servers that take pushes only from their own team sit outside the server-side risk too.

One check to run now

First thing: run hg --version. Need to upgrade anything that's earlier than 7.2.6. After upgrading, one message does the second half of the check: if a command aborts with "path contains illegal component: .hg/...", the repository holds a malicious changeset that was accepted before the upgrade. Treat that repository as hostile and do not work around the abort.

What this is not

This is not a worm, and nothing spreads on its own. An attacker has to get a crafted repository or bundle in front of a Mercurial user first. Mercurial reports no exploitation in the wild, and none of the four flaws sits in CISA's known exploited list. The release was coordinated: packagers and hosting providers held the fixes before the announcement, which is why patched packages landed the same day.

How to fix

Upgrade to Mercurial 7.2.6, or install the patched package from your distribution.

Mercurial won't schedule new upstream releases for older series. Distributions can get backported patches on request, so a distribution package carrying the fixes is a valid endpoint too. The upgrade should be painless: Mercurial has rarely broken backwards compatibility.

If you have a server on, and you have web.archivesubrepos enabled, disable it. Leave it off after the upgrade as well. Mercurial says it stays off until a future security release of much narrower reach.

If you cannot upgrade today, three habits cut the exposure. Use hg import to apply patches from untrusted changesets, don't use the patch tool. Do not run hg inside archives of untrusted repositories made before 7.2.6, because upgrading does not repair an archive already on disk. The 7.2.6 release notes list the configuration settings that reduce exposure for each flaw.

HOL's assessment

Every other tool your team uses runs on top of version control. A flaw that fires during a clone or a patch read reaches the machine holding signing keys, deployment credentials and the code itself. Mercurial's maintainers ran this release the right way: coordinated disclosure, fixes waiting in distribution packages on day one, and a plain instruction that every user should upgrade. The upgrade is small and the trigger is an everyday command, so this belongs at the top of today's list.

Where to download Guard

HOL Guard is open source and free. You can use Guard Desktop on macOS 13+ (Apple silicon), Windows x64 and Linux x86_64. No terminal required. There is a one command terminal installation on the same install page. After installing, hol-guard doctor will tell you that daemon is started and the intercept layer is up and working.

Sources

Mercurial, Mercurial 7.2.6 released: https://mercurial-scm.org/news/2026/0009-release-7.2.6

Mercurial, security advisories: https://www.mercurial-scm.org/security

Raphaël Gomès, Mercurial 7.2.6 critical security release (oss-sec): https://seclists.org/oss-sec/2026/q4/999

We can't upgrade this week. What's lowering the risk today?

Treat every repository and bundle from outside your team as hostile until you upgrade. Apply patches from untrusted changesets with hg import rather than patch, do not run hg inside archives of untrusted repositories made before 7.2.6, and turn web.archivesubrepos off on any server that has it on. Go check the 7.2.6 release notes for specific settings for each of the flaws that further reduce the exposure.

How do we know if a hostile changeset already reached us?

Upgrade first. Then go on working. On 7.2.6, a command that aborts with "path contains illegal component: .hg/..." is Mercurial refusing a changeset carrying a .hg/ path, which means that repository accepted a malicious changeset before the upgrade. Quarantine that repo and grab a clean copy from a trusted source.

Mercurial 7.2.6 questions

Reviewed . 2 questions.

We can't upgrade this week. What's lowering the risk today?

Treat every repository and bundle from outside your team as hostile until you upgrade. Apply patches from untrusted changesets with hg import rather than patch, do not run hg inside archives of untrusted repositories made before 7.2.6, and turn web.archivesubrepos off on any server that has it on. Go check the 7.2.6 release notes for specific settings for each of the flaws that further reduce the exposure.

How do we know if a hostile changeset already reached us?

Upgrade first. Then go on working. On 7.2.6, a command that aborts with "path contains illegal component: .hg/..." is Mercurial refusing a changeset carrying a .hg/ path, which means that repository accepted a malicious changeset before the upgrade. Quarantine that repo and grab a clean copy from a trusted source.

Sources

  1. Mercurial, Mercurial 7.2.6 released — 2026-12-03
  2. Mercurial, security advisories (HG-SA-2026-001 to 004) — 2026-12-03
  3. Raphaël Gomès, Mercurial 7.2.6 critical security release (oss-sec) — 2026-12-03
All articles

Keep exploring

The engineering desk continues across the ecosystem: security research on shipping agents safely, and plugins that put the standards to work.