serde_with: KeyValueMap serialization panics on empty sequence or map entries
Affects serde_withSource GCVE Database
CVSS 5.1 Medium : upgrade to 3.21.0 when convenient.
Data as of 17 Sep 2026, 20:05 UTC
- 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:NWhat to do
Upgrade serde_with to 3.21.0.
Affected software
| Product | Affected | Fixed in |
|---|---|---|
| crates.ioserde_with | Affected
| Fixed in
|
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
- github.com/jonasbb/serde_with/security/advisories/GHSA-7gcf-g7xr-8hxj (opens in a new tab)
- github.com/jonasbb/serde_with/pull/966 (opens in a new tab)
- github.com/jonasbb/serde_with/commit/c8a1d820ea25df01692b367058d587343e199389 (opens in a new tab)
- github.com/jonasbb/serde_with (opens in a new tab)
- github.com/jonasbb/serde_with/releases/tag/v3.21.0 (opens in a new tab)
- github.com/jonasbb/serde_with/compare/v2.2.0...v2.3.0 (opens in a new tab)