CVE-2021-39194: Kaml Improper Handling Of Missing Values Vulnerability

MODERATE
Advisory Identifier: GHSA-fmm9-3gv8-58f4
CVSS 4.3
CWE-230 CWE-835
Published
Advisory Summary

CVE-2021-39194 is a MODERATE (CVSS 4.3) improper handling of missing values vulnerability (CWE-230: Improper Handling of Missing Values) affecting Kaml libraries in the Maven ecosystem. The issue involves improper handling of missing values in kaml. Remediation is available by upgrading affected packages to version 0.35.3.

CVE-2021-39194 at a Glance

CVE Identifier CVE-2021-39194
GHSA Identifier GHSA-fmm9-3gv8-58f4
Severity MODERATE
CVSS v3.1 Base Score 4.3
CWE Classification CWE-230: Improper Handling of Missing Values
Affected Product Kaml
Package Ecosystem Maven
Published Date
Last Updated

Security Impact

CVSS: 4.3

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

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

How to Fix CVE-2021-39194

To remediate this vulnerability, upgrade all affected Kaml 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.charleskorn.kaml:kaml fixed: 0.35.3
<dependency>
    <groupId>com.charleskorn.kaml</groupId>
    <artifactId>kaml</artifactId>
    <version>0.35.3</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.charleskorn.kaml

How to Check if You Are Affected

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

mvn dependency:tree -Dincludes=com.charleskorn.kaml

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

Note: The mvn dependency:tree -Dincludes=com.charleskorn.kaml 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-230: Improper Handling of Missing Values, where the product does not handle or incorrectly handles when a parameter, field, or argument name is specified, but the associated value is missing, i.e. it is empty, blank, or null. In Kaml, 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

### Impact Attackers that could provide arbitrary YAML input to an application that uses kaml could cause the application to endlessly loop while parsing the input. This could result in resource starvation and denial of service. This only affects applications that use polymorphic serialization with the default tagged polymorphism style. Applications using the property polymorphism style are not affected. YAML input for a polymorphic type that provided a tag but no value for the object would trigger the issue, for example: ```yaml !<x> ``` The following is a sample application that demonstrates this issue: ```kotlin import com.charleskorn.kaml.Yaml import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable @Serializable private sealed class K { @Serializable @SerialName("x") data class X( val property: String? = null, ) : K() } const val s = """ !<x> """ fun main() { println("Started.") val result = Yaml.default.decodeFromString(K.serializer(), s) println("Finished, result is $result") } ``` On vulnerable versions of kaml, the `decodeFromString()` operation hangs and never returns. ### Patches Version 0.35.3 or later contain the fix for this issue.

CVE-2021-39194 Affected Kaml Versions

1 component(s)
Fixed Versions:
0.35.3
Product / Package Ecosystem Affected Versions Fixed Version
com.charleskorn.kaml:kaml
Maven
< 0.35.3
0.35.3

References

Frequently Asked Questions

What is CVE-2021-39194?
CVE-2021-39194 is a security vulnerability in Kaml involving Improper Handling of Missing Values in kaml under CWE-230: Improper Handling of Missing Values.
Which Kaml versions are affected?
Affected versions include releases prior to 0.35.3 across affected packages: com.charleskorn.kaml:kaml.
What version fixes CVE-2021-39194?
Upgrading to 0.35.3 (or the latest patched release for your respective branch) resolves the vulnerability.
Is kaml affected?
Yes, com.charleskorn.kaml:kaml is affected in releases prior to 0.35.3. Upgrade your dependency to 0.35.3 or later.
What is the CVSS score of CVE-2021-39194?
CVE-2021-39194 has a CVSS v3.1 base score of 4.3 (MODERATE) with vector string CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:N/I:N/A:L.
What CWE is associated with CVE-2021-39194?
CVE-2021-39194 is classified under CWE-230: Improper Handling of Missing Values (The product does not handle or incorrectly handles when a parameter, field, or argument name is specified, but the associated value is missing, i.e. it is empty, blank, or null.).
How can I check Maven dependencies for CVE-2021-39194?
Run the dependency tree command: 'mvn dependency:tree -Dincludes=com.charleskorn.kaml'. 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-fmm9-3gv8-58f4",
  "modified" : "2021-09-08T14:47:32Z",
  "published" : "2021-09-07T23:08:40Z",
  "aliases" : [ "CVE-2021-39194" ],
  "summary" : "Improper Handling of Missing Values in kaml",
  "details" : "### Impact\nAttackers that could provide arbitrary YAML input to an application that uses kaml could cause the application to endlessly loop while parsing the input. This could result in resource starvation and denial of service. \n\nThis only affects applications that use polymorphic serialization with the default tagged polymorphism style. Applications using the property polymorphism style are not affected.\n\nYAML input for a polymorphic type that provided a tag but no value for the object would trigger the issue, for example:\n\n```yaml\n!<x>\n```\n\nThe following is a sample application that demonstrates this issue:\n\n```kotlin\nimport com.charleskorn.kaml.Yaml\nimport kotlinx.serialization.SerialName\nimport kotlinx.serialization.Serializable\n\n@Serializable\nprivate sealed class K {\n    @Serializable\n    @SerialName(\"x\")\n    data class X(\n        val property: String? = null,\n    ) : K()\n}\n\nconst val s = \"\"\"\n!<x>\n\"\"\"\n\nfun main() {\n    println(\"Started.\")\n    val result = Yaml.default.decodeFromString(K.serializer(), s)\n    println(\"Finished, result is $result\")\n}\n```\n\nOn vulnerable versions of kaml, the `decodeFromString()` operation hangs and never returns. \n\n\n### Patches\nVersion 0.35.3 or later contain the fix for this issue.",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:N/I:N/A:L"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "Maven",
      "name" : "com.charleskorn.kaml:kaml"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "0.35.3"
      } ]
    } ],
    "database_specific" : {
      "last_known_affected_version_range" : "< 0.35.2"
    }
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/charleskorn/kaml/security/advisories/GHSA-fmm9-3gv8-58f4"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2021-39194"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/charleskorn/kaml/issues/179"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/charleskorn/kaml/commit/e18785d043fc6324c81e968aae9764b4b060bc6a"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/charleskorn/kaml"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-230", "CWE-835" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2021-09-07T18:02:13Z",
    "nvd_published_at" : "2021-09-07T20:15:00Z"
  }
}