Git Shell Bypass By Abusing Less (CVE-2017-8386)
The git-shell restricted shell, used as the upstream peer for git over SSH, could be escaped by abusing the less pager. An attacker with SSH access to a git-shell account could break out of the restricted command set and run arbitrary commands.
insinuator.net
Published on insinuator.net
The git-shell is a restricted shell maintained by the git developers and is meant to be used as the upstream peer in a git remote session over a ssh tunnel. The basic idea behind this shell is to restrict the allowed commands in a ssh session to the ones required by git which are as follows:
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the built-in git commands invoked the less pager, whose interactive features allow spawning a shell, so the restricted shell did not actually confine the user.
Impact
An attacker with access to a git-shell account could escape the restricted command set and execute arbitrary commands, though the text does not detail the full exploit chain.
What the attacker needed
SSH access to a git-shell account
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 write-up has not been written yet. The Original tab links to the source.
A restricted shell is a login environment that only lets you run a small set of approved commands, here the few git commands needed for a remote session. The report shows that one of those commands can open a text viewer called less, and less has features that let you start other programs, so the restriction can be escaped. That means someone who can log in could run commands the administrator never intended.
What is RCE?
Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.