REDHAT-BUG-2583437: Medium severity Ericsson xmerl vulnerability
Improper Restriction of XML External Entity Reference vulnerability in xmerlscan in Erlang OTP xmerl allows an attacker to exhaust the memory of the Erlang VM via an XML document that names an external DTD.
With default options, xmerlscan:string/1,2 and xmerlscan:file/1,2 fetch and parse the external DTD named in a <!DOCTYPE root SYSTEM "..."> declaration. fetchDTD/2 in lib/xmerl/src/xmerlscan.erl passes every system identifier to the default fetch function, which maps file: and absolute URIs to local paths, and intfiledecl/3 then reads the whole file with file:readfile/1. This happens whether or not validation is enabled, and the allowentities option, which is false by default since OTP 27, only governs <!ENTITY> declarations and does not stop the fetch. A document naming file:///dev/zero makes the node read without bound until the operating system kills it for lack of memory, and the parse never returns.
This issue affects OTP from OTP 17.0 before OTP 27.3.4.20, OTP 28.5.0.9, and OTP 29.1.3, corresponding to xmerl from 1.3.7 before 2.1.3.4, 2.1.9.1, and 2.2.1. Whether OTP before OTP 17.0, corresponding to xmerl before 1.3.7, is affected is unknown.
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Upgrade
Upgrade to a fixed release to a version that resolves this vulnerability.
Fixed in 27.3.4.20 - Upgrade
Upgrade to a fixed release to a version that resolves this vulnerability.
Fixed in 28.5.0.9 - Upgrade
Upgrade to a fixed release to a version that resolves this vulnerability.
Fixed in 29.1.3
Event History
Frequently Asked Questions
Who is realistically exposed to this issue?
Applications that pass attacker-controlled XML to xmerl_scan:string/1,2 or xmerl_scan:file/1,2 are exposed, because a supplied document can name an external DTD. The issue affects OTP 17.0 and later versions before OTP 27.3.4.20, OTP 28.5.0.9, and OTP 29.1.3.
Does disabling XML entity handling or validation prevent exploitation?
No. Fetching the external DTD occurs whether validation is enabled or not, and allow_entities=false does not prevent the DTD fetch; that option only controls <!ENTITY> declarations.
What must an attacker provide to trigger the denial of service?
The attacker needs to provide an XML document containing a DOCTYPE declaration with an external system identifier, such as file:///dev/zero. The default fetch behavior maps file: and absolute URIs to local paths and reads the referenced file in full, which can exhaust Erlang VM memory and prevent parsing from returning.
How can teams determine whether their deployment is affected?
Check the OTP or xmerl version and whether the application parses untrusted XML using xmerl_scan:string/1,2 or xmerl_scan:file/1,2 with default behavior. OTP versions before 17.0 have an unknown affected status.