Back to Blog
medium SEVERITY9 min read

Resource Exhaustion via Unchecked File Imports: How Missing Limits Create DoS Vulnerabilities

A medium-severity vulnerability in a file transfer receiver allowed attackers to exhaust server resources by sending maliciously crafted import files with no size limits, no JSON depth restrictions, and millions of entries loaded directly into memory. The fix introduces explicit input validation guards that reject unauthenticated or malformed requests before any disk or network operations begin. Understanding this class of vulnerability is essential for any developer building file ingestion pipe

O
By Orbis AppSec
•Technically reviewed by Anupam Mediratta•Published May 18, 2026•Reviewed June 3, 2026

Answer Summary

Resource exhaustion via unchecked file imports (CWE-770) is a denial-of-service vulnerability where missing input validation allows attackers to upload files with no size limits or JSON depth restrictions, causing the server to load millions of entries into memory and exhaust resources. The fix implements explicit validation guards that reject unauthenticated requests and enforce strict limits on file size, JSON nesting depth, and entry count before processing begins.

Vulnerability at a Glance

cweCWE-770 (Allocation of Resources Without Limits or Throttling)
fixImplement authentication checks, size limits, JSON depth restrictions, and entry count validation
riskDenial of service, server unavailability, memory exhaustion
languageMulti-language (affects any file import handler)
root causeMissing input validation and resource limits on file imports
vulnerabilityResource Exhaustion via Unchecked File Imports (DoS)

Introduction

Imagine you've built a file transfer feature. It works great in testing — files come in, get parsed, and everything runs smoothly. But what happens when someone sends a JSON file with 10 million entries? Or a deeply nested JSON structure hundreds of levels deep? Or a file that's several gigabytes in size?

If your code doesn't answer those questions before it starts processing, you may be sitting on a Denial-of-Service (DoS) time bomb.

This post breaks down a real medium-severity vulnerability discovered in src/transfer/receiver.rs — a file import handler that lacked resource limits and input validation. We'll explore how it could be exploited, what the fix looks like, and how you can prevent similar issues in your own code.


The Vulnerability Explained

What Went Wrong

The file import functionality in receiver.rs had three interconnected problems:

  1. No file size limits — Files were loaded entirely into memory without any size check. A 4 GB file? Into RAM it goes.
  2. No JSON depth limits — JSON was parsed without restricting nesting depth. A deeply recursive structure can cause a parser to blow its stack or consume exponential memory.
  3. No entry count limits — Files with millions of top-level entries were processed without any cap.

In addition, the receiver began processing file data immediately upon connection, without verifying the peer's identity. Any connecting party was treated as a trusted peer — no authentication handshake, no public key verification, no pre-shared key mechanism.

The Technical Picture

Here's a simplified mental model of what the vulnerable code flow looked like:

// VULNERABLE: No size check, no depth limit, no authentication
async fn receive_file_from_request(
    request: IncomingRequest,
    sender_pk: &[u8],
) -> Result<(), FenvoyError> {
    let filename = sanitize_filename(&request.filename);

    // ❌ No check: Is sender_pk valid or non-empty?
    // ❌ No check: How large is this file?
    // ❌ No check: Is this JSON nested 10,000 levels deep?

    let raw_bytes = read_entire_file(&request).await?;   // Loads everything into memory
    let parsed: Value = serde_json::from_slice(&raw_bytes)?; // Parses without depth guard

    process_entries(parsed).await?;
    Ok(())
}

The function trusts everything it receives. It doesn't ask who is sending, how big the payload is, or how complex the structure is.

How Could It Be Exploited?

An attacker doesn't need sophisticated tools to exploit this. Here are three concrete attack scenarios:

Scenario 1: The Giant File Attack

# Attacker generates a 10 GB file of valid-looking JSON
python3 -c "
import json, sys
data = {'entries': ['x' * 1000] * 10_000_000}
json.dump(data, sys.stdout)
" > evil_import.json

# Sends it to the receiver endpoint
curl -X POST https://target/transfer/receive \
     --data-binary @evil_import.json

The server attempts to load 10 GB into RAM. If it doesn't OOM-kill first, it will grind to a halt.

Scenario 2: The Deep Nesting Attack (JSON Bomb)

# Generate deeply nested JSON — 100,000 levels deep
nested = "x"
for _ in range(100_000):
    nested = f'{{"a": {nested}}}'

with open("deep_nest.json", "w") as f:
    f.write(nested)

Many JSON parsers recurse into nested structures. At sufficient depth, this causes stack overflow or exponential memory allocation — crashing the process or making it unresponsive.

Scenario 3: The Million Entries Attack

# A flat JSON array with 50 million tiny entries
import json
data = list(range(50_000_000))
with open("million_entries.json", "w") as f:
    json.dump(data, f)

Even if each entry is small, allocating and iterating 50 million objects can consume gigabytes of heap memory and saturate the CPU for minutes.

Real-World Impact

Attack Vector Potential Impact
Oversized file upload Memory exhaustion, OOM crash
Deeply nested JSON Stack overflow, process crash
Millions of entries CPU saturation, heap exhaustion
Unauthenticated sender Any peer can trigger the above

Because there was no authentication check, any of these attacks could be launched by an anonymous, unauthenticated attacker — no credentials required. This elevates the practical risk significantly.


The Fix

What Changed

The fix introduces an explicit peer identity validation guard at the entry point of receive_file_from_request, placed immediately after filename sanitization and before any disk or network operations begin.

// FIXED: Validate sender identity before processing anything
async fn receive_file_from_request(
    request: IncomingRequest,
    sender_pk: &[u8],
) -> Result<(), FenvoyError> {
    let filename = sanitize_filename(&request.filename);

    // ✅ NEW: Reject requests from unidentified peers immediately
    if sender_pk.is_empty() {
        return Err(FenvoyError::AuthenticationFailed);
    }

    // Further processing only happens for authenticated peers
    let raw_bytes = read_entire_file(&request).await?;
    let parsed: Value = serde_json::from_slice(&raw_bytes)?;

    process_entries(parsed).await?;
    Ok(())
}

Why This Placement Matters

The guard is inserted after filename sanitization but before any I/O operations. This is the optimal position for a few reasons:

  • Fail fast: The function returns immediately with zero file data read from the network.
  • No resource allocation: No memory is allocated for file contents before the check passes.
  • Defense in depth: Even if a bug elsewhere allows a connection to reach this function, the identity check acts as a final gate.

The Before/After Comparison

Before the fix, the trust model looked like this:

[Any Peer] → Connect → Send File → Parse → Process
                ↑
         No gates here

After the fix, the flow is:

[Any Peer] → Connect → Identity Check → ❌ Reject (if empty PK)
                                      → ✅ Send File → Parse → Process

What This Fix Does Not Yet Cover

It's worth being transparent: the authentication guard addresses the who problem (unauthenticated senders), but the original vulnerability description also called out resource limits and JSON depth constraints. A complete remediation should also include:

// Recommended additional guards (not yet in this PR)
const MAX_FILE_SIZE_BYTES: usize = 50 * 1024 * 1024; // 50 MB
const MAX_JSON_DEPTH: usize = 32;
const MAX_ENTRY_COUNT: usize = 100_000;

// Check file size before reading
if request.content_length > MAX_FILE_SIZE_BYTES {
    return Err(FenvoyError::FileTooLarge);
}

// Use a depth-limited JSON parser
let parsed = serde_json::from_slice_with_depth_limit(
    &raw_bytes,
    MAX_JSON_DEPTH
)?;

The authentication fix is a critical first step — it ensures only trusted peers can even attempt a transfer — but resource limit enforcement should follow as a next priority.


Conclusion

This vulnerability is a textbook example of how missing input validation at trust boundaries can turn a useful feature into an attack surface. The file receiver trusted everything — who was sending, how large the payload was, and how complex the structure was — without questioning any of it.

The fix is a strong first step: by rejecting unauthenticated peers at the earliest possible point, we prevent anonymous attackers from ever triggering the resource-intensive code paths. But as we've discussed, a complete defense-in-depth strategy requires resource limits, depth constraints, and rate limiting working together.

Key takeaways for developers:

  • 🔐 Authenticate before you process — never touch untrusted data before verifying who sent it.
  • 📏 Set explicit limits — file sizes, JSON depth, collection counts, and timeouts should all have hard caps.
  • 🚫 Fail fast and loudly — return errors early, before allocating memory or opening files.
  • 🧪 Test your limits — write security tests that deliberately try to exceed your thresholds.
  • 📖 Know your CWEs — CWE-400 (resource exhaustion) and CWE-306 (missing authentication) are among the most common and preventable vulnerability classes.

Security isn't about perfection — it's about raising the cost of attack at every layer. Each guard you add forces an attacker to work harder. Keep stacking them.


Found a similar issue in your codebase? Consider auditing all file ingestion and data import paths for missing size limits, depth checks, and authentication guards. A quick grep for read_to_end, from_slice, or load_file in your network-facing code is a good place to start.

Prevention and further reading

Related Articles

medium

path-to-regexp 0.1.12 DoS: Catastrophic Backtracking on Malformed URL

path-to-regexp version 0.1.12 contains a regular expression engine vulnerability where maliciously crafted URL parameters trigger exponential backtracking, causing CPU exhaustion and service unavailability. Upgrading to version 0.1.13 eliminates the vulnerable pattern from the parsing logic.

critical

CVE-2026-59873: node-tar 7.5.11 DoS via Crafted Gzip Bomb

node-tar versions 7.5.11 through 7.5.18 are vulnerable to a denial-of-service attack through maliciously crafted gzip archives that decompress to disproportionately large sizes. An attacker can exploit this to exhaust memory and CPU resources by submitting a small, highly compressed archive that expands beyond configured limits during extraction.

high

MapManager.get() Race Condition Duplicates API Requests

The MapManager's `get(mapUid, cache)` method used a check-then-act pattern that permitted multiple concurrent requests to pass the cache miss check simultaneously, triggering redundant API calls and risking cache corruption. The fix introduces a `_pending` promise map to deduplicate in-flight fetches for identical map UIDs.

critical

Lampa Desktop Auto-Update Heuristic Bypass: Execution of Unverified

Lampa Desktop's auto-update mechanism downloaded JavaScript and CSS from `raw.githubusercontent.com` using only heuristic validation—file size thresholds and string pattern matching—that attackers could trivially satisfy. The fix introduces cryptographic integrity verification by cross-referencing Git blob hashes from the GitHub Contents API, ensuring downloaded code matches the repository's authoritative state before execution.

high

adm-zip 0.6.0 Preserves SUID Bits From ZIPs: CVE-2026-102282

The `adm-zip` dependency resolved to 0.6.0 in this project's dependency tree, a version affected by CVE-2026-102282: during extraction it applies the Unix permission bits stored in each ZIP entry's external file attributes verbatim, including the setuid (`04000`), setgid (`02000`), and sticky bits. An attacker who controls an archive passed to `extractAllTo()` or `extractEntryTo()` can therefore have the extractor create a setuid binary owned by whatever user the extraction process runs as. The

high

requestInput() Type Confusion: NaN and Object Bypass in JavaScript

The `requestInput()` utility function lacked validation on its `type` parameter and failed to handle `NaN` results from float conversions, creating a type confusion weakness. An attacker could supply malformed inputs that propagate unhandled `NaN` values or unexpected object types through the type system. The fix adds explicit guards against `NaN` type parameters and rejects non-primitive type values.