Mercurial 7.2.6 fixes four chained Mercurial vulnerabilities that allow code execution on clients and servers. The project calls it a “critical security release” and says “all users should upgrade immediately.” Two of the flaws affect every version of the version control system.
Technical Analysis
Attack Vector and Prerequisites
Attackers do not need credentials, but they need a victim to touch their data. According to the Mercurial 7.2.6 release announcement, “Most issues need data crafted by an attacker: a repository, a bundle or a clone bundle.” Cloning, pulling or unbundling from an untrusted source is enough. Even commands like hg archive, hg cat or hg diff can expose users.
Servers face risk too. Anyone who can push to a server may bypass validation. The project warns that “seemingly harmless read-only operations could execute arbitrary code.”
The Four Flaws
- HG-SA-2026-001 (all versions): Changesets with .hg/ paths or symlink writes allow configuration injection or writes outside the working copy.
- HG-SA-2026-002 (7.1 to 7.2.5): A crafted bundle poisons a cache, so Mercurial uses unvalidated content.
- HG-SA-2026-003 (2.6 to 7.2.5): A race in symlink checks during parallel updates lets a malicious changeset write through a symlink.
- HG-SA-2026-004 (all versions, including Windows): Line breaks in .hgsub URLs inject configuration, even through hg log –patch.
Affected Products, Impact, and Exploitation Status
Every Mercurial release before 7.2.6 carries at least two of these Mercurial vulnerabilities. Together, they enable client-side code execution and server-side remote code execution. Unpatched servers can also “relay malicious data to their users.”
No exploitation in the wild has been reported. The project has published no CVE IDs, and Debian tracks the flaws under temporary IDs.
Who Found the Bugs
Taylor Campbell (NetBSD), Pierre-Yves David (Mercurial), Thomas Chauchefoin (Trail of Bits) and Ozgun Kultekin (WakeField) reported the issues.
Remediation and Mitigation
Official Patches
Upgrade to Mercurial 7.2.6 or your distribution’s patched package. Older series get no new releases, but distributions can request backports. Debian has already fixed its trixie package.
Workarounds and Cleanup
- Turn off web.archivesubrepos on servers, even after upgrading.
- Do not run hg inside archives of untrusted repositories made before 7.2.6.
- Apply untrusted patches with hg import, not patch.
Detection
After upgrading, watch for the error “path contains illegal component: .hg/”. It means a repository already holds a malicious changeset. Finally, review any repository that triggers it, since these Mercurial vulnerabilities let bad changesets slip in before the fix.
Support Our Threat Intelligence
Find our vulnerability reports and weekly recaps helpful? Support our work today and unlock a 100% ad-free reading experience!