Skip to main content
VulnerabilityPublished Updated

serde_with: KeyValueMap serialization panics on empty sequence or map entries

Affects serde_withSource GCVE Database

0

CVSS 5.1 Medium : upgrade to 3.21.0 when convenient.

Data as of 17 Sep 2026, 20:05 UTC

CVSS 4.0 base score
5.1Medium
How severe the flaw is on the 0–10 CVSS scale.
Patch
Available – fixed in 3.21.0
CVSS:4.0/AV:L/AC:L/AT:N/PR:N/UI:N/VC:N/VI:N/VA:L/SC:N/SI:N/SA:N

What to do

Upgrade serde_with to 3.21.0.

Affected software

ProductAffectedFixed in
crates.ioserde_withAffected
  • <3.21.0
Fixed in
  • 3.21.0

Check your own hosts for these packages with threat-finder (opens in a new tab), our free open-source scanner.

AI-suggested

A patch is available for this vulnerability. Users of serde_with should upgrade to version 3.21.0 or later where this issue is fixed. Until patched, avoid serializing attacker-controlled data with KeyValueMap or implement input validation to prevent empty sequences or map entries. No vendor advisory content contradicts this guidance.

Description

The serde_with crate's KeyValueMap serializer has a flaw where it panics when serializing an empty sequence or map entry. This occurs because the serializer incorrectly assumes each mapped element has at least one key field and subtracts one from the length before validation, leading to a panic on empty entries. An attacker able to control serialized data can cause a denial of service by crashing the process during serialization.

References

Community reviews

Loading reviews…