fix: prevent SQL injection via require_owned_task column names#1973
Open
namann5 wants to merge 2 commits into
Open
fix: prevent SQL injection via require_owned_task column names#1973namann5 wants to merge 2 commits into
namann5 wants to merge 2 commits into
Conversation
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
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #1971
Summary
Adds column name whitelist validation to require_owned_task() to prevent SQL injection via the columns parameter.
Changes
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).