CVE-2021-39194
JSON

4.3medium

Denial of service while parsing polymorphic input with tagged polymorphism style in kaml

Severity
4.3medium CVSS:3.1 by GitHub_M
Exploit likelihood
1.66% (higher than 77% of CVEs; EPSS, by FIRST)
Published
Last changed
Assigned by
GitHub_M
Also known as
GHSA-fmm9-3gv8-58f4

Description

kaml is an open source implementation of the YAML format with support for kotlinx.serialization. In affected versions 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. Version 0.35.3 or later contain the fix for this issue.

Affected

Product or packageVersionsReported by
charleskorn kaml< 0.35.2CVE List
com.charleskorn.kaml:kaml (Maven)before 0.35.3GitHub Advisory Database
kaml_project kamlbefore 0.35.3NVD

All scores

GitHub_M4.3medium CVSS:3.1CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:N/I:N/A:L
GitHub4.3medium CVSS:3.1CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:N/I:N/A:L
NVD6.5medium CVSS:3.1CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:N/I:N/A:H
NVD4.0medium CVSS:2.0AV:N/AC:L/Au:S/C:N/I:N/A:P

Classification

What each source says

CVE List

kaml is an open source implementation of the YAML format with support for kotlinx.serialization. In affected versions 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. Version 0.35.3 or later contain the fix for this issue.

GitHub Advisory Database
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:

!<x>

The following is a sample application that demonstrates this issue:

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.

NVD (es)

kaml es una implementación de código abierto del formato YAML con soporte para kotlinx.serialization. En las versiones afectadas, unos atacantes que pudieran proporcionar una entrada YAML arbitraria a una aplicación que usa kaml podría causar que la aplicación realice un bucle interminable mientras analiza la entrada. Esto podría resultar en una inanición de recursos y una denegación de servicio. Esto sólo afecta a las aplicaciones que usan una serialización polimórfica con el estilo de polimorfismo etiquetado predeterminado. Las aplicaciones que usan el estilo de polimorfismo de propiedades no están afectadas. La entrada de YAML para un tipo polimórfico que proporciona una etiqueta pero no un valor para el objeto desencadenaría el problema. La versión 0.35.3 o posterior contiene la corrección de este problema

References

Sources

SourceRecordLicence
CVE ListCVE-2021-39194 changed 2024-08-04CVE Terms of Use
GitHub Advisory DatabaseGHSA-fmm9-3gv8-58f4 changed 2026-07-08CC-BY-4.0
NVDCVE-2021-39194 changed 2026-06-17Public domain