-
Notifications
You must be signed in to change notification settings - Fork 0
feat(routes): add catalog description lookup (rerun) #24
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,20 @@ | ||||||
| /* | ||||||
| * Copyright (c) 2014-2024 Bjoern Kimminich & the OWASP Juice Shop contributors. | ||||||
| * SPDX-License-Identifier: MIT | ||||||
| */ | ||||||
|
|
||||||
| import * as models from '../models/index' | ||||||
| import { type Request, type Response, type NextFunction } from 'express' | ||||||
|
|
||||||
| // Catalog description search for the storefront quick-filter. | ||||||
| module.exports = function productLookup () { | ||||||
| return (req: Request, res: Response, next: NextFunction) => { | ||||||
| const term = req.query.term ?? '' | ||||||
| models.sequelize.query(`SELECT name, description FROM Products WHERE description LIKE '%${term}%' AND deletedAt IS NULL ORDER BY name ASC`) | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. SQL Injection in /rest/products/lookup (routes/productLookup.ts) (Severity: HIGH) The endpoint allows unauthenticated users to inject SQL via the term query parameter, which is interpolated directly into a Sequelize raw query, potentially exposing or altering data. This causes the WHERE clause to be manipulated because term is interpolated into the query string without parameter binding or escaping, leading to unauthorized data access depending on SQLite/Sequelize configurations.
Suggested change
💬 Reply |
||||||
| .then(([rows]: any) => { | ||||||
| res.json({ term, rows }) | ||||||
| }).catch((error: Error) => { | ||||||
| next(error) | ||||||
| }) | ||||||
| } | ||||||
| } | ||||||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SQL Injection in /rest/products/lookup (routes/productLookup.ts) (Severity: HIGH)
Security impact: an attacker can inject SQL via the term query parameter, potentially reading or modifying data. The code interpolates req.query.term directly into a raw SQL string in line 13, which is executed by Sequelize without parameter binding, leading to data exposure or corruption and occurs on the public route mounted at line 572.
View details in ZeroPath
💬 Reply
@ZeroPath false-positive because …or@ZeroPath accepted-risk because …to triage this finding, or ask it any question.All commands