Checkmarx AI Remediation - Second_Order_SQL_Injection#4
Open
cx-lucas-ferreira wants to merge 6 commits into
Open
Checkmarx AI Remediation - Second_Order_SQL_Injection#4cx-lucas-ferreira wants to merge 6 commits into
cx-lucas-ferreira wants to merge 6 commits into
Conversation
Author
|
New Issues (48)
Checkmarx found the following issues in this Pull Request
Fixed Issues (101)
Great job! The following issues were fixed in this Pull Request
Use @Checkmarx to interact with Checkmarx PR Assistant. |
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.





Checkmarx One – Remediation
Second_Order_SQL_Injection ·
Critical
Triage context:
Reachable ·
Exploitable
Fix second-order SQL injection vulnerabilities in Django application
What is the issue?
The application contains second-order SQL injection vulnerabilities (CWE-89) across multiple files. User-supplied data such as usernames and blab names is stored in the database during registration, then later retrieved and embedded directly into new SQL queries via string concatenation or Python
%-formatting without sanitization. This two-stage attack vector makes the vulnerabilities harder to detect than classic first-order SQL injection, as the malicious payload is injected at one point in time and executed at another.Why should it be fixed?
An attacker can register a malicious username containing SQL metacharacters, which later executes arbitrary SQL when the stored value is reused in queries. This can result in full credential exfiltration, privilege escalation, account takeover, or database destruction. The vulnerability violates OWASP Top 10 (A03:2021), PCI DSS, and NIST SP 800-53 requirements.
How should it be fixed?
Convert all unsafe
cursor.execute()calls to Django's parameterized query API across five files. Inapp/commands/ListenCommand.pyandapp/commands/IgnoreCommand.py, parameterize the INSERT and SELECT queries that use DB-sourced values. Inapp/views/userController.py, fix 12 queries (login, showPasswordHint, showTotp, processTotp, processRegister, processRegisterFinish, showProfile, processProfile, usernameExists, updateUsername) and remove the unusedsqlparseimport. Inapp/views/blabController.py, fix all 7 queries and add an allowlist for the non-parameterizable ORDER BY clause. Inapp/views/resetController.py, parameterize the INSERT users and INSERT listeners queries. Add regression tests inapp/tests/test_sql_injection.pyandapp/tests/__init__.py.Use @Checkmarx to interact with Checkmarx PR Assistant.
Examples:
@Checkmarx how are you able to help me?@Checkmarx rescan this PR