Skip to content

feat(routes): add catalog description lookup (rerun) - #24

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

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

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

The following issues were found:

  • Issue 1: SQL Injection
    • Location: routes/productLookup.ts:13
    • Score: HIGH (88.0)
    • Description: The newly exposed /rest/products/lookup endpoint interpolates the attacker-controlled term query parameter directly into a raw SQL statement. An anonymous user can inject SQL syntax through term, altering the query and potentially extracting or modifying data available to the database connection.

Evidence: const term = req.query.term ?? '' reads the HTTP query parameter, and line 13 constructs SELECT ... WHERE description LIKE '%${term}%' without parameter binding or escaping. The route is mounted at line 572 without an authentication middleware.

Security Overview
Detected Code Changes
Change Type Relevant files
Enhancement ► routes/productLookup.ts
    Add productLookup route for catalog description search
► server.ts
    Register /rest/products/lookup route with productLookup handler

Comment thread routes/productLookup.ts
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

Copy link
Copy Markdown

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

The following issues were found:

  • Issue 1: SQL Injection
    • Location: routes/productLookup.ts:13
    • Score: HIGH (87.0)
    • Description: The newly exposed /rest/products/lookup endpoint interpolates the attacker-controlled term query parameter directly into a Sequelize raw SQL query. An unauthenticated caller can inject SQL syntax through term, altering the WHERE clause and potentially extracting or modifying database data depending on the SQLite/Sequelize connection capabilities.

Evidence: const term = req.query.term ?? '' reads request query input, and line 13 constructs ... WHERE description LIKE '%${term}%' ... without replacements, bind parameters, or escaping before models.sequelize.query(...). The route is registered as app.get('/rest/products/lookup', productLookup()) with no authentication middleware.

Security Overview
Detected Code Changes
Change Type Relevant files
Enhancement ► routes/productLookup.ts
    Add productLookup route for catalog description search
► server.ts
    Register /rest/products/lookup route with productLookup handler

Comment thread routes/productLookup.ts
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)

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

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