Skip to content

fix: prevent SQL injection via require_owned_task column names#1973

Open
namann5 wants to merge 2 commits into
utksh1:mainfrom
namann5:fix/sql-injection-routes-upstream
Open

fix: prevent SQL injection via require_owned_task column names#1973
namann5 wants to merge 2 commits into
utksh1:mainfrom
namann5:fix/sql-injection-routes-upstream

Conversation

@namann5

@namann5 namann5 commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Closes #1971

Summary

Adds column name whitelist validation to require_owned_task() to prevent SQL injection via the columns parameter.

Changes

  • backend/secuscan/routes.py: Define _TASK_COLUMNS frozenset with all valid tasks table column names
  • backend/secuscan/routes.py: Validate every column in the comma-separated columns parameter against the whitelist before constructing the SQL query
  • Raise HTTP 400 with descriptive message for unknown columns instead of allowing arbitrary SQL interpolation

Why

The columns parameter was directly interpolated into a SQL SELECT query via f-string without validation. While all 6 current callers pass hardcoded values, the interface was a ticking time bomb — CVSS 9.1 (Critical).

The columns parameter of 
equire_owned_task() was directly
interpolated into the SQL query via f-string without any validation.
While all 6 current callers pass hardcoded column strings, the
function's interface made it dangerously easy for a future developer
to inadvertently pass user-controlled data.

Fix:
- Define _TASK_COLUMNS frozenset containing all valid tasks table
  column names, sourced from the schema in database.py
- Validate every column name in the comma-separated columns
  parameter against this whitelist before constructing the query
- Raise HTTP 400 with a descriptive message listing unknown columns
  instead of allowing arbitrary SQL interpolation
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

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.

Critical: SQL injection via unsanitized column names in require_owned_task

1 participant