Skip to content

CPE/XCCDF/DS: fix infinite loops in parsers on malformed input#2362

Open
edznux-dd wants to merge 1 commit into
OpenSCAP:mainfrom
edznux-dd:fix/parser-infinite-loops
Open

CPE/XCCDF/DS: fix infinite loops in parsers on malformed input#2362
edznux-dd wants to merge 1 commit into
OpenSCAP:mainfrom
edznux-dd:fix/parser-infinite-loops

Conversation

@edznux-dd
Copy link
Copy Markdown

(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:

  • 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.
  • XCCDF profile: xccdf_profile_parse / xccdf_parse_remarks could re-read the same node forever; added a forward-progress guard and skip non- 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.

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.
@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented Jun 3, 2026

Quality Gate Failed Quality Gate failed

Failed conditions
E Reliability Rating on New Code (required ≥ A)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

@jan-cerny jan-cerny self-assigned this Jun 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants