VYPR
High severityNVD Advisory· Published Oct 25, 2022· Updated Feb 25, 2026

Apache Batik prior to 1.16 allows RCE when loading untrusted SVG input

CVE-2022-41704

Description

A vulnerability in Batik of Apache XML Graphics allows an attacker to run untrusted Java code from an SVG. This issue affects Apache XML Graphics prior to 1.16. It is recommended to update to version 1.16.

AI Insight

LLM-synthesized narrative grounded in this CVE's description and references.

Apache Batik versions before 1.16 allow arbitrary code execution via untrusted Java code embedded in SVG files.

Vulnerability

Description

CVE-2022-41704 is a vulnerability in Apache XML Graphics Batik that allows an attacker to execute untrusted Java code from an SVG file due to the lack of restrictions on loading jar files embedded within SVG content. The Apache XML Graphics project describes this as an information disclosure vulnerability, but the ability to run arbitrary code extends the potential impact to full remote code execution [1][4]. The issue affects all Batik versions from 1.0 up to and including 1.15 [4].

Attack

Vector and Exploitation

The attack vector relies on Batik's parser loading untrusted Java classes from jar archives that are specified within an SVG file. An attacker can craft a malicious SVG that references an external or embedded jar, which is then processed by Batik when the SVG is rendered or converted. No authentication is required beyond the victim opening the SVG in an application that uses Batik (e.g., a web browser or document converter) [2][4]. The vulnerability is classified as medium severity by the Apache Software Foundation [4].

Impact

Successful exploitation could allow an attacker to execute arbitrary Java code within the context of the application using Batik, leading to information disclosure, data manipulation, or further system compromise. Batik is used in many enterprise applications for SVG rendering and conversion, increasing the potential reach of this attack [1][3][4].

Mitigation

Users should upgrade to Apache Batik 1.16 or later, which blocks the loading of jars by default. The fix was released on the same day the CVE was made public [3][4]. No workarounds are documented for older versions. Batik 1.16 also addresses several related SSRF vulnerabilities, making it a critical security update for all affected deployments [3].

AI Insight generated on May 21, 2026. Synthesized from this CVE's description and the cited reference URLs; citations are validated against the source bundle.

Affected packages

Versions sourced from the GitHub Security Advisory.

PackageAffected versionsPatched versions
org.apache.xmlgraphics:batikMaven
< 1.161.16

Affected products

5

Patches

1
905f368b50c2

BATIK-1338: Block loading jar inside svg

https://github.com/apache/xmlgraphics-batikSimon SteinerSep 28, 2022via ghsa
2 files changed · +20 1
  • batik-bridge/src/main/java/org/apache/batik/bridge/DefaultScriptSecurity.java+3 1 modified
    @@ -20,6 +20,8 @@ Licensed to the Apache Software Foundation (ASF) under one or more
     
     import org.apache.batik.util.ParsedURL;
     
    +import static org.apache.batik.util.SVGConstants.SVG_SCRIPT_TYPE_JAVA;
    +
     /**
      * Default implementation for the <code>ScriptSecurity</code> interface.
      * It allows all types of scripts to be loaded, but only if they
    @@ -76,7 +78,7 @@ public DefaultScriptSecurity(String scriptType,
                                      ParsedURL docURL){
             // Make sure that the archives comes from the same host
             // as the document itself
    -        if (docURL == null) {
    +        if (docURL == null || SVG_SCRIPT_TYPE_JAVA.equals(scriptType)) {
                 se = new SecurityException
                     (Messages.formatMessage(ERROR_CANNOT_ACCESS_DOCUMENT_URL,
                                             new Object[]{scriptURL}));
    
  • batik-test-old/src/test/java/org/apache/batik/bridge/DefaultScriptSecurityTestCase.java+17 0 modified
    @@ -22,6 +22,8 @@ Licensed to the Apache Software Foundation (ASF) under one or more
     import org.junit.Assert;
     import org.junit.Test;
     
    +import static org.apache.batik.util.SVGConstants.SVG_SCRIPT_TYPE_JAVA;
    +
     public class DefaultScriptSecurityTestCase {
         @Test
         public void testUrls() {
    @@ -37,4 +39,19 @@ public void testUrls() {
                     "which comes from different location than the document itself. This is not allowed with the current " +
                     "security settings and that script will not be loaded.");
         }
    +
    +    @Test
    +    public void testJarFile() {
    +        ParsedURL docUrl = new ParsedURL("");
    +        ParsedURL scriptUrl = new ParsedURL("poc.jar");
    +        String ex = "";
    +        try {
    +            new DefaultScriptSecurity(SVG_SCRIPT_TYPE_JAVA, scriptUrl, docUrl).checkLoadScript();
    +        } catch (SecurityException e) {
    +            ex = e.getMessage();
    +        }
    +        Assert.assertEquals(ex, "Could not access the current document URL when trying to load script file " +
    +                "file:poc.jar. Script will not be loaded as it is not possible to verify it comes from the same location " +
    +                "as the document.");
    +    }
     }
    

Vulnerability mechanics

Generated on May 9, 2026. Inputs: CWE entries + fix-commit diffs from this CVE's patches. Citations validated against bundle.

References

11

News mentions

0

No linked articles in our index yet.