Skip to content
RCE Advisory Intermediate CVE-2020-26301

GHSL-2020-123: Command injection in mscdex/ssh2 - CVE-2020-26301

The ssh2 library's agent method on Windows constructs a shell command from its input without proper escaping, allowing command injection. An attacker who controls the input could execute arbitrary commands on the host.

kevinbackhouse Follow

Originally disclosed on GitHub Security Lab

The agent method has a command injection vulnerability on Windows. Clients of the mscdex/ssh2 library are unlikely to be aware of this, so they might unwittingly write code that contains a vulnerability.

kevinbackhouse, on GitHub Security Lab

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 report has not been written yet. The Original tab links to the source.

How it worked

Impact

This issue may lead to remote code execution if a client of the library calls the vulnerable method with untrusted input.

What the attacker needed

Windows operating system; application passes untrusted input to agent method

The fix

The bug was fixed in a later commit, as confirmed by the maintainer.

How it was found

  1. Install the ssh2 library.
  2. Create a script that calls the agent method with a crafted string.
  3. Run the script and observe that a file named exploit is created.

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.

When a program builds a command for the operating system by gluing together text, special characters in that text can break out of the intended command and run something else. Here, the ssh2 library did this on Windows, so if a program passed user-controlled text to its agent function, an attacker could run their own commands.

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 kevinbackhouse

View all

47 more disclosed reports, best first.

More from GitHub Security Lab

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.