-
Notifications
You must be signed in to change notification settings - Fork 0
feat(routes): add product packaging leaflet (rerun) #23
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,22 @@ | ||||||
| /* | ||||||
| * Copyright (c) 2014-2024 Bjoern Kimminich & the OWASP Juice Shop contributors. | ||||||
| * SPDX-License-Identifier: MIT | ||||||
| */ | ||||||
|
|
||||||
| import { type Request, type Response, type NextFunction } from 'express' | ||||||
| import path from 'path' | ||||||
| import fs from 'fs' | ||||||
|
|
||||||
| // Serves the packaging leaflet that ships with each product. | ||||||
| module.exports = function productLeaflet () { | ||||||
| return (req: Request, res: Response, next: NextFunction) => { | ||||||
| const leaflet = req.query.leaflet ?? 'default.md' | ||||||
| fs.readFile(path.join('ftp/leaflets', String(leaflet)), 'utf8', (error, text) => { | ||||||
|
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. Path Traversal in /rest/products/leaflet (routes/productLeaflet.ts) (Severity: HIGH) Path traversal vulnerability: an unauthenticated request to /rest/products/leaflet with a attacker-controlled leaflet parameter leads to arbitrary file reads. The code uses req.query.leaflet directly and feeds it into path.join('ftp/leaflets', leaflet) which causes the server to escape the intended directory and read arbitrary files, resulting in exposure of source, configs, secrets, or other sensitive content.
Suggested change
💬 Reply |
||||||
| if (error != null) { | ||||||
| next(error) | ||||||
| return | ||||||
| } | ||||||
| res.type('text/plain').send(text) | ||||||
| }) | ||||||
| } | ||||||
| } | ||||||
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.
Path Traversal in /rest/products/leaflet (routes/productLeaflet.ts) (Severity: HIGH)
An unauthenticated request to /rest/products/leaflet can read arbitrary files. This occurs because leaflet is concatenated directly to a path under ftp/leaflets via path.join and fs.readFile, which allows traversal like ../../package.json, potentially exposing secrets. The route in server.ts:572 is mounted without auth, and routes/productLeaflet.ts:13-14 uses the attacker-controlled parameter to form the filesystem path, resulting in unintended file access.
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