CVE-2021-23899: Json sanitizer Arbitrary Code Injection Vulnerability
CRITICALCVE-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
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).
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.
<dependency>
<groupId>com.mikesamuel</groupId>
<artifactId>json-sanitizer</artifactId>
<version>1.2.2</version>
</dependency>
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
CVE-2021-23899 Affected Json sanitizer Versions
1 component(s)| 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?
Which Json sanitizer versions are affected?
What version fixes CVE-2021-23899?
Is json-sanitizer affected?
What is the CVSS score of CVE-2021-23899?
What CWE is associated with CVE-2021-23899?
How can I check Maven dependencies for CVE-2021-23899?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"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"
}
}