🛡️ Sentinel: [CRITICAL] Fix SQL injection vulnerability in db.py#56
Draft
davidjuarezdev wants to merge 1 commit intomainfrom
Draft
🛡️ Sentinel: [CRITICAL] Fix SQL injection vulnerability in db.py#56davidjuarezdev wants to merge 1 commit intomainfrom
davidjuarezdev wants to merge 1 commit intomainfrom
Conversation
Explicitly validates `**items` dictionary keys against the database structure using `raise ValueError` instead of `assert` in `contains` and `remove` methods. `assert` can be stripped out entirely when Python is run with the `-O` flag, creating a critical vulnerability where arbitrary keys could be interpolated directly into the SQL query text. Co-authored-by: davidjuarezdev <[email protected]>
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.
🚨 Severity: CRITICAL
💡 Vulnerability: SQL injection vulnerability in
streamrip/db.py'scontainsandremovemethods. The previous implementation validated dynamic**itemsdictionary keys usingassert, which is stripped when Python is run with optimizations (e.g.,python -O). In theremovemethod, keys weren't validated at all. This allowed arbitrary, malicious strings to be directly interpolated into the SQLite query strings (f"{key}=?").🎯 Impact: An attacker could craft arbitrary
**kwargsthat bypass the identifier restrictions of standard python variable names, subsequently injecting malicious SQL fragments into dynamic query execution.🔧 Fix: Replaced the fragile
assertstatements with explicitif key not in allowed_keys: raise ValueError(...)loops, applying this robust schema validation to bothcontainsandremovemethods prior to SQL construction.✅ Verification: Formatting and linting checks run successfully (
poetry run ruff check). The comprehensive test suite passes viapoetry run pytest tests.PR created automatically by Jules for task 10316247338205181248 started by @davidjuarezdev