Skip to content

OVAL/XCCDF/DS/source: fix memory-corruption bugs on malformed input#2363

Open
edznux-dd wants to merge 1 commit into
OpenSCAP:mainfrom
edznux-dd:fix/memory-corruption
Open

OVAL/XCCDF/DS/source: fix memory-corruption bugs on malformed input#2363
edznux-dd wants to merge 1 commit into
OpenSCAP:mainfrom
edznux-dd:fix/memory-corruption

Conversation

@edznux-dd
Copy link
Copy Markdown

(see #2361 for more context)

This is the 3rd PR of the series (out of 4). This one focuses on UaF, double free and heap buffer overflow found with the fuzzer setup (under address sanitizer for ease of discovery)

Open question:

I've set #define DS_SDS_MAX_COMPONENT_REF_DEPTH to an arbitrary limit of 30, but I'm not familiar enough with openscap expectations here to see if this could/should be lowered. 30 was a safe, but conservative value (I don't see a real scenario where it would be > 5, but I might be completely miss guided here)

For more context:

  • OVAL oval_set.c: a mixing a nested (aggregate) with object_reference/filter children (collective) wrote into the wrong union member, so oval_setobject_free() later freed a model-owned object (use-after-free / double free). Reject children that don't match the established set type.
  • XCCDF resolve.c: entries were resolved through xccdf_resolve_textlist(), which reads each item as oscap_text -- but a xccdf_warning is smaller, so this read out of bounds (heap-buffer-overflow). Added a dedicated xccdf_resolve_warninglist() operating on warning->text.
  • DS sds.c: component_id aliased the xlink_href buffer that was freed too early (use-after-free); keep it alive until last use. Also cap catalog component-ref recursion (cyclic catalog -> OOM); this recursion-DoS fix is bundled here because it is interleaved with the UAF fix in the same function (instead of a dedicated branch with risk of conflicts)
  • source/schematron.c: OSCAP_SCHEMATRON_TABLE lacked the {0,NULL,NULL} sentinel its lookup loop relies on -> global-buffer-overflow.

- OVAL oval_set.c: a <set> mixing a nested <set> (aggregate) with
  object_reference/filter children (collective) wrote into the wrong union
  member, so oval_setobject_free() later freed a model-owned object
  (use-after-free / double free). Reject children that don't match the
  established set type.
- XCCDF resolve.c: <warning> entries were resolved through
  xccdf_resolve_textlist(), which reads each item as oscap_text -- but a
  xccdf_warning is smaller, so this read out of bounds (heap-buffer-overflow).
  Added a dedicated xccdf_resolve_warninglist() operating on warning->text.
- DS sds.c: component_id aliased the xlink_href buffer that was freed too
  early (use-after-free); keep it alive until last use. Also cap catalog
  component-ref recursion (cyclic catalog -> OOM); this recursion-DoS fix is
  bundled here because it is interleaved with the UAF fix in the same function.
  Also a NULL id guard in lookup_component_in_collection.
- source/schematron.c: OSCAP_SCHEMATRON_TABLE lacked the {0,NULL,NULL}
  sentinel its lookup loop relies on -> global-buffer-overflow; added it.
  Plus NULL guards for missing href/uri, empty <catalog>, and NULL XPath eval.
@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented Jun 3, 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.

1 participant