feat(routes): add product revenue lookup (rerun) - #20
Conversation
|
❌ 1 possible security or compliance issue detected. Reviewed everything up to 632a124. The following issues were found:
Evidence:
Security Overview
Detected Code Changes
|
| module.exports = function productRevenue () { | ||
| return (req: Request, res: Response, next: NextFunction) => { | ||
| const name = req.query.name ?? '' | ||
| models.sequelize.query(`SELECT id, name, price FROM Products WHERE name LIKE '%${name}%' AND deletedAt IS NULL ORDER BY price DESC`) |
There was a problem hiding this comment.
SQL Injection in /rest/products/revenue (routes/productRevenue.ts) (Severity: HIGH)
This SQL injection risk allows an unauthenticated user to inject SQL via the name query parameter, which is interpolated directly into a LIKE clause in productRevenue, leading to potential data disclosure or modification. The vulnerability arises from building the query with string interpolation in routes/productRevenue.ts lines 13-14, and mounting the endpoint in server.ts:572 without authentication middleware, which causes unvalidated input to reach the database.
View details in ZeroPath
| models.sequelize.query(`SELECT id, name, price FROM Products WHERE name LIKE '%${name}%' AND deletedAt IS NULL ORDER BY price DESC`) | |
| models.sequelize.query('SELECT id, name, price FROM Products WHERE name LIKE ? AND deletedAt IS NULL ORDER BY price DESC', { replacements: [`%${name}%`] }) |
💬 Reply @ZeroPath false-positive because … or @ZeroPath accepted-risk because … to triage this finding, or ask it any question.
|
❌ 1 possible security or compliance issue detected. Reviewed everything up to 632a124. The following issues were found:
Evidence:
Security Overview
Detected Code Changes
|
| module.exports = function productRevenue () { | ||
| return (req: Request, res: Response, next: NextFunction) => { | ||
| const name = req.query.name ?? '' | ||
| models.sequelize.query(`SELECT id, name, price FROM Products WHERE name LIKE '%${name}%' AND deletedAt IS NULL ORDER BY price DESC`) |
There was a problem hiding this comment.
SQL Injection in /rest/products/revenue (routes/productRevenue.ts:14) (Severity: HIGH)
The endpoint is exploitable by remote attackers who can inject SQL via the name query parameter, which causes the raw query to include unescaped input in the LIKE clause and return unintended data. This is worsened by the route registering without authentication or authorization, leading to unauthorized access to product data via /rest/products/revenue?name=...
View details in ZeroPath
| models.sequelize.query(`SELECT id, name, price FROM Products WHERE name LIKE '%${name}%' AND deletedAt IS NULL ORDER BY price DESC`) | |
| models.sequelize.query('SELECT id, name, price FROM Products WHERE name LIKE :name AND deletedAt IS NULL ORDER BY price DESC', { replacements: { name: `%${name}%` } }) |
💬 Reply @ZeroPath false-positive because … or @ZeroPath accepted-risk because … to triage this finding, or ask it any question.
Controlled re-run: tree is byte-identical to the pre-deploy probe branch, so discovery prompts hit the AI cache and only the confirmation stage differs.