Skip to content
RCE Disclosed report Intermediate CVE-2017-17458

Mercurial git subrepo lead to arbritary command injection

A specially crafted Mercurial repository could contain a Git subrepository with a checked-in post-update hook script, which would then run arbitrary code when the repository was used. An attacker could therefore execute commands on the operating system of a user who cloned or processed such a repository.

criticalonly Follow

Originally disclosed on HackerOne

Critical View original
  • Triaged in 4 months
  • Fixed in 11 days
  • Paid in 21 months
  • Disclosed after 22 months

Hi IBB,

I'd like to submit a issue exist in Mercurial.

It is possible that a specially malformed repository can cause Git subrepositories to run arbitrary code in 
the form of a .git/hooks/post-update script checked in to the repository in Mercurial 4.4 and earlier. 
Typical use of Mercurial prevents construction of such repositories, but they can be created 
programmatically.

Further details of my original report can be found at: https://bz.mercurial-scm.org/show_bug.cgi?id=5730

And the Mercurial security advisory https://www.mercurial-scm.org/wiki/WhatsNew#Mercurial_4.4.1_.282017-11-07.29

Thanks, Terry

Impact

A crafted mercurial repo with an evil git subrepo can lead to execute arbritary command on user's OS. And other web applications or clients support mercurial repo management or invoke hg related command also have a risk affected by this vulnerability.

The original report as published on HackerOne, by criticalonly. Images and videos are our own copies; raw HTML is shown as text. View it on HackerOne.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

How it worked

Root cause

Likely Mercurial did not prevent a Git subrepository from carrying an executable post-update hook script, so the hook ran when the subrepository was updated.

Impact

A crafted repository could lead to arbitrary command execution on the user's OS, and other applications or clients that manage Mercurial repositories or invoke hg commands may also be at risk.

What the attacker needed

Victim uses a crafted Mercurial repo; repo contains a Git subrepository; subrepo includes a post-update hook

The fix

A Mercurial 4.4.1 security advisory is referenced; the text does not describe the fix itself.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

Mercurial is a version control tool, like Git, that tracks changes to files. It can include other repositories inside it, called subrepositories, and Git has hook scripts that run automatically at certain moments. If a repository ships a hook script that runs on update, then simply working with that repository can run the attacker's commands on your computer.

What is RCE?

Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.

More by criticalonly

View all

1 more disclosed report, best first.

More from Internet Bug Bounty

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Remote code execution

The lesson behind this report.

Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.