CPE/XCCDF/DS: fix infinite loops in parsers on malformed input#2362
Open
edznux-dd wants to merge 1 commit into
Open
CPE/XCCDF/DS: fix infinite loops in parsers on malformed input#2362edznux-dd wants to merge 1 commit into
edznux-dd wants to merge 1 commit into
Conversation
Several parse loops never made progress on unexpected/truncated input, spinning forever (DoS). - CPE dict/lang: `while (localname != TAG)` loops spun at EOF (localname becomes NULL / reader stops advancing) and on unconsumed child nodes in cpe_item, cpe_generator, cpe_platform, cpe vendor/notes, cpe23 and deprecation parsing; cpe_testexpr_parse spun on a nested logical-test with an invalid operator. Break on end-of-document and force forward progress. - XCCDF profile: xccdf_profile_parse / xccdf_parse_remarks could re-read the same node forever; added a forward-progress guard and skip non-<remark> children. - DS rds_index: the report-requests/assets/reports loops did `continue` without advancing the reader on a non-matching element. Also NULL-safe id lookups and guards for unresolved relationship refs.
|
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.




(see #2361 for more context)
This is the 2nd PR out of 4, and focuses on infinite loops of unexpected or truncated inputs.
Like in the first PR, this also adds null-checks to the related files (to avoid merge conflicts 😅 )
Some context:
while (localname != TAG)loops spun at EOF (localname becomes NULL / reader stops advancing) and on unconsumed child nodes in cpe_item, cpe_generator, cpe_platform, cpe vendor/notes, cpe23 and deprecation parsing; cpe_testexpr_parse spun on a nested logical-test with an invalid operator.continuewithout advancing the reader on a non-matching element. Also NULL-safe id lookups and guards for unresolved relationship refs.