🛡️ Sentinel: [CRITICAL] Fix SQL injection risk in dynamic database queries#47
Draft
davidjuarezdev wants to merge 1 commit intomainfrom
Draft
🛡️ Sentinel: [CRITICAL] Fix SQL injection risk in dynamic database queries#47davidjuarezdev wants to merge 1 commit intomainfrom
davidjuarezdev wants to merge 1 commit intomainfrom
Conversation
…eries Replaced `assert` in `streamrip/db.py` with `ValueError` for validating keys during query construction, as `assert` can be optimized away in production, potentially leaving the code vulnerable to SQL injection through dictionary unpacking bypass. Also added key validation to the `remove` method which had no checks. Added a journal entry explaining this finding. Co-authored-by: davidjuarezdev <230496599+davidjuarezdev@users.noreply.github.com>
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 via Python's
assertand**kwargsdictionary unpacking bypass in dynamic database queries (streamrip/db.py).🎯 Impact: If the Python interpreter runs with the optimization flag
-O,assertstatements are stripped out entirely. An attacker (or corrupted input) could pass malicious column names via**kwargsdictionary unpacking (which allows any identifier), completely bypassing the key validation logic inDatabaseBase.contains. The keys were then concatenated directly into a query string, leading to SQL injection. Additionally,DatabaseBase.removehad no key validation at all.🔧 Fix:
DatabaseBase.containsto useraise ValueErrorinstead ofassertto ensure the key validation runs regardless of optimization flags.DatabaseBase.remove..jules/sentinel.mddocumenting this edge case.✅ Verification:
pytestsuites passing).PR created automatically by Jules for task 11980032661180759317 started by @davidjuarezdev