Disclosed vulnerabilities
Fixed: May 29, 2021
No CVE assigned Published: Sep 1, 2021

Command injection vulnerability in ssh2

9.8 Critical Severity javascript node nodejs npm RCE
Mario Teixeira Reported by Checkmarx Zero

Summary

Affected versions of the NPM package ssh2 allow command injection through the unsafe execution of user-controlled parameters.

Product

This vulnerability affects versions of ssh2 prior to 1.0.0.

Impact

This issue may lead to remote code execution if malicious input is passed to the agent parameter.

Steps to reproduce

  1. An SSH server must be running.
  2. Create the file poc.js:
    require('ssh2')().connect({
     'agent': "/"& echo vulnerable > result"",
     'username': "checkmarx",
     'tryKeyboard': true
    })
  3. Run node poc.js

Expected result:

A file named result will be created with “vulnerable” written inside.

Remediation

  1. Update to version 1.0.0 or above.
  2. As a workaround, make sure untrusted input can’t be passed to the vulnerable parameters when using the library.

Credit

This issue was discovered and reported by Checkmarx SCA Security Analysts André Sá and Mário Teixeira.

Resources

  1. Vulnerable code
  2. Issue
  3. f76327

Stay connected and never miss a research update!