Skip to content

harden: add parameterized queries in migrate-db.mjs - #7

Closed
anupamme wants to merge 1 commit into
timharris707:mainfrom
anupamme:fix-repo-modeldeck-sql-injection-migrate-db
Closed

anupamme wants to merge 1 commit into
timharris707:mainfrom
anupamme:fix-repo-modeldeck-sql-injection-migrate-db

Conversation

@anupamme

@anupamme anupamme commented Sep 4, 2026

Copy link
Copy Markdown

Summary

Harden input handling in scripts/migrate-db.mjs (flagged by semgrep).

Vulnerability

Field Value
ID utils.custom.sql-injection-template-literal
Severity HIGH
Scanner semgrep
Rule utils.custom.sql-injection-template-literal
File scripts/migrate-db.mjs:40
Assessment Defensive hardening

Description: SQL query constructed using JavaScript template literals with dynamic input. This can lead to SQL injection. Use parameterized queries instead.

Threat Model Context

This is a web application - XSS and injection vulnerabilities can affect end users.

Changes

  • scripts/migrate-db.mjs

Behavior Preservation

The change is scoped to 1 file on the vulnerable path.


This patch removes an exploit primitive — a code pattern that, while not independently exploitable today, could be chained with other weaknesses by automated exploit-development tooling. Proactive removal of such primitives raises the bar against increasingly capable automated attack tools.


Automated security fix by OrbisAI Security

Automated security fix generated by OrbisAI Security
@timharris707

Copy link
Copy Markdown
Owner

Claude Fable 5.1, on behalf of Tim Harris:

Thanks for the patch. Closing without merging: every call to that count helper passes a hardcoded table name from inside the same script, so there is no path for outside input to reach the query. The change would not alter behavior, and we keep the script small.

If you ever spot something with a real input path, we would like to hear about it.

@anupamme

anupamme commented Sep 6, 2026

Copy link
Copy Markdown
Author

Thanks for the detailed review. I agree with the assessment; the current callers only pass hardcoded table names, so there isn’t an attacker-controlled path to the interpolated value, and this isn’t an independently exploitable SQL injection today.

My intent was defensive hardening in response to the static-analysis finding. I also agree that the allowlist adds complexity when the helper doesn’t currently need to accept dynamic table names.

If the helper later becomes exposed to dynamic input, the allowlist approach (or removing the dynamic identifier altogether) would be appropriate.

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.

2 participants