-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Improve cvssv3 validation #12440
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
base: dev
Are you sure you want to change the base?
Improve cvssv3 validation #12440
Conversation
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
3c962cd
to
b0dda81
Compare
Conflicts have been resolved. A maintainer will review the pull request shortly. |
This pull request introduces potential security risks related to CVSS vector parsing, logging, and input validation across multiple files, with concerns about incomplete data sanitization, reduced logging visibility, and potential exposure of sensitive vulnerability information. 💭 Unconfirmed Findings (9)
All finding details can be found in the DryRun Security Dashboard. |
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
4389265
to
5ab1c71
Compare
Conflicts have been resolved. A maintainer will review the pull request shortly. |
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.
This is looking really good - only a couple questions/nits
docs/content/en/open_source/contributing/how-to-write-a-parser.md
Outdated
Show resolved
Hide resolved
dojo/models.py
Outdated
except Exception as ex: | ||
logger.error("Can't compute cvssv3 score for finding id %i. Invalid cvssv3 vector found: '%s'. Exception: %s", self.id, self.cvssv3, ex) | ||
logger.warning("Can't compute cvssv3 score for finding id %i. Invalid cvssv3 vector found: '%s'. Exception: %s.", self.id, self.cvssv3, ex) | ||
# should we set self.cvssv3 to None here to avoid storing invalid vectors? it would also remove invalid vectors on existing findings... |
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.
I think we should remove invalid vectors, but only if the id is None
before the finding is saved. That allows us to prevent the issue from spreading even further without implications for existing data
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.
addressed this, but maybe we should just throw a ValidationError? That is what will happen in the future if we implement better validation support for Findings in general via clean
.
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.
actually, I think the validator will do this already, as its called before the save method is, right?
dojo/db_migrations/0229_alter_finding_cvssv3_alter_finding_template_cvssv3.py
Outdated
Show resolved
Hide resolved
112adfe
to
a2f1f98
Compare
Although it's not fully clear "what the problem is" reported in #8264 , we want to stop using the regex for validation and use the
cvss
library in a validator. This PR updates the validator on the model and updates the test cases to reflect the new behaviour. The new behaviour is better:Finding.save()
is called, no validation is perfrmed by Django. So we have make sure the parsers only store valid vectors.I updated the parsers that did not yet follow the guidelines in
docs/content/en/open_source/contributing/how-to-write-a-parser.md
. I considered:set_data_from_cvss_string(...)
to the Finding modelFinding.save()
to validate/parse the vector stringBut in the end I went for a helper method in
dojo.utils
to parse the CVSS vector. This way we have the parsing logic in one central place and the parsers can decide which of the 3 parsed fields they want to use on the model (vector
,score
,severity
). The logic is also failsafe, invalid vectors result in empty cvss fields but won't cause the import to fail.Remaining questions:
Finding.save()
that sets (overwrites) thecvssv3_score
if a valid vector is set? (I think for now YES)Finding.save()
encounters an invalid vector incvssv3
. Should we clear the vector before saving? (I think for now NO)Risks:
Feedback welcome. I also think this is a nice preparation for when we want to support CVSS4 vectors.