OnChainScans
Zip Slip Directory Traversal Vulnerability•CWE-22: Improper Limitation of a Pathname to a Restricted Directory• LIVE SCANNER EMBEDDED

How to Detect & Prevent Zip Slip Path Traversal Vulnerabilities

Audit compressed archives for malicious file entries attempting to overwrite system files.

Live Diagnostic Tool: ZIP / RAR Safe Peek ScannerFull Tool Page
Executive Answer & Impact Analysis

Zip Slip is a critical security vulnerability where an archive contains filenames with directory traversal characters (e.g. '../../etc/passwd'). When unpacked by vulnerable extraction libraries, the archive writes files outside the target directory, enabling arbitrary remote code execution.

Root Cause Analysis

Extraction libraries that blindly concatenate the archive entry path with the destination directory without validating whether the resolved canonical path remains within the target folder.

Step-by-Step Resolution Procedure

1Inspect Archive Without Extraction

Use the ZIP Safe Peek scanner above to list archive entries in memory and flag any entry with '../' or double extensions.

2Validate Canonical Path Before Extraction

In your application extraction logic, verify that canonical resolved destination paths start with the target directory.

3Enforce Safe Archive Extraction Libraries

Update your unzip utility to modern libraries that automatically strip traversal tokens.

Verification Command or Config Pattern

TERMINAL / CONFIGRFC CWE-22: Improper Limitation of a Pathname to a Restricted Directory
import path from "path";

function isSafeExtractionPath(targetDir: string, entryName: string): boolean {
  const destinationPath = path.resolve(targetDir, entryName);
  // Ensure destination path starts with target directory root
  return destinationPath.startsWith(path.resolve(targetDir) + path.sep);
}

Frequently Asked Remediation Questions

What file formats are vulnerable to Zip Slip?

Any container format supporting path hierarchy, including ZIP, TAR, JAR, WAR, 7z, and APK files.

How does OnChainScans inspect archives safely?

OnChainScans reads the central directory header in browser memory via JSZip without writing any files to disk.

What is a compression ratio bomb?

A zip bomb is a tiny archive (e.g. 42 KB) that expands to gigabytes of data when extracted, crashing the host server via disk or memory exhaustion.

Can double extensions (.pdf.exe) be caught?

Yes. OnChainScans automatically flags files with executable extensions masquerading as documents.