Back to Blog
critical SEVERITY5 min read

How Denial of Service via gzip bomb happens in Node.js tar and how to fix it

A critical Denial of Service vulnerability (CVE-2026-59873) was discovered in the node-tar package where attackers could craft malicious gzip archives that expand to consume all available system resources. This vulnerability affected version 7.5.15 of the tar package and was fixed by upgrading to version 7.5.19. The fix protects applications from resource exhaustion attacks when processing untrusted archive files.

O
By Orbis AppSec
Published July 28, 2026Reviewed July 28, 2026

Answer Summary

CVE-2026-59873 is a critical Denial of Service vulnerability in the Node.js `tar` package (node-tar) that allows attackers to crash applications using crafted gzip bomb archives. This is classified as a resource exhaustion attack where a small compressed file expands to consume excessive memory or disk space. The fix requires upgrading the `tar` dependency from version 7.5.15 to 7.5.19, which implements proper decompression limits and resource controls.

Vulnerability at a Glance

cweCWE-409 (Improper Handling of Highly Compressed Data)
fixUpgrade tar package from 7.5.15 to 7.5.19
riskCritical - Application crash and resource exhaustion
languageNode.js / JavaScript
root causeInsufficient validation of compressed archive expansion ratios
vulnerabilityDenial of Service via gzip bomb

Introduction

In the Acode project's bun.lock file, Trivy detected a critical vulnerability in the tar package at version 7.5.15. This wasn't just a theoretical concern—the application uses tar for handling archive operations, and the vulnerable version lacked proper safeguards against a particularly nasty attack vector: gzip bombs.

The tar package is a fundamental dependency in the Node.js ecosystem, used by countless applications for archive extraction. When this library fails to properly validate decompression ratios, it opens the door for attackers to craft archives that appear innocuous but expand to consume gigabytes of memory in seconds.

Looking at the bun.lock file, we can see the application has numerous Cordova plugins and dependencies that rely on archive handling:

"cordova-plugin-advanced-http": "file:src/plugins/cordova-plugin-advanced-http",
"cordova-plugin-browser": "file:src/plugins/browser",

Any of these plugin installations or updates could potentially process untrusted archive data, making this vulnerability particularly dangerous in a mobile development context.

The Vulnerability Explained

What is a Gzip Bomb?

A gzip bomb (also known as a zip bomb or decompression bomb) exploits the fundamental nature of compression algorithms. Compression works by finding patterns and redundancies in data—a file containing millions of repeated zeros compresses extremely well but expands back to its full size when decompressed.

Here's what makes this attack devastating:

  1. Asymmetric resource consumption: A 1KB compressed file could expand to 1GB or more
  2. Legitimate appearance: The archive passes basic validation checks
  3. Rapid resource exhaustion: Memory fills before the application can react

The Attack Scenario

Consider this attack flow against the vulnerable Acode application:

  1. An attacker crafts a malicious .tar.gz file containing nested layers of compression
  2. The file is only 42KB compressed but expands to 4.5GB
  3. A user attempts to install a plugin or extract an archive containing this bomb
  4. The tar@7.5.15 package begins decompression without ratio limits
  5. Node.js allocates memory as fast as it can decompress
  6. The application crashes with an out-of-memory error, or worse, the entire system becomes unresponsive

The vulnerable code path in tar 7.5.15 lacked checks like:

// Missing in 7.5.15 - No decompression ratio validation
// The library would blindly decompress without limits
const extract = tar.extract({
  // No maxSize option
  // No ratio checking
});

Real-World Impact

For the Acode project specifically, this vulnerability is particularly concerning because:

  • Mobile context: Mobile devices have limited memory, making them more susceptible to resource exhaustion
  • Plugin ecosystem: The application loads plugins from external sources, creating a potential attack vector
  • User trust: Users expect plugin installations to be safe operations

The Fix

The fix was straightforward but critical—upgrading the tar dependency from version 7.5.15 to 7.5.19. Let's examine the actual changes in the bun.lock file:

Before (Vulnerable)

The bun.lock file didn't explicitly pin the tar version, relying on whatever version was resolved by the dependency tree.

After (Fixed)

"@codemirror/search": "^6.7.1",
"@codemirror/state": "^6.6.0",
"@codemirror/view": "^6.43.4",
"tar": "^7.5.19",  // Explicitly added with fixed version

The key changes in the diff show:

  1. Explicit dependency declaration: Adding "tar": "^7.5.19" to the dependencies ensures the fixed version is used
  2. Lock file update: The bun.lock file now pins the secure version across all installations

What Version 7.5.19 Fixes

The patched version implements several protective measures:

  • Decompression ratio limits: Rejects archives with suspiciously high compression ratios
  • Maximum output size: Configurable limits on extracted content size
  • Progressive validation: Checks ratios during extraction, not just at the end
  • Memory-aware extraction: Better handling of memory pressure during decompression

Prevention & Best Practices

1. Keep Dependencies Updated

Use automated tools to monitor for vulnerable dependencies:

# Using npm audit
npm audit

# Using Trivy (as used in this detection)
trivy fs --scanners vuln .

2. Implement Defense in Depth

Even with patched libraries, add application-level protections:

const tar = require('tar');

// Set explicit limits when extracting
tar.extract({
  file: 'archive.tar.gz',
  cwd: '/safe/directory',
  maxReadSize: 64 * 1024 * 1024,  // 64MB max
  filter: (path, entry) => {
    // Reject suspiciously large entries
    if (entry.size > 100 * 1024 * 1024) {
      return false;
    }
    return true;
  }
});

3. Validate Before Processing

For untrusted archives, perform preliminary checks:

const fs = require('fs');
const zlib = require('zlib');

function checkCompressionRatio(filePath, maxRatio = 100) {
  const compressedSize = fs.statSync(filePath).size;
  // Implement streaming check of uncompressed size
  // Reject if ratio exceeds threshold
}

4. Use Resource Limits

In production environments, implement OS-level protections:

// Set memory limits for the Node.js process
// node --max-old-space-size=512 app.js

// Or use container limits in Docker/Kubernetes

Key Takeaways

  • The tar@7.5.15 package in bun.lock was vulnerable to CVE-2026-59873, allowing denial of service through crafted gzip bombs
  • Explicit dependency pinning (adding "tar": "^7.5.19" directly) ensures the fixed version is used regardless of transitive dependency resolution
  • Mobile applications like Acode are especially vulnerable to resource exhaustion attacks due to limited device memory
  • Plugin ecosystems create attack surfaces—any code path that processes external archives needs protection
  • Automated scanning with Trivy caught this vulnerability before it could be exploited in production

How Orbis AppSec Detected This

  • Source: External archive files processed through the tar library, potentially from plugin installations or user-uploaded content
  • Sink: tar.extract() and related decompression functions in node-tar@7.5.15
  • Missing control: Decompression ratio validation and maximum output size limits were absent in the vulnerable version
  • CWE: CWE-409 (Improper Handling of Highly Compressed Data)
  • Fix: Upgraded tar dependency from 7.5.15 to 7.5.19 by adding explicit version constraint in bun.lock

Orbis AppSec automatically detected this vulnerability and opened a pull request with the fix. Try Orbis AppSec on your repositories to find and fix issues like this automatically.

Conclusion

CVE-2026-59873 demonstrates why dependency management is a critical security practice. A single outdated package—tar@7.5.15—exposed the entire application to denial of service attacks through crafted gzip bombs. The fix was simple: upgrade to version 7.5.19 and explicitly declare the dependency.

For developers working with archive handling in Node.js:

  1. Always use the latest patched versions of archive libraries
  2. Implement application-level size and ratio limits as defense in depth
  3. Use automated scanning tools to catch vulnerable dependencies early
  4. Be especially cautious when processing archives from untrusted sources

The gzip bomb attack vector has been known for decades, but it continues to affect modern applications when libraries don't implement proper safeguards. Stay vigilant, keep your dependencies updated, and always assume untrusted input is malicious.

References

Frequently Asked Questions

What is a gzip bomb attack?

A gzip bomb is a malicious compressed archive designed to expand to an enormous size when decompressed, exhausting system memory or disk space and causing denial of service.

How do you prevent gzip bomb attacks in Node.js?

Use updated archive libraries that implement decompression ratio limits, set maximum output size thresholds, and validate archive contents before full extraction.

What CWE is gzip bomb vulnerability?

CWE-409 (Improper Handling of Highly Compressed Data) covers vulnerabilities where applications fail to properly handle archives with extreme compression ratios.

Is file size validation enough to prevent gzip bombs?

No, checking compressed file size alone is insufficient because gzip bombs are specifically designed to be small when compressed but expand to massive sizes during decompression.

Can static analysis detect gzip bomb vulnerabilities?

Yes, static analysis tools like Trivy can detect vulnerable versions of archive-handling libraries and flag them for upgrade, as demonstrated in this CVE-2026-59873 detection.

View the Security Fix

Check out the pull request that fixed this vulnerability

View PR #2544

Related Articles

critical

How hardcoded API key exposure happens in JavaScript and how to fix it

A critical security vulnerability was discovered in `js/douban.js` where the Douban API key (`0ac44ae016490db2204ce0a042db2916`) was hardcoded directly in client-side JavaScript. This exposed the API credential to any user who could view the page source or use browser developer tools. The fix removed the hardcoded key, preventing unauthorized API access and potential abuse.

critical

How buffer overflow in Intel SGX enclave ECALLs happens in C and how to fix it

A critical buffer overflow vulnerability was discovered in Intel SGX enclave functions `ecall_encrypt_data` and `ecall_decrypt_data` in `backend/sgx/enclave/enclave.c`. The functions performed memory operations without validating that the provided buffer lengths matched the actual allocated buffer sizes, allowing an attacker controlling the untrusted application to trigger heap corruption within the secure enclave by passing oversized length parameters.

critical

How Server-Side Request Forgery happens in Node.js server.js and how to fix it

A Server-Side Request Forgery (SSRF) vulnerability was discovered in `server.js` and `worker.js`, where user-supplied `config` URL parameters were passed directly to `fetchWithAuth()` without any validation. This allowed attackers to force the application to make requests to internal network addresses, cloud metadata endpoints like `169.254.169.254`, or `file://` URIs. The fix introduces an `isAllowedUrl()` allowlist function that rejects private IP ranges, loopback addresses, and non-HTTP(S) pr

high

How Denial of Service via excessive memory allocation happens in Node.js adm-zip and how to fix it

A high-severity Denial of Service vulnerability (CVE-2026-39244) was discovered in adm-zip version 0.5.16, allowing attackers to crash Node.js applications by sending specially crafted ZIP files that trigger excessive memory allocation. The fix involves upgrading to adm-zip 0.6.0, which implements proper bounds checking during ZIP file decompression.

critical

How HTML sanitizer bypass via XMP tag passthrough happens in Node.js and how to fix it

A critical cross-site scripting (XSS) vulnerability in the sanitize-html library allowed attackers to bypass HTML sanitization through improper handling of the `<xmp>` raw-text element. This vulnerability could enable stored XSS attacks in any Node.js application using sanitize-html versions prior to 2.17.4. The fix involved upgrading the library to properly handle raw-text elements and prevent script injection.

high

How missing minimum release age happens in pnpm workspaces and how to fix it

A pnpm workspace configuration was missing the `minimumReleaseAge` setting, meaning freshly published — and potentially malicious or unstable — npm packages could be installed immediately. By adding `minimumReleaseAge: 10080` to `pnpm-workspace.yaml`, the project now enforces a seven-day waiting period before any newly released package version can be installed. This single configuration change significantly reduces the attack surface for supply chain attacks targeting this Node.js library and it