Skip to main content

serde_with: KeyValueMap serialization panics on empty sequence or map entries

0
Medium
Published: 07/15/2026 (07/15/2026, 22:41:01 UTC)
Source: GCVE Database
Product: serde_with

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.

CVSS v4.0

Attack Vector
Local
Attack Complexity
Low
Attack Requirements
None
Privileges Required
None
User Interaction
None
Vuln. Confidentiality
None
Vuln. Integrity
None
Vuln. Availability
Low
Subsq. Confidentiality
None
Subsq. Integrity
None
Subsq. Availability
None
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

Affected software

crates.ioghsa
serde_with
Affected versions
<3.21.0

Run on your own infrastructure? Check whether these packages are installed with threat-finder — our free open-source scanner.

AI-Powered Analysis

Machine-generated threat intelligence

AILast updated: 09/17/2026, 20:05:10 UTC

Technical Analysis

The KeyValueMap serializer in serde_with versions >=2.3.0 and <3.21.0 assumes that each mapped element contains at least one field or item to serve as the map key. It preallocates a vector with capacity of length minus one before verifying this assumption. If an attacker supplies an empty inner sequence or map entry, this leads to a panic due to Vec::with_capacity being called with an invalid size. This vulnerability can be triggered via serialization through serde_json::to_string or other Serde serializers when using #[serde_as(as = "KeyValueMap<_>")]. The root cause is improper length validation before vector preallocation in key_value_map.rs at multiple source locations.

Potential Impact

An attacker who can supply attacker-controlled data for serialization through the KeyValueMap serializer can cause the process to panic and terminate, resulting in a denial of service. There is no indication of privilege escalation or code execution. The impact is limited to local denial of service via process crash during serialization.

Mitigation Recommendations

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.

Pro Console: star threats, build custom feeds, automate alerts via Slack, email & webhooks.Upgrade to Pro

Technical Details

Gcve Source
db.gcve.eu
Osv Id
GHSA-7gcf-g7xr-8hxj
Osv Schema Version
1.4.0
Ecosystems
["crates.io"]
Database Specific Severity
MODERATE
Cvss Version
4.0

Threat ID: 6a58b40568715ace43d67084

Added to database: 07/16/2026, 10:35:49 UTC

Last enriched: 09/17/2026, 20:05:10 UTC

Last updated: 10/03/2026, 01:47:44 UTC

Views: 134

Community Reviews

0 reviews

Crowdsource mitigation strategies, share intel context, and vote on the most helpful responses. Sign in to add your voice and help keep defenders ahead.

Sort by
Loading community insights…

Want to contribute mitigation steps or threat intel context? Sign in or create an account to join the community discussion.

Actions

PRO

Updates to AI analysis require Pro Console access. Upgrade inside Console → Billing.

Please log in to the Console to use AI analysis features.

Need more coverage?

Upgrade to Pro Console for AI refresh and higher limits.

For incident response and remediation, OffSeq services can help resolve threats faster.

Latest Threats

Breach by OffSeqOFFSEQFRIENDS — 25% OFF

Check if your credentials are on the dark web

Instant breach scanning across billions of leaked records. Free tier available.

Scan now
OffSeq TrainingCredly Certified

Lead Pen Test Professional

Technical5-day eLearningPECB Accredited
View courses