-
Notifications
You must be signed in to change notification settings - Fork 0
feat(routes): add product revenue lookup (rerun) #20
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,21 @@ | ||||||
| /* | ||||||
| * 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' | ||||||
|
|
||||||
| // Product revenue lookup for the merchant dashboard. Callers filter by product | ||||||
| // name fragment, e.g. /rest/products/revenue?name=Juice. | ||||||
| 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. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 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=...
Suggested change
💬 Reply |
||||||
| .then(([rows]: any) => { | ||||||
| res.json({ name, 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/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
💬 Reply
@ZeroPath false-positive because …or@ZeroPath accepted-risk because …to triage this finding, or ask it any question.All commands