GHSA-7gcf-g7xr-8hxj: serde_with: KeyValueMap serialization panics on empty sequence or map entries
The serde_with crate contains a vulnerability in its KeyValueMap serializer that causes a panic when serializing empty sequences or map entries. This occurs because the serializer incorrectly assumes each mapped element has at least one field or item and subtracts one from the length before validation. An attacker able to control serialized data using KeyValueMap can trigger a denial of service by causing the process to crash during serialization.
AI Analysis
Technical Summary
The KeyValueMap serializer in serde_with versions prior to 3.21.0 improperly handles empty inner sequences or map entries by preallocating a vector with a capacity of length minus one without verifying the presence of required key fields. This leads to a panic during serialization when an empty entry is encountered. The vulnerability can be triggered via serde_json::to_string or any Serde serializer that uses KeyValueMap, allowing an attacker controlling serialized data to cause a denial of service by crashing the process.
Potential Impact
A local attacker who can supply attacker-controlled data for serialization using the KeyValueMap serializer can cause the application to panic and terminate, resulting in a denial of service. There is no indication of privilege escalation, data disclosure, or remote code execution.
Mitigation Recommendations
No official patch or fix is currently confirmed. Users should check the vendor advisory for updates. Until a fix is available, avoid serializing untrusted or attacker-controlled data with KeyValueMap or implement input validation to ensure no empty sequences or map entries are serialized.
GHSA-7gcf-g7xr-8hxj: serde_with: KeyValueMap serialization panics on empty sequence or map entries
Description
The serde_with crate contains a vulnerability in its KeyValueMap serializer that causes a panic when serializing empty sequences or map entries. This occurs because the serializer incorrectly assumes each mapped element has at least one field or item and subtracts one from the length before validation. An attacker able to control serialized data using KeyValueMap can trigger a denial of service by causing the process to crash during serialization.
CVSS v4.0
Affected software
Run on your own infrastructure? Check whether these packages are installed with threat-finder — our free open-source scanner.
Weaknesses
AI-Powered Analysis
Machine-generated threat intelligence
Technical Analysis
The KeyValueMap serializer in serde_with versions prior to 3.21.0 improperly handles empty inner sequences or map entries by preallocating a vector with a capacity of length minus one without verifying the presence of required key fields. This leads to a panic during serialization when an empty entry is encountered. The vulnerability can be triggered via serde_json::to_string or any Serde serializer that uses KeyValueMap, allowing an attacker controlling serialized data to cause a denial of service by crashing the process.
Potential Impact
A local attacker who can supply attacker-controlled data for serialization using the KeyValueMap serializer can cause the application to panic and terminate, resulting in a denial of service. There is no indication of privilege escalation, data disclosure, or remote code execution.
Mitigation Recommendations
No official patch or fix is currently confirmed. Users should check the vendor advisory for updates. Until a fix is available, avoid serializing untrusted or attacker-controlled data with KeyValueMap or implement input validation to ensure no empty sequences or map entries are serialized.
Technical Details
- Gcve Source
- db.gcve.eu
- Osv Id
- GHSA-7gcf-g7xr-8hxj
- Osv Schema Version
- 1.4.0
- Aliases
- []
- 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: 07/16/2026, 10:49:31 UTC
Last updated: 07/17/2026, 03:39:46 UTC
Views: 4
Community Reviews
0 reviewsCrowdsource mitigation strategies, share intel context, and vote on the most helpful responses. Sign in to add your voice and help keep defenders ahead.
Want to contribute mitigation steps or threat intel context? Sign in or create an account to join the community discussion.
Actions
Updates to AI analysis require Pro Console access. Upgrade inside Console → Billing.
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
Check if your credentials are on the dark web
Instant breach scanning across billions of leaked records. Free tier available.