Mercurial 7.2.6 released#
Critical security release of Mercurial: all users should upgrade immediately.
As announced earlier this week, this release fixes several high impact vulnerabilities that can be combined with each other. Together, they allow arbitrary code execution on clients and remote code execution on servers.
Who is exposed#
Most issues need data crafted by an attacker: a repository, a bundle or a clone bundle.
You are exposed if you clone, pull, unbundle or apply patches from a source you do not
fully trust, or if you run commands like hg archive, hg cat or hg diff on revisions
coming from such a source.
Servers that untrusted people can push to are exposed too: some server-side validation could be bypassed, and seemingly harmless read-only operations could execute arbitrary code. Unpatched servers can also relay malicious data to their users.
The vulnerabilities#
HG-SA-2026-001, arbitrary code execution via
hg archiveand others (all versions): changesets containing.hg/paths or writing through symlinks could be exported and exchanged, leading to configuration injection or writes outside of the working copy. Reported by Taylor Campbell from the NetBSD project.HG-SA-2026-002, integrity check bypass through cache poisoning (7.1 to 7.2.5): a crafted bundle could make Mercurial use non-validated content in the same process, for example during
hg cloneorhg pull -u. Found by Pierre-Yves David, from the Mercurial project.HG-SA-2026-003, writing through a symlink during a parallel update (2.6 to 7.2.5): a race in the symlink auditing of parallel workers could be reliably exploited by a malicious changeset. Reported by Thomas Chauchefoin from Trail of Bits.
HG-SA-2026-004, configuration injection through a malformed
.hgsub(all versions, Windows included): line breaks in subrepository URLs could inject configuration into repositories created in the background, from operations as simple ashg log --patch, without checking anything out. Reported by Özgün Kültekin from WakeField.
What to do#
Upgrade to Mercurial 7.2.6, or to the patched package of your distribution. No new upstream releases are planned for older series, but we are providing backported patches to distributions on request.
Warning
If you have enabled web.archivesubrepos on a server, turn it off, even after upgrading
to 7.2.6. It should stay off until a future security release, of much narrower reach and
lesser impact than this one.
If you cannot upgrade right away, the release notes list, for each issue, the configuration and practices that reduce your exposure in the meantime, as well as what remains true after upgrading. In particular:
archives made by earlier versions are not fixed by upgrading: do not run
hginside archives of untrusted repositories made before 7.2.6;apply patches from untrusted changesets with
hg import, not withpatch;if a command now aborts with
path contains illegal component: .hg/..., the repository holds a malicious changeset that was accepted before the upgrade.
See the release notes for the full details, and our security page for the list of advisories.
Thanks#
We thank the reporters for their work and for their patience during the coordinated disclosure.
We also thank Arthur from Gentils Nuages for providing additional CI resources to test this release, as well as the downstream packagers and the hosting providers who prepared their updates ahead of time so that fixes reach users as quickly as possible.