Page MenuHomePhabricator

Pass SSH wrappers to VCS commands unconditonally, not just if there's an SSH remote
ClosedPublic

Authored by epriestley on Aug 11 2017, 12:16 AM.
Tags
None
Referenced Files
F14052452: D18389.diff
Fri, Nov 15, 9:00 AM
F14037745: D18389.diff
Sun, Nov 10, 6:43 PM
F14028526: D18389.id.diff
Fri, Nov 8, 1:58 PM
F14024277: D18389.diff
Thu, Nov 7, 7:45 AM
F14014595: D18389.id.diff
Sun, Nov 3, 6:17 AM
F13974776: D18389.id44200.diff
Oct 18 2024, 7:22 AM
F13961466: D18389.id44200.diff
Oct 15 2024, 5:13 AM
Unknown Object (File)
Sep 20 2024, 11:28 PM
Subscribers

Details

Summary

Ref T12961. In Mercurial, it's possible to have "subrepos" which may use a different protocol than the main repository.

By putting an SSH repository inside an HTTP repository, an attacker can theoretically get us to execute hg without overriding ui.ssh, then execute code via the SSH hostname attack.

As an immediate mitigation to this attack, specify ui.ssh unconditionally. Normally, this will have no effect (it will just be ignored). In the specific case of an SSH repo inside an HTTP repo, it will defuse the ssh protocol.

For good measure and consistency, do the same for Subversion and Git. However, we don't normally maintain working copies for either Subversion or Git so it's unlikely that similar attacks exist there.

Test Plan
  • Put an SSH subrepo with an attack URI inside an HTTP outer repo in Mercurial.
  • Ran hg up with and without ui.ssh specified.
  • Got dangerous badness without ui.ssh and safe ssh subprocesses with ui.ssh.

I'm not yet able to confirm that hg pull -u -- <uri> can actually trigger this, but this can't hurt and our SSH wrapper is safer than the native behavior for all Subversion, Git and Mercurial versions released prior to today.

Diff Detail

Repository
rP Phabricator
Lint
Lint Not Applicable
Unit
Tests Not Applicable