CVE-2019-10776

9.8 CRITICAL

📋 TL;DR

This vulnerability allows remote command injection in git-diff-apply npm package. An attacker can execute arbitrary commands on the system by controlling the remoteUrl parameter. All users of git-diff-apply versions prior to 0.22.2 are affected.

💻 Affected Systems

Products:
  • git-diff-apply
Versions: All versions prior to 0.22.2
Operating Systems: All platforms where Node.js runs
Default Config Vulnerable: ⚠️ Yes
Notes: Vulnerability exists in the default configuration when processing user-controlled remote URLs.

📦 What is this software?

⚠️ Risk & Real-World Impact

🔴

Worst Case

Full system compromise with arbitrary command execution as the user running the application, potentially leading to data theft, ransomware deployment, or complete system takeover.

🟠

Likely Case

Remote code execution allowing attackers to run commands, access sensitive data, or pivot to other systems in the network.

🟢

If Mitigated

No impact if proper input validation and sanitization are implemented, or if the vulnerable version is not used.

🌐 Internet-Facing: HIGH - If the application processes user-controlled git URLs from external sources, it's directly exploitable from the internet.
🏢 Internal Only: MEDIUM - Internal applications using this library with user-controlled input remain vulnerable to insider threats or compromised internal systems.

🎯 Exploit Status

Public PoC: ⚠️ Yes
Weaponized: LIKELY
Unauthenticated Exploit: ⚠️ Yes
Complexity: LOW

Exploitation is straightforward - attackers can inject shell commands through the remoteUrl parameter. Multiple security advisories and proof-of-concepts are publicly available.

🛠️ Fix & Mitigation

✅ Official Fix

Patch Version: 0.22.2

Vendor Advisory: https://github.com/kellyselden/git-diff-apply/commit/106d61d3ae723b4257c2a13e67b95eb40a27e0b5

Restart Required: No

Instructions:

1. Update package.json to require git-diff-apply version 0.22.2 or higher. 2. Run 'npm update git-diff-apply'. 3. Verify the update with 'npm list git-diff-apply'.

🔧 Temporary Workarounds

Input Validation and Sanitization

all

Implement strict validation of remoteUrl parameter to prevent command injection

// JavaScript example: Validate URL format before passing to git-diff-apply
const urlRegex = /^[a-zA-Z0-9.:\/\-_]+$/;
if (!urlRegex.test(remoteUrl)) { throw new Error('Invalid URL format'); }

Environment Restriction

linux

Run the application with minimal privileges and in isolated environments

# Run as non-root user
sudo -u appuser node app.js
# Use container isolation
docker run --read-only --cap-drop=ALL node:alpine

🧯 If You Can't Patch

  • Implement strict input validation on all user-controlled parameters passed to git-diff-apply
  • Isolate the application in a container or VM with restricted network access and minimal privileges

🔍 How to Verify

Check if Vulnerable:

Check package.json or run 'npm list git-diff-apply' to see if version is below 0.22.2

Check Version:

npm list git-diff-apply | grep git-diff-apply

Verify Fix Applied:

Confirm git-diff-apply version is 0.22.2 or higher with 'npm list git-diff-apply'

📡 Detection & Monitoring

Log Indicators:

  • Unusual git commands in application logs
  • Suspicious shell commands following git operations
  • Failed git operations with malformed URLs

Network Indicators:

  • Unexpected outbound connections from the application
  • DNS requests for suspicious domains following git operations

SIEM Query:

process.name:"node" AND cmdline:"git-diff-apply" AND (cmdline:*"|"* OR cmdline:*";"* OR cmdline:*"&"*)

🔗 References

📤 Share & Export