-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Vulnerable 2 #3
base: main
Are you sure you want to change the base?
Vulnerable 2 #3
Conversation
|
||
db.get(query, [], (err, row) => { | ||
if (err) { | ||
return res.status(500).send(`{"error": "${err.stack}"}`); |
Check warning
Code scanning / CodeQL
Exception text reinterpreted as HTML Medium
Exception text
Exception text
app.get('/login', (req, res) => { | ||
const { email, password } = req.query; | ||
|
||
if (!email || !password) { | ||
return res.status(400).send('Email and password are required'); | ||
} | ||
const query = `SELECT * FROM users WHERE email = '${email}' and password = '${password}'`; | ||
|
||
db.get(query, [], (err, row) => { | ||
if (err) { | ||
return res.status(500).send(`{"error": "${err.stack}"}`); | ||
} | ||
return res.send('Login successful'); | ||
}); | ||
}); |
Check failure
Code scanning / CodeQL
Missing rate limiting High
a database access
|
||
// Login endpoint (Unsafe) | ||
app.get('/login', (req, res) => { | ||
const { email, password } = req.query; |
Check warning
Code scanning / CodeQL
Sensitive data read from GET request Medium
Route handler
} | ||
const query = `SELECT * FROM users WHERE email = '${email}' and password = '${password}'`; | ||
|
||
db.get(query, [], (err, row) => { |
Check failure
Code scanning / CodeQL
Database query built from user-controlled sources High
user-provided value
This query string depends on a
user-provided value
const attachmentPath = path.join(__dirname, 'attachments', attachmentName); | ||
|
||
// Check if file exists | ||
if (!fs.existsSync(attachmentPath)) { |
Check failure
Code scanning / CodeQL
Uncontrolled data used in path expression High
user-provided value
} | ||
|
||
// Read the file and send it in the response | ||
fs.readFile(attachmentPath, (err, data) => { |
Check failure
Code scanning / CodeQL
Uncontrolled data used in path expression High
user-provided value
app.get('/attachment/:name', (req, res) => { | ||
// This line directly takes the user input and appends it to the directory path | ||
const attachmentName = req.params.name; | ||
const attachmentPath = path.join(__dirname, 'attachments', attachmentName); | ||
|
||
// Check if file exists | ||
if (!fs.existsSync(attachmentPath)) { | ||
return res.status(404).send('Attachment not found'); | ||
} | ||
|
||
// Read the file and send it in the response | ||
fs.readFile(attachmentPath, (err, data) => { | ||
if (err) { | ||
return res.status(500).send('Error reading file'); | ||
} | ||
res.setHeader('Content-Type', 'text/plain'); | ||
res.send(data); | ||
}); | ||
}); |
Check failure
Code scanning / CodeQL
Missing rate limiting High
a file system access
This route handler performs
a file system access
Mayhem for API Automated API Testing Report❗ 1 Errors Found
✔️ 🎆 0 Warnings FoundTesting details and issue reproduction found at https://app.mayhem.security/forallsecure-demo/mapi-node-example/node/91 |
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## main #3 +/- ##
==========================================
+ Coverage 88.23% 92.10% +3.86%
==========================================
Files 1 1
Lines 17 38 +21
==========================================
+ Hits 15 35 +20
- Misses 2 3 +1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
For testing path traversal