Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions routes/productLookup.ts
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`)

@zeropath-ai-staging zeropath-ai-staging Bot Sep 9, 2026

Copy link
Copy Markdown

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

Suggested change
models.sequelize.query(`SELECT name, description FROM Products WHERE description LIKE '%${term}%' AND deletedAt IS NULL ORDER BY name ASC`)
models.sequelize.query('SELECT name, description FROM Products WHERE description LIKE :term AND deletedAt IS NULL ORDER BY name ASC', { replacements: { term: `%${term}%` } })

💬 Reply @ZeroPath false-positive because … or @ZeroPath accepted-risk because … to triage this finding, or ask it any question.

All commands

@zeropath-ai-staging zeropath-ai-staging Bot Sep 9, 2026

Copy link
Copy Markdown

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)

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.
View details in ZeroPath

Suggested change
models.sequelize.query(`SELECT name, description FROM Products WHERE description LIKE '%${term}%' AND deletedAt IS NULL ORDER BY name ASC`)
models.sequelize.query('SELECT name, description FROM Products WHERE description LIKE :term AND deletedAt IS NULL ORDER BY name ASC', { replacements: { term: `%${term}%` } })

💬 Reply @ZeroPath false-positive because … or @ZeroPath accepted-risk because … to triage this finding, or ask it any question.

All commands

.then(([rows]: any) => {
res.json({ term, rows })
}).catch((error: Error) => {
next(error)
})
}
}
2 changes: 2 additions & 0 deletions server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ const resetPassword = require('./routes/resetPassword')
const securityQuestion = require('./routes/securityQuestion')
const search = require('./routes/search')
const coupon = require('./routes/coupon')
const productLookup = require('./routes/productLookup')
const basket = require('./routes/basket')
const order = require('./routes/order')
const verify = require('./routes/verify')
Expand Down Expand Up @@ -568,6 +569,7 @@ restoreOverwrittenFilesWithOriginals().then(() => {
app.get('/rest/user/whoami', security.updateAuthenticatedUsers(), currentUser())
app.get('/rest/user/authentication-details', authenticatedUsers())
app.get('/rest/products/search', search())
app.get('/rest/products/lookup', productLookup())
app.get('/rest/basket/:id', basket())
app.post('/rest/basket/:id/checkout', order())
app.put('/rest/basket/:id/coupon/:coupon', coupon())
Expand Down