-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Reimport: Special statuses should be respected from reports #12249
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reimport: Special statuses should be respected from reports #12249
Conversation
🟡 Please give this pull request extra attention during review.This pull request contains a potential mass assignment vulnerability in the Checkmarx One parser and highlights some SQL injection risks, with most findings being low-confidence observations about parsing logic and state consistency that do not introduce direct security threats.
|
Vulnerability | Potential Mass Assignment Vulnerability |
---|---|
Description | The code uses mass assignment by using the **instance_details syntax to pass multiple attributes to the Finding model constructor, which could potentially include unintended or malicious attributes if instance_details is not properly validated or filtered |
django-DefectDojo/dojo/tools/checkmarx_one/parser.py
Lines 175 to 189 in 796ee74
date = self._parse_date(instance.get("firstFoundDate")) | |
else: | |
date = self._parse_date(instance.get("foundDate")) | |
instance_details = self.determine_state(instance) | |
instance_details.update(base_finding_details) | |
# Create the finding object | |
finding = Finding( | |
severity=instance.get("severity").title(), | |
date=date, | |
file_path=instance.get("destinationFileName"), | |
line=instance.get("destinationLine"), | |
**instance_details, | |
) | |
# Add some details to the description | |
if node_snippet := get_node_snippet(instance.get("nodes", [])): |
💭 Unconfirmed Findings (4)
Vulnerability | SQL Injection Vulnerabilities |
---|---|
Description | Critical severity (CWE-89) vulnerabilities found in WebGoat Java source code files. Involves untrusted user inputs directly concatenated into SQL queries without proper input validation or parameterization, potentially allowing arbitrary SQL syntax injection. |
Vulnerability | Potential State Consistency Risks |
---|---|
Description | Identified in default_reimporter.py, these risks involve possible race conditions or stale data issues during finding reimport. Mitigation was added by refreshing specific database fields before processing. |
Vulnerability | Parsing State Determination Considerations |
---|---|
Description | Found in checkmarx_one/parser.py, potential risks include external documentation reference changes, state determination based on string comparisons, and lack of input validation on state values. |
Vulnerability | No Direct Security Vulnerabilities |
---|---|
Description | Most changes appear to be improvements in test coverage and parsing logic. No introduction of hardcoded credentials or sensitive information was detected. |
All finding details can be found in the DryRun Security Dashboard.
Co-authored-by: Charles Neill <[email protected]>
…ffooch/django-DefectDojo into reimport-special-status-consideration
When a report has findings that are mitigated since the previous import, a similar problem will occur. I don't think this PR solves that yet. A workaround for that was done in #12204. I think the root cause is not that old data is being passed into The
The result is that too many findings are passed into
Although the refresh solution may work for now, it might not work in the future if something changes in the reimport. The result of the refresh might also depend on the transaction isolation being used. The refresh implementation also results in incorrect counts for the django-DefectDojo/dojo/importers/default_reimporter.py Lines 128 to 138 in 3fd00f0
I think tracking mitigated findings and "special status findings" should be added so we can stick to the original design that i.e.
Alternative the mitigated findings and "special status" findings can be tracked separately from each other. The proposed tracking solution would additionally expose another error in the reimporter where findings are marked as false positive/risk accepted/out of scope without setting the django-DefectDojo/dojo/importers/default_reimporter.py Lines 606 to 617 in 3fd00f0
If the user chooses to uncheck the close old findings input parameter, the findings that are false positive/out of scope/risk accepted end up as active==False but also is_mitigated==False. For findings that have no special status, but are mitigated, this is done better:
|
I created a small draft PR that shows what it would look like. I didn't test or add any unit tests yet. |
Turns out that by tracking the mitigated findings, we see that in some unit tests a findings get mitigated and reactivated within the same import. I guess for now it's OK to stick to the refresh solution as that solves the reported problem and doesn't seem to make things worse. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approved
* Reimport: Special statuses should be respected from reports * Fixing ruff * Update unittests/tools/test_checkmarx_one_parser.py Co-authored-by: Charles Neill <[email protected]> * Use the correct dict for statuses --------- Co-authored-by: Charles Neill <[email protected]>
* Reimport: Special statuses should be respected from reports * Fixing ruff * Update unittests/tools/test_checkmarx_one_parser.py Co-authored-by: Charles Neill <[email protected]> * Use the correct dict for statuses --------- Co-authored-by: Charles Neill <[email protected]>
* Reimport: Special statuses should be respected from reports * Fixing ruff * Update unittests/tools/test_checkmarx_one_parser.py Co-authored-by: Charles Neill <[email protected]> * Use the correct dict for statuses --------- Co-authored-by: Charles Neill <[email protected]>
* Reimport: Special statuses should be respected from reports * Fixing ruff * Update unittests/tools/test_checkmarx_one_parser.py Co-authored-by: Charles Neill <[email protected]> * Use the correct dict for statuses --------- Co-authored-by: Charles Neill <[email protected]>
When performing a reimport, the status of a finding from the report that is either false positive, out of scope, or risk accepted is being discarded. This is due to a flaw in the way findings are calculated for the
close_old_findings
function.Let's say we have a finding in the database that is active. In the next reimport, the same finding is being reported form the tool as false positive. Reimport will do the following:
This situation is caused from attempting to close a stale record, that may or may not already be closed, and therefore overwrite any other statuses. The solution here is simple: fetch the latest status on the finding before deciding if it needs to be closed.
[sc-10908]