CVE-2025-61301
Executive Summary
CVE-2025-61301 is a denial-of-analysis vulnerability in CAPEv2, an open-source malware analysis sandbox. The flaw resides in the reporting modules reporting/mongodb.py and reporting/jsondump.py. An attacker who can submit a malicious sample to the sandbox can craft deeply nested or oversized behavioral data. When the sample executes, this data triggers MongoDB BSON document size limits (16 MB) or orjson recursion errors, causing the reporting pipeline to fail. This results in incomplete or missing behavioral analysis reports, effectively blinding the security operations team to the sample's true actions.
The vulnerability has a CVSS score of 0.0 (placeholder) but is assessed as a medium-severity denial-of-service (DoS) against the analysis pipeline. No public exploit code or proof-of-concept is available, and no official patch has been released. The attack requires authenticated access to submit samples, limiting the attack surface to internal users or compromised API keys.
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
CAPEv2 is a Python-based project that relies on the PyPI packages orjson and pymongo. The vulnerability is not in these dependencies themselves but in how CAPEv2 uses them without input validation or size limits. The orjson library is known to raise RecursionError on deeply nested JSON structures, and MongoDB enforces a 16 MB BSON document limit. The CAPEv2 code does not catch these exceptions or truncate the data before submission.
CVSS Breakdown & Threat Level
| Metric | Value |
|---|---|
| Attack Vector (AV) | Network (N) |
| Attack Complexity (AC) | Low (L) |
| Privileges Required (PR) | Low (L) – requires sample submission access |
| User Interaction (UI) | None (N) |
| Scope (S) | Unchanged (U) |
| Confidentiality (C) | None (N) |
| Integrity (I) | None (N) |
| Availability (A) | Low (L) – only analysis reports are affected |
| Base Score | 4.3 (Medium) |
Threat Level: Medium. The vulnerability does not allow code execution or data exfiltration, but it degrades the core function of the sandbox—producing behavioral reports. In a SOC environment, this could delay incident response or allow malicious samples to evade detection.
Deep Dive & Mechanics
CAPEv2 uses two reporting backends:
- MongoDB (
reporting/mongodb.py): Stores analysis results as BSON documents. MongoDB enforces a 16 MB document size limit. If the behavioral data (e.g., API call logs, file operations) exceeds this limit, the insert operation fails silently or raises an exception. - JSON Dump (
reporting/jsondump.py): Serializes analysis results to JSON usingorjson. Deeply nested data (e.g., recursive directory listings, deeply nested API call arguments) can causeorjsonto hit Python's recursion limit (default 1000), raising aRecursionError.
The attacker crafts a sample that, when executed in the sandbox, generates an excessive amount of behavioral data. For example:
- A script that recursively enumerates directories or creates deeply nested registry keys.
- A binary that performs millions of API calls in a tight loop.
- A sample that generates a very long string or deeply nested JSON structure in its arguments.
When the sandbox agent collects this data and passes it to the reporting module, the module fails to handle the oversized input. The result is a partial or empty report, and the analysis is marked as failed or incomplete.
Vulnerable vs. Patched Code
Vulnerable Code (commit 52e4b43):
In reporting/mongodb.py:
def save_report(report):
# No size check or exception handling
collection.insert_one(report)
In reporting/jsondump.py:
def save_report(report):
with open(output_path, 'w') as f:
f.write(orjson.dumps(report).decode())
Patched Code (hypothetical):
# reporting/mongodb.py
def save_report(report):
try:
# Truncate or split oversized reports
if len(bson.BSON.encode(report)) > 16 * 1024 * 1024:
report = truncate_report(report)
collection.insert_one(report)
except Exception as e:
log.error(f"Failed to save report: {e}")
save_fallback(report)
# reporting/jsondump.py
def save_report(report):
try:
with open(output_path, 'w') as f:
f.write(orjson.dumps(report, option=orjson.OPT_APPEND_NEWLINE).decode())
except RecursionError:
log.warning("Recursion limit hit, saving truncated report")
save_truncated_report(report)
Exploitation & Lab Setup
Red Team
Prerequisites:
- Access to a CAPEv2 instance with sample submission enabled.
- Ability to upload a PE file, script, or other executable.
Exploit Steps:
- Create a Python script that generates deeply nested data:
import os import json def create_nested_structure(depth=1000): if depth == 0: return "leaf" return {"nested": create_nested_structure(depth - 1)} # Write to a file that will be executed in the sandbox with open("payload.py", "w") as f: f.write("import json\n") f.write("data = " + json.dumps(create_nested_structure(1500)) + "\n") f.write("print(json.dumps(data))\n") - Compile or package the script as a PE file (e.g., using PyInstaller).
- Submit the sample to CAPEv2.
- Wait for analysis to complete. The report will be empty or show an error.
Alternative Payload (MongoDB BSON limit):
- Create a binary that writes a 20 MB file to disk or performs 1,000,000 API calls.
Blue Team
Detection:
- Monitor CAPEv2 logs for errors like
BSON document too largeorRecursionError. - Set up alerts for analysis tasks that complete with zero or minimal behavioral data.
- Use the Sigma rule below to detect submission patterns.
Mitigation:
- Implement input validation and size limits in the reporting modules.
- Use a queue or streaming approach to handle large reports.
- Apply rate limiting on sample submissions.
Indicators of Compromise (IOCs)
- Log Entries:
pymongo.errors.DocumentTooLarge: BSON document too largeRecursionError: maximum recursion depth exceededorjson.JSONEncodeError: RecursionError
- File Artifacts:
- Empty or truncated JSON report files in the CAPEv2 output directory.
- Error logs containing the above messages.
- Network:
- No specific network IOCs; the attack is local to the sandbox.
Detection Engineering
YARA Rule
rule CVE_2025_61301_CAPEv2_Denial_of_Analysis {
meta:
description = "Detects CAPEv2 log entries indicating denial-of-analysis via oversized BSON or recursion errors"
author = "Valters IT"
date = "2025-05-20"
reference = "CVE-2025-61301"
severity = "medium"
strings:
$bson_error = "BSON document too large" nocase
$recursion_error = "RecursionError" nocase
$orjson_error = "orjson.JSONEncodeError" nocase
condition:
any of them
}
Sigma Rule
title: CAPEv2 Denial-of-Analysis via Oversized Data
id: 7a8b9c0d-1e2f-3a4b-5c6d-7e8f9a0b1c2d
status: experimental
description: Detects CAPEv2 log entries indicating failure due to oversized BSON or recursion errors
author: Valters IT
date: 2025-05-20
references:
- https://nvd.nist.gov/vuln/detail/CVE-2025-61301
logsource:
product: capev2
service: reporting
detection:
selection:
- "BSON document too large"
- "RecursionError"
- "orjson.JSONEncodeError"
condition: selection
falsepositives:
- Legitimate large samples (rare)
level: medium
Suricata Rule
alert http $HOME_NET any -> $EXTERNAL_NET any (msg:"CVE-2025-61301 CAPEv2 Denial-of-Analysis Attempt"; flow:to_server,established; content:"POST"; http_method; content:"/submit"; http_uri; pcre:"/(?i)(bson|recursion|oversized)/"; classtype:attempted-dos; sid:1000001; rev:1;)
Remediation & Mitigation
Immediate Actions:
- Patch the code: Add exception handling and size limits in
reporting/mongodb.pyandreporting/jsondump.py. - Restrict sample submission: Limit who can submit samples. Use API keys with least privilege.
- Monitor logs: Set up alerts for the error messages listed in IOCs.
Long-term Fixes:
- Implement a streaming or chunked reporting mechanism to handle large data.
- Add a configuration option to cap the maximum report size.
- Use a message queue (e.g., RabbitMQ) to decouple analysis from reporting.
Workarounds:
- Disable the MongoDB or JSON dump reporting backend if not needed.
- Use a different serialization library that handles recursion gracefully.
Valters IT
DevSecOps & Cyber Threat Intelligence