Vulnerabilities In Apache Batik Default Security Controls – SSRF And RCE Through Remote Class Loading
The default security controls in Apache Batik could be bypassed because the JAR protocol returns a null host, allowing an attacker to load remote resources and scripts. This enabled SSRF through the image tag and, with non-default script execution enabled, remote code execution via remote JAR loading.
Published on zerodayinitiative.com
I stumbled upon the Apache Batik library while researching other Java-based products. It immediately caught my attention, as this library parses Scalable Vector Graphics (SVG) files and transforms them into different raster graphics formats (i.e., PNG, PDF, or JPEG).
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the security check compared hosts using Java's URL.getHost, which returns null for JAR URLs, so a JAR URL was treated as local and allowed.
Impact
An attacker could make the server perform HTTP GET requests or NTLM authentication to attacker-controlled hosts, and if script execution was enabled, could achieve remote code execution; the SSRF and script-security bypasses were fixed in Batik 1.15, but Rhino script execution remains a risk when enabled.
What the attacker needed
SVG input accepted by Batik; Script execution enabled for RCE; Non-default allowed script types for JAR RCE
The fix
The default security control bypasses were fixed in Batik 1.15; users should also avoid enabling script execution and apply the strictest controls possible.
How it was found
- Create an SVG that references a remote resource or JAR using the jar: protocol.
- Submit the SVG to an endpoint that converts it with the Batik transcoder.
- The security check sees a null host and allows the remote load.
- For RCE, enable script execution and allow the application/java-archive script type.
- The remote JAR is loaded and its EventListenerInitializer code runs.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
Apache Batik is a Java library that turns SVG images into other formats like PNG or JPEG. It has safety checks to stop an SVG from fetching files from other servers or running code, but a flaw in how it checks the address of a JAR file let an attacker slip past those checks. That meant a malicious SVG could make the server fetch a remote file or, if scripting was turned on, run the attacker's Java code.
What is SSRF?
The server can be made to fetch an address the attacker chooses, reaching internal services, cloud metadata or other customers' data.