http4k has a potential XXE (XML External Entity Injection) vulnerability
Date: 2024-12
Affected: maven/org.http4k:http4k-format-xml
Attack vector: deserialization
Category: vulnerability-disclosure
Severity: Critical
CVE: CVE-2024-55875
CWE: CWE-200
CWE-611
CWE-918
CVSS: 9.8 (CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H)

### Summary _Short summary of the problem. Make the impact and severity as clear as possible. For example: An unsafe deserialization vulnerability allows any unauthenticated user to execute arbitrary code on the server._ There is a potential XXE(XML External Entity Injection) vulnerability when http4k handling malicious XML contents within requests, which might allow attackers to read local sensitive information on server, trigger Server-side Request Forgery and even execute code under some circumstances. ### Details _Give all details on the vulnerability. Pointing to the incriminated source code is very helpful for the maintainer._ https://github.com/http4k/http4k/blob/25696dff2d90206cc1da42f42a1a8dbcdbcdf18c/core/format/xml/src/main/kotlin/org/http4k/format/Xml.kt#L42-L46 XML contents is parsed with DocumentBuilder without security settings on or external entity enabled ### PoC _Complete instructions, including specific configuration details, to reproduce the vulnerability._ #### Example Vulnerable server code: ``` import org.http4k.core.* import org.http4k.format.Xml.xml import org.http4k.server.Netty import org.http4k.server.asServer import org.w3c.dom.Document fun main() { val xmlLens = Body.xml().toLens() // Create an HTTP handler val app: HttpHandler = { request -> try { // Parse the incoming XML payload to a Document object val xmlDocument: Document = xmlLens(request) // Extract root element name or other


Mitigations:

Architectural layers (MAESTRO):