Add 3 critical security vulnerabilities for training purposes - #11
Add 3 critical security vulnerabilities for training purposes#11sust4in wants to merge 1 commit into
Conversation
sust4in
commented
May 29, 2026
- RCE via OS command injection in /accounts/:username/export
- NoSQL injection with password exposure in /accounts/search
- Path traversal via unsanitized filename in /files/:filename
- RCE via OS command injection in /accounts/:username/export - NoSQL injection with password exposure in /accounts/search - Path traversal via unsanitized filename in /files/:filename Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
❌ 2 possible security or compliance issues detected. Reviewed everything up to 1e0e44d. The following issues were found:
Security Overview
Detected Code Changes
|
| exec(`echo Exporting notes for ${req.params.username} in ${format} format`, (error, stdout, stderr) => { | ||
| if (error) { | ||
| return res.status(500).json({ error: stderr }); | ||
| } | ||
| res.status(200).json({ output: stdout }); |
There was a problem hiding this comment.
OS Command Injection in Account Export Endpoint (Severity: HIGH)
Remote Code Execution is possible because user-supplied input from the 'format' query parameter and 'username' path parameter is passed directly to the exec function without sanitization. This allows an attacker to inject arbitrary OS commands, leading to potential compromise of the server.
View details in ZeroPath
Suggested fix
Unable to apply as inline suggestion. Download .diff and apply from repo root with git apply ed00d5d9.diff
diff --git a/packages/services/api/src/routes/accounts.js b/packages/services/api/src/routes/accounts.js
--- a/packages/services/api/src/routes/accounts.js
+++ b/packages/services/api/src/routes/accounts.js
@@ -31,7 +31,7 @@
// User-supplied input is passed directly to exec() without sanitization
router.get('/accounts/:username/export', auth, async (req, res, next) => {
const format = req.query.format || 'json';
- exec(`echo Exporting notes for ${req.params.username} in ${format} format`, (error, stdout, stderr) => {
+ exec('echo Exporting notes for ' + JSON.stringify(req.params.username) + ' in ' + JSON.stringify(format) + ' format', (error, stdout, stderr) => {
if (error) {
return res.status(500).json({ error: stderr });
}
| { email: query }, | ||
| { password: 1, email: 1, name: 1 } | ||
| ).exec(); | ||
|
|
||
| res.status(200).json(accounts); |
There was a problem hiding this comment.
Sensitive Credential Exposure in Account Search Results (Severity: HIGH)
Passwords are exposed in API responses, which can lead to unauthorized account access if intercepted. The Account.find function in accounts.js inadvertently includes the 'password' field in search results, causing sensitive credential exposure.
View details in ZeroPath
| { email: query }, | |
| { password: 1, email: 1, name: 1 } | |
| ).exec(); | |
| res.status(200).json(accounts); | |
| { email: query }, | |
| { password: 0, email: 1, name: 1 } | |
| ).exec(); | |
| res.status(200).json(accounts); |