CVE-2021-23359

7.5 HIGH

📋 TL;DR

CVE-2021-23359 is a command injection vulnerability in the port-killer npm package that allows attackers to execute arbitrary commands on the system. This affects all versions of port-killer where user input is passed to the vulnerable function. Any application using this package with untrusted input is vulnerable to remote code execution.

💻 Affected Systems

Products:
  • port-killer npm package
Versions: All versions
Operating Systems: All operating systems where Node.js runs
Default Config Vulnerable: ⚠️ Yes
Notes: Only vulnerable when user-controlled input is passed to the vulnerable function. The package itself is vulnerable by design.

📦 What is this software?

⚠️ Manual Verification Required

This CVE does not have specific version information in our database, so automatic vulnerability detection cannot determine if your system is affected.

Why? The CVE database entry doesn't specify which versions are vulnerable (no version ranges provided by the vendor/NVD).

🔒 Custom verification scripts are available for registered users. Sign up free to download automated test scripts.

Recommended Actions:
  1. Review the CVE details at NVD
  2. Check vendor security advisories for your specific version
  3. Test if the vulnerability is exploitable in your environment
  4. Consider updating to the latest version as a precaution

⚠️ Risk & Real-World Impact

🔴

Worst Case

Full system compromise allowing attacker to execute any command with the privileges of the running process, potentially leading to data theft, ransomware deployment, or complete system takeover.

🟠

Likely Case

Arbitrary command execution leading to file creation/modification, data exfiltration, or installation of backdoors/malware.

🟢

If Mitigated

No impact if input validation/sanitization is implemented or if the package is not used with untrusted input.

🌐 Internet-Facing: HIGH - Web applications using this package with user input are directly exposed to exploitation.
🏢 Internal Only: MEDIUM - Internal systems using this package could be exploited by authenticated users or through other attack vectors.

🎯 Exploit Status

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

Proof of concept demonstrates command injection via user input. Exploitation is straightforward with minimal technical barriers.

🛠️ Fix & Mitigation

✅ Official Fix

Patch Version: N/A

Vendor Advisory: https://github.com/tylerjpeterson/port-killer/security/advisories

Restart Required: No

Instructions:

1. Remove port-killer package from your project. 2. Use alternative packages like kill-port or implement port killing functionality securely. 3. Update package.json and run npm install.

🔧 Temporary Workarounds

Input Validation and Sanitization

all

Implement strict input validation to ensure only expected values are passed to port-killer functions

// Example: Validate input is numeric only
const port = req.body.port;
if (!/^\d+$/.test(port)) {
    throw new Error('Invalid port number');
}

Replace with Safe Alternative

all

Replace port-killer with a secure alternative package that doesn't use exec() with user input

npm uninstall port-killer
npm install kill-port

🧯 If You Can't Patch

  • Implement strict input validation and sanitization for all user inputs passed to port-killer
  • Run the application with minimal privileges and in a sandboxed/containerized environment

🔍 How to Verify

Check if Vulnerable:

Check package.json or package-lock.json for port-killer dependency. Run: npm list port-killer

Check Version:

npm list port-killer

Verify Fix Applied:

Verify port-killer is no longer in package.json and npm list shows no port-killer installation

📡 Detection & Monitoring

Log Indicators:

  • Unusual process execution from Node.js applications
  • File creation/modification by Node.js processes
  • Error logs showing command execution failures

Network Indicators:

  • Unexpected outbound connections from Node.js applications
  • Command and control traffic patterns

SIEM Query:

process.name:"node" AND (process.cmdline:*exec* OR process.cmdline:*child_process*)

🔗 References

📤 Share & Export