CVE-2021-23899: Json sanitizer Arbitrary Code Injection Vulnerability

CRITICAL
Advisory Identifier: GHSA-mm8j-9x84-m9cv
CVSS 9.8
CWE-611
Published
Advisory Summary

CVE-2021-23899 is a CRITICAL (CVSS 9.8) arbitrary code injection vulnerability (CWE-611: Improper Restriction of XML External Entity Reference) affecting Json sanitizer libraries in the Maven ecosystem. The issue involves arbitrary code injection in json-sanitizer. Remediation is available by upgrading affected packages to version 1.2.2.

CVE-2021-23899 at a Glance

CVE Identifier CVE-2021-23899
GHSA Identifier GHSA-mm8j-9x84-m9cv
Severity CRITICAL
CVSS v3.1 Base Score 9.8
CWE Classification CWE-611: Improper Restriction of XML External Entity Reference
Affected Product Json sanitizer
Package Ecosystem Maven
Published Date
Last Updated

Security Impact

CVSS: 9.8

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H).

Attack Vector Network (AV:N)
Attack Complexity Low (AC:L)
Privileges Required None (PR:N)
User Interaction None (UI:N)
Scope Unchanged (S:U)
Confidentiality High (C:H)
Integrity High (I:H)
Availability High (A:H)

How to Fix CVE-2021-23899

To remediate this vulnerability, upgrade all affected Json sanitizer dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

com.mikesamuel:json-sanitizer fixed: 1.2.2
<dependency>
    <groupId>com.mikesamuel</groupId>
    <artifactId>json-sanitizer</artifactId>
    <version>1.2.2</version>
</dependency>
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

mvn dependency:tree -Dincludes=com.mikesamuel

How to Check if You Are Affected

To determine whether your Java application is affected by CVE-2021-23899, inspect your build dependencies using the Maven Dependency Plugin:

mvn dependency:tree -Dincludes=com.mikesamuel

Analyze the terminal output to locate any version of Json sanitizer in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 1.2.2), your application is affected.

Note: The mvn dependency:tree -Dincludes=com.mikesamuel command inspects the resolved dependency graph declared in your project's POM files; it does not perform automated security scanning or inspect runtime dynamic classpaths. Always verify runtime container classpaths and shaded JARs.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-611: Improper Restriction of XML External Entity Reference, where the product processes an xml document that can contain xml entities with uris that resolve to documents outside of the intended sphere of control, causing the product to embed incorrect documents into its output. In Json sanitizer, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

OWASP json-sanitizer before 1.2.2 may emit closing SCRIPT tags and CDATA section delimiters for crafted input. This allows an attacker to inject arbitrary HTML or XML into embedding documents.

CVE-2021-23899 Affected Json sanitizer Versions

1 component(s)
Fixed Versions:
1.2.2
Product / Package Ecosystem Affected Versions Fixed Version
com.mikesamuel:json-sanitizer
Maven
< 1.2.2
1.2.2

References

Frequently Asked Questions

What is CVE-2021-23899?
CVE-2021-23899 is a security vulnerability in Json sanitizer involving Arbitrary code injection in json-sanitizer under CWE-611: Improper Restriction of XML External Entity Reference.
Which Json sanitizer versions are affected?
Affected versions include releases prior to 1.2.2 across affected packages: com.mikesamuel:json-sanitizer.
What version fixes CVE-2021-23899?
Upgrading to 1.2.2 (or the latest patched release for your respective branch) resolves the vulnerability.
Is json-sanitizer affected?
Yes, com.mikesamuel:json-sanitizer is affected in releases prior to 1.2.2. Upgrade your dependency to 1.2.2 or later.
What is the CVSS score of CVE-2021-23899?
CVE-2021-23899 has a CVSS v3.1 base score of 9.8 (CRITICAL) with vector string CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H.
What CWE is associated with CVE-2021-23899?
CVE-2021-23899 is classified under CWE-611: Improper Restriction of XML External Entity Reference (The product processes an XML document that can contain XML entities with URIs that resolve to documents outside of the intended sphere of control, causing the product to embed incorrect documents into its output.).
How can I check Maven dependencies for CVE-2021-23899?
Run the dependency tree command: 'mvn dependency:tree -Dincludes=com.mikesamuel'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-mm8j-9x84-m9cv",
  "modified" : "2021-04-06T21:44:01Z",
  "published" : "2021-06-16T17:34:18Z",
  "aliases" : [ "CVE-2021-23899" ],
  "summary" : "Arbitrary code injection in json-sanitizer",
  "details" : "OWASP json-sanitizer before 1.2.2 may emit closing SCRIPT tags and CDATA section delimiters for crafted input. This allows an attacker to inject arbitrary HTML or XML into embedding documents.",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "Maven",
      "name" : "com.mikesamuel:json-sanitizer"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "1.2.2"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2021-23899"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/OWASP/json-sanitizer/commit/a37f594f7378a1c76b3283e0dab9e1ab1dc0247e"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/OWASP/json-sanitizer/compare/v1.2.1...v1.2.2"
  }, {
    "type" : "WEB",
    "url" : "https://groups.google.com/g/json-sanitizer-support/c/dAW1AeNMoA0"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-611" ],
    "severity" : "CRITICAL",
    "github_reviewed" : true,
    "github_reviewed_at" : "2021-04-06T21:44:01Z",
    "nvd_published_at" : "2021-01-13T16:15:00Z"
  }
}