title: Security issue with external entity loading in XML without enabling it
description: In PHP versions 8.0.* before 8.0.30, 8.1.* before 8.1.22, and 8.2.* before 8.2.8 various XML functions rely on libxml global state to track configuration variables, like whether external entities are loaded. This state is assumed to be unchanged unless the user explicitly changes it by calling appropriate function. However, since the state is process-global, other modules - such as ImageMagick - may also use this library within the same process, and change that global state for their internal purposes, and leave it in a state where external entities loading is enabled. This can lead to the situation where external XML is parsed with external entities loaded, which can lead to disclosure of any local files accessible to PHP. This vulnerable state may persist in the same process across many requests, until the process is shut down.
affected:
{
defaultStatus: affected
product: PHP
vendor: PHP Group
versions:
lessThan: 8.0.30, status: affected, version: 8.0.*, versionType: semver
lessThan: 8.1.22, status: affected, version: 8.1.*, versionType: semver
lessThan: 8.2.8, status: affected, version: 8.2.*, versionType: semver
}
metrics:
cvssV3_1: [
attackComplexity: LOW
attackVector: NETWORK
availabilityImpact: LOW
baseScore: 8.6
baseSeverity: HIGH
confidentialityImpact: HIGH
integrityImpact: LOW
privilegesRequired: NONE
scope: UNCHANGED
userInteraction: NONE
vectorString: CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:L/A:L
version: 3.1
]
format: CVSS
scenarios: GENERAL
workarounds: Disable external entity loader, e.g. like this: libxml_set_external_entity_loader(function () { return null; });