Create SqlInjection.js - #2
Conversation
|
|
||
| app.get("search", function handler(req, res) { | ||
| // BAD: the category might have SQL special characters in it | ||
| var query1 = |
There was a problem hiding this comment.
🤖 Security Issue: Direct concatenation of user input into SQL query without parameterization allows SQL injection attacks
Severity: HIGH
Category: sql_injection
Tool: ClaudeCode AI Security Analysis
Exploit Scenario: An attacker can manipulate the 'category' parameter to inject SQL commands. For example: category=' OR 1=1 UNION SELECT username, password FROM users--' would bypass the WHERE clause and potentially expose sensitive data from other tables. More severe attacks could include: ' OR 1=1; DROP TABLE PRODUCT;--' to destroy data or ' UNION SELECT null, database()--' to extract database metadata.
Recommendation: Use parameterized queries with placeholders instead of string concatenation. Replace the vulnerable code with: pool.query('SELECT ITEM, PRICE FROM PRODUCT WHERE ITEM_CATEGORY = $1 ORDER BY PRICE', [req.params.category], function(err, results) { ... })
No description provided.