MODERATE 4.3

CVE-2021-39194

Improper Handling of Missing Values in kaml

Description

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.

Affected Maven artifacts (1)

ArtifactAffected versionsFixed in
com.charleskorn.kaml » kaml
< 0.35.3
0.35.3

Blast radius

1affected artifacts
41affected versions
272dependent artifacts (est.)
6,023dependent versions

36% of the dependent artifacts (99) still pull an affected version in their latest release.

DepthDependent versions
Direct
186
2 hops
743
3 hops
460
4 hops
1,329
5 hops
2,183
6 hops
1,122

Most used dependents

Computed from the dependency graph of build 20261126.1706 (compile and runtime scopes, nearest version wins). Exclusions and dependency management in consuming projects are not applied, so dependents are potentially affected. When several artifacts are affected, a dependent version that pulls more than one of them is counted once per artifact.