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 package | Versions | Reported by |
|---|---|---|
| charleskorn kaml | < 0.35.2 | CVE List |
| com.charleskorn.kaml:kaml (Maven) | before 0.35.3 | GitHub Advisory Database |
| kaml_project kaml | before 0.35.3 | NVD |
All scores
| GitHub_M | 4.3medium CVSS:3.1 | CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:N/I:N/A:L |
| GitHub | 4.3medium CVSS:3.1 | CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:N/I:N/A:L |
| NVD | 6.5medium CVSS:3.1 | CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:N/I:N/A:H |
| NVD | 4.0medium CVSS:2.0 | AV: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
| https://github.com/charleskorn/kaml/security/advisories/GHSA-fmm9-3gv8-58f4 | exploit, third-party-advisory, web | |
| https://github.com/charleskorn/kaml/issues/179 | exploit, patch, third-party-advisory, web | |
| https://github.com/charleskorn/kaml/commit/e18785d043fc6324c81e968aae9764b4b060bc6a | patch, third-party-advisory, web | |
| https://nvd.nist.gov/vuln/detail/CVE-2021-39194 | advisory | |
| https://github.com/charleskorn/kaml | web | |
Sources
| Source | Record | Licence |
|---|---|---|
| CVE List | CVE-2021-39194 changed 2024-08-04 | CVE Terms of Use |
| GitHub Advisory Database | GHSA-fmm9-3gv8-58f4 changed 2026-07-08 | CC-BY-4.0 |
| NVD | CVE-2021-39194 changed 2026-06-17 | Public domain |