Skip to content

feat(ops): add warehouse audit endpoint - #28

Open
ogulcan-gurcaglar wants to merge 1 commit into
zp313-ubasefrom
zp313-u2-registered-in-pr
Open

ogulcan-gurcaglar wants to merge 1 commit into
zp313-ubasefrom
zp313-u2-registered-in-pr

Conversation

@ogulcan-gurcaglar

Copy link
Copy Markdown

Adds the warehouse audit endpoint and registers it.

@zeropath-ai-staging

Copy link
Copy Markdown

1 possible security or compliance issue detected. Reviewed everything up to 03559bb.

The following issues were found:

  • Issue 1: SQL Injection
    • Location: routes/warehouseAudit.ts:13
    • Score: CRITICAL (90.0)
    • Description: The newly mounted /rest/warehouse/audit route is reachable without any authentication or authorization middleware, and interpolates the attacker-controlled zone query parameter directly into a SQL statement. An anonymous remote user can inject SQL (for example, using a UNION or comment payload) to read arbitrary database records, and the resulting rows are returned in the JSON response.

Evidence: server.ts:578 mounts app.get('/rest/warehouse/audit', warehouseAudit()) with no auth/role middleware. The handler reads req.query.zone at line 12 and embeds it unescaped into models.sequelize.query(...) at line 13; unlike the neighboring orderAudit route, it uses no replacements/parameter binding.

Security Overview
Detected Code Changes
Change Type Relevant files
Enhancement ► routes/warehouseAudit.ts
    Add warehouse audit route for operations console
► server.ts
    Register warehouse audit route /rest/warehouse/audit

Comment thread routes/warehouseAudit.ts
module.exports = function warehouseAudit () {
return (req: Request, res: Response, next: NextFunction) => {
const zone = req.query.zone ?? ''
models.sequelize.query(`SELECT * FROM Products WHERE description LIKE '%${zone}%'`)

@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/warehouse/audit (warehouseAudit.ts) (Severity: CRITICAL)

The route allows unauthenticated access which can lead to data exposure. It interpolates req.query.zone directly into a SQL statement, causing injection that could read arbitrary tables; this is performed without parameter binding, resulting in the returned rows in the JSON response.
View details in ZeroPath

Suggested change
models.sequelize.query(`SELECT * FROM Products WHERE description LIKE '%${zone}%'`)
models.sequelize.query('SELECT * FROM Products WHERE description LIKE ?', { replacements: [`%${zone}%`] })

💬 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 03559bb.

The following issues were found:

  • Issue 1: SQL Injection
    • Location: routes/warehouseAudit.ts:13
    • Score: HIGH (84.0)
    • Description: The new warehouse audit endpoint interpolates the attacker-controlled zone query parameter directly into a raw SQL statement. A remote caller can supply SQL metacharacters to alter the WHERE clause or execute additional SQLite expressions, exposing or modifying database data depending on the database driver's behavior.

Evidence: const zone = req.query.zone ?? '' reads request query input, and line 13 constructs models.sequelize.query with the value embedded in LIKE '%${zone}%' without parameter binding or escaping. The endpoint is registered as GET /rest/warehouse/audit in server.ts:578.

Security Overview
Detected Code Changes
Change Type Relevant files
Enhancement ► routes/warehouseAudit.ts
    Add warehouse audit route for operations console
► server.ts
    Register warehouse audit route /rest/warehouse/audit

Comment thread routes/warehouseAudit.ts
module.exports = function warehouseAudit () {
return (req: Request, res: Response, next: NextFunction) => {
const zone = req.query.zone ?? ''
models.sequelize.query(`SELECT * FROM Products WHERE description LIKE '%${zone}%'`)

@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 warehouseAudit endpoint (routes/warehouseAudit.ts) (Severity: HIGH)

SQL injection risk exposes or alters data because the zone query parameter is interpolated directly into a LIKE clause in a raw SQL query, which can be exploited by supplying special characters. This occurs in routes/warehouseAudit.ts line 13 where zone is read from req.query.zone and embedded in sequelize.query without parameter binding, leading to potentially unintended queries executed by GET /rest/warehouse/audit.
View details in ZeroPath

Suggested change
models.sequelize.query(`SELECT * FROM Products WHERE description LIKE '%${zone}%'`)
models.sequelize.query('SELECT * FROM Products WHERE description LIKE :zone', { replacements: { zone: `%${zone}%` } })

💬 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