VYPR
High severityNVD Advisory· Published Oct 25, 2022· Updated Aug 3, 2024

Apache Batik prior to 1.16 allows RCE via scripting

CVE-2022-42890

Description

A vulnerability in Batik of Apache XML Graphics allows an attacker to run Java code from untrusted SVG via JavaScript. This issue affects Apache XML Graphics prior to 1.16. Users are recommended to upgrade to version 1.16.

AI Insight

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

Apache Batik before 1.16 allows arbitrary Java code execution via JavaScript in untrusted SVG files, leading to information disclosure or SSRF.

Vulnerability

Overview

CVE-2022-42890 is a security flaw in Apache Batik, part of the Apache XML Graphics project, that permits an attacker to execute arbitrary Java code from untrusted SVG files through embedded JavaScript. The root cause is that Batik's SVG rasterizer uses the Rhino JavaScript engine without restricting which Java classes can be accessed from scripts, allowing malicious SVG content to invoke arbitrary Java methods [1][2][4].

Exploitation

An attacker can exploit this vulnerability by crafting a malicious SVG file containing JavaScript that calls Java classes. No authentication is required; the victim only needs to process the SVG, for example by viewing it in a browser or converting it server-side. The attacker can then execute arbitrary Java code within the Batik process, potentially leading to information disclosure or server-side request forgery (SSRF) [1][4].

Impact

Successful exploitation can result in the disclosure of sensitive information, such as file contents or environment details, or allow the attacker to make network requests from the server (SSRF). The vulnerability is rated as Medium severity by both the Apache Security Team and NVD [3][4].

Mitigation

Users should upgrade to Apache Batik version 1.16 or later, which restricts the Java classes accessible from JavaScript. No workaround is available for earlier versions [1][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
org.apache.xmlgraphics:batik-bridgeMaven
< 1.161.16

Affected products

6

Patches

3
401aa8595f52

BATIK-1345: Restrict what java classes can be run thru rhino

https://github.com/apache/xmlgraphics-batikSimon SteinerOct 13, 2022via ghsa
1 file changed · +1 1
  • batik-script/src/main/java/org/apache/batik/script/rhino/RhinoClassShutter.java+1 1 modified
    @@ -59,7 +59,7 @@ public void test(String cls) {
          * Returns whether the given class is visible to scripts.
          */
         public boolean visibleToScripts(String fullClassName) {
    -        if (fullClassName.startsWith("java.") && !WHITELIST.contains(fullClassName) && !fullClassName.endsWith("Permission")) {
    +        if (!WHITELIST.contains(fullClassName) && !fullClassName.endsWith("Permission") && !fullClassName.startsWith("org.")) {
                 return false;
             }
     
    
eada57c716a2

BATIK-1345: Restrict what java classes can be run thru rhino

https://github.com/apache/xmlgraphics-batikSimon SteinerOct 12, 2022via ghsa
1 file changed · +29 0
  • batik-test-old/src/test/java/org/apache/batik/script/rhino/RhinoClassShutterTest.java+29 0 added
    @@ -0,0 +1,29 @@
    +/*
    +
    +   Licensed to the Apache Software Foundation (ASF) under one or more
    +   contributor license agreements.  See the NOTICE file distributed with
    +   this work for additional information regarding copyright ownership.
    +   The ASF licenses this file to You under the Apache License, Version 2.0
    +   (the "License"); you may not use this file except in compliance with
    +   the License.  You may obtain a copy of the License at
    +
    +       http://www.apache.org/licenses/LICENSE-2.0
    +
    +   Unless required by applicable law or agreed to in writing, software
    +   distributed under the License is distributed on an "AS IS" BASIS,
    +   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    +   See the License for the specific language governing permissions and
    +   limitations under the License.
    +
    + */
    +package org.apache.batik.script.rhino;
    +
    +import org.junit.Assert;
    +import org.junit.Test;
    +
    +public class RhinoClassShutterTest {
    +    @Test
    +    public void testImports() {
    +        Assert.assertFalse(new RhinoClassShutter().visibleToScripts("java.lang.Runtime"));
    +    }
    +}
    
52f7a1ad6e31

BATIK-1345: Restrict what java classes can be run thru rhino

https://github.com/apache/xmlgraphics-batikSimon SteinerOct 12, 2022via ghsa
1 file changed · +8 0
  • batik-script/src/main/java/org/apache/batik/script/rhino/RhinoClassShutter.java+8 0 modified
    @@ -20,13 +20,17 @@ Licensed to the Apache Software Foundation (ASF) under one or more
     
     import org.mozilla.javascript.ClassShutter;
     
    +import java.util.Arrays;
    +import java.util.List;
    +
     /**
      * Class shutter that restricts access to Batik internals from script.
      *
      * @author <a href="mailto:deweese@apache.org">Thomas DeWeese</a>
      * @version $Id$
      */
     public class RhinoClassShutter implements ClassShutter {
    +    private static final List<String> WHITELIST = Arrays.asList("java.io.PrintStream", "java.lang.System", "java.net.URL");
     
         /*
         public RhinoClassShutter() {
    @@ -55,6 +59,10 @@ public void test(String cls) {
          * Returns whether the given class is visible to scripts.
          */
         public boolean visibleToScripts(String fullClassName) {
    +        if (fullClassName.startsWith("java.") && !WHITELIST.contains(fullClassName) && !fullClassName.endsWith("Permission")) {
    +            return false;
    +        }
    +
             // Don't let them mess with script engine's internals.
             if (fullClassName.startsWith("org.mozilla.javascript"))
                 return false;
    

Vulnerability mechanics

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

References

13

News mentions

0

No linked articles in our index yet.