Skip to content

feat(routes): add product packaging leaflet (rerun) - #23

Open
ogulcan-gurcaglar wants to merge 2 commits into
masterfrom
zp313-r8
Open

ogulcan-gurcaglar wants to merge 2 commits into
masterfrom
zp313-r8

Conversation

@ogulcan-gurcaglar

Copy link
Copy Markdown

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.

@zeropath-ai-staging

Copy link
Copy Markdown

1 possible security or compliance issue detected. Reviewed everything up to 8942e5c.

The following issues were found:

  • Issue 1: Path Traversal
    • Location: routes/productLeaflet.ts:14
    • Score: HIGH (81.0)
    • Description: The newly exposed unauthenticated /rest/products/leaflet endpoint passes the attacker-controlled leaflet query parameter directly to path.join and fs.readFile without constraining it to the intended leaflet directory. A remote anonymous user can supply traversal segments (for example, ?leaflet=../../package.json, adjusted for the process working directory) to read arbitrary files readable by the Node process, including application configuration, source, and potentially secrets, which are then returned in the response.

Evidence: server.ts:572 mounts the handler without authentication, and routes/productLeaflet.ts:13-14 converts req.query.leaflet directly into a filesystem path under ftp/leaflets; path.join normalizes .. segments rather than preventing escape.

Security Overview
Detected Code Changes
Change Type Relevant files
Enhancement ► routes/productLeaflet.ts
    Add new route to serve product leaflets
► server.ts
    Register new /rest/products/leaflet route using productLeaflet handler

Comment thread routes/productLeaflet.ts
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) => {

@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.

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

Suggested change
fs.readFile(path.join('ftp/leaflets', String(leaflet)), 'utf8', (error, text) => {
fs.readFile(path.join('ftp/leaflets', path.basename(String(leaflet))), 'utf8', (error, text) => {

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

All commands

@zeropath-ai-staging

Copy link
Copy Markdown

1 possible security or compliance issue detected. Reviewed everything up to 8942e5c.

The following issues were found:

  • Issue 1: Path Traversal
    • Location: routes/productLeaflet.ts:14
    • Score: HIGH (83.0)
    • Description: The new unauthenticated /rest/products/leaflet endpoint uses the attacker-controlled leaflet query parameter directly in path.join before reading the file. A request such as ?leaflet=../../server.ts can escape ftp/leaflets and return arbitrary readable files as text/plain. This exposes server-side source, configuration, secrets, or other sensitive files available to the process.

Evidence: const leaflet = req.query.leaflet ?? 'default.md' obtains request-controlled input, and fs.readFile(path.join('ftp/leaflets', String(leaflet)), ...) performs the filesystem read without canonicalization, allowlisting, or containment validation.

Security Overview
Detected Code Changes
Change Type Relevant files
Enhancement ► routes/productLeaflet.ts
    Add new route to serve product leaflets
► server.ts
    Register new /rest/products/leaflet route using productLeaflet handler

Comment thread routes/productLeaflet.ts
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) => {

@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.

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

Suggested change
fs.readFile(path.join('ftp/leaflets', String(leaflet)), 'utf8', (error, text) => {
fs.readFile(path.join('ftp/leaflets', path.basename(String(leaflet))), 'utf8', (error, text) => {

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

All commands

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant