[CVE-2022-23308] Use-after-free of ID and IDREF attributes 96/286696/1
authorNick Wellnhofer <wellnhofer@aevum.de>
Tue, 8 Feb 2022 02:29:24 +0000 (03:29 +0100)
committerDongHun Kwak <dh0128.kwak@samsung.com>
Thu, 12 Jan 2023 00:58:56 +0000 (09:58 +0900)
commit98ca95e2597f3711d72b7578a41ec46607fb80c4
tree9b873db05c8dce7585ab83ee88704025687b2d22
parent847949e090c6dcc10af0f6b1ab58114d9cd9b543
[CVE-2022-23308] Use-after-free of ID and IDREF attributes

If a document is parsed with XML_PARSE_DTDVALID and without
XML_PARSE_NOENT, the value of ID attributes has to be normalized after
potentially expanding entities in xmlRemoveID. Otherwise, later calls
to xmlGetID can return a pointer to previously freed memory.

ID attributes which are empty or contain only whitespace after
entity expansion are affected in a similar way. This is fixed by
not storing such attributes in the ID table.

The test to detect streaming mode when validating against a DTD was
broken. In connection with the defects above, this could result in a
use-after-free when using the xmlReader interface with validation.
Fix detection of streaming mode to avoid similar issues. (This changes
the expected result of a test case. But as far as I can tell, using the
XML reader with XIncludes referencing the root document never worked
properly, anyway.)

All of these issues can result in denial of service. Using xmlReader
with validation could result in disclosure of memory via the error
channel, typically stderr. The security impact of xmlGetID returning
a pointer to freed memory depends on the application. The typical use
case of calling xmlGetID on an unmodified document is not affected.

Change-Id: I2698142478b614c9b4636528c20aa30e2bbae31c
Signed-off-by: DongHun Kwak <dh0128.kwak@samsung.com>
valid.c