Skip to main content

SharpCompress CVE-2026-44788

MEDIUM
Path Traversal (CWE-22)
2026-05-08 https://github.com/adamhathcock/sharpcompress GHSA-6c8g-7p36-r338
6.5
CVSS 3.1 · NVD
View

Attack ChainAIDerived

Hypothetical attack flow derived from CVE metadata – not a confirmed exploit chain

  1. Recon
    Craft malicious archive with traversal paths
  2. Delivery
    User extracts archive via WriteToDirectory()
  3. Exploit
    Vulnerable code skips Path.GetFullPath() check
  4. Install
    Directory.CreateDirectory() resolves .. and / on raw path
  5. C2
    Directories/files created outside extraction root
  6. Execute
    (TAR only with SymbolicLinkHandler) Symlink entry created pointing outside root
  7. Impact
    File entry written through symlink
  8. Step 8
    Arbitrary file write on filesystem

Vulnerability Assessment

Weakness
CWE
OWASP Top 10:2025
A01:2025 - Broken Access Control
ASVS 5.0
V5 - File Handling Path canonicalization, traversal prevention
MITRE ATT&CK

2 techniques across 2 tactics: Discovery, Collection

The technique list with ATT&CK links and the kill-chain view is part of the Basic plan and up.

Exploitation Conditions

User interaction is required-the vulnerability is triggered when a user explicitly extracts an untrusted archive via WriteToDirectory() API call, not through automatic background processing. The attacker must craft a malicious archive (ZIP or TAR) with directory entries containing traversal sequences (.., / prefixes, or absolute paths); normal archives are not affected. For TAR symlink escalation, the application must: (1) call WriteToDirectory() with a SymbolicLinkHandler delegate, (2) use ExtractFullPath = true option (or equivalent), and (3) the handler must create symlinks without validating targets. Windows deployments are less exposed because Windows restricts symlink creation to administrator-level privileges and requires special flag handling. The exploitation is scoped to the running process's filesystem permissions-an attacker cannot escape the process user's access level. Non-solid archive formats (ZIP, TAR) are vulnerable; solid and 7-Zip formats are not affected due to different code paths.

Impact

CVSS 5.9 with AV:N/AC:H/PR:N/UI:R/S:U reflects network-accessible attack vector, high complexity (archive must be crafted), no privileges required, and no authentication. However, UI:R (user interaction required) is a critical limiting factor-the vulnerability requires a user to extract an untrusted or attacker-controlled archive, not automatic processing. EPSS and KEV status are not provided in the input, so real-world exploitation probability cannot be directly assessed. The vulnerability is a classic zip-slip variant (well-understood attack class) with publicly available proof-of-concept code, suggesting low exploit sophistication once discovered. Real-world risk hinges on deployment context: applications that extract untrusted archives programmatically without user interaction are at high risk; those requiring explicit user extraction are at lower risk. The AC:H complexity suggests defensive mitigations may already be in place in some deployments (e.g., archive signature validation, sandboxing). The symlink escalation is TAR-only and requires the caller to implement SymbolicLinkHandler, narrowing exposure further-many applications may not restore symlinks or may run on Windows where symlink support is limited. Absence of CVSS scope change (S:U) means exploitation does not grant access beyond the running process's permissions, which is a significant constraint for privilege escalation in hardened environments.

Exploit ScenarioDerived

An attacker crafts a malicious ZIP archive with directory entries named ../../escaped_relative/ and /tmp/escaped_absolute/, then tricks a user into extracting it via a file browser or web upload. When the application calls archive.WriteToDirectory("/home/user/extract"), the vulnerable code creates directories at /home/escaped_relative/ and /tmp/escaped_absolute/ instead of under /home/user/extract/, allowing the attacker to stage files in privileged locations (cron drop-ins, systemd service directories) for privilege escalation. For TAR archives with symlink handling enabled, the attacker includes a symlink entry link → ../../../evil_outside/ and a file entry link/payload.sh, causing the file to be written outside the extraction root via symlink following.

This Month Plan within 30 days. Why: MEDIUM severity (CVSS 4.0-6.9).
Patch available 0.0% exploitation probability (EPSS)

Get an e-mail when this CVE is exploited, patched or re-scored. Free account.

Alert me

AnalysisAIv1 – May 09, 2026

Path traversal in SharpCompress WriteToDirectory() allows malicious ZIP and TAR archives to create directories outside the intended extraction root via relative (../../) and absolute path (/tmp/) overrides in the directory-entry fast-path. TAR archives can be further escalated to arbitrary file writes when callers implement SymbolicLinkHandler without validating symlink targets, enabling an attacker to write files anywhere on the filesystem subject to process permissions. CVSS 5.9 reflects moderate severity; real-world impact depends on whether the application extracts untrusted archives and implements symlink handling.

RemediationAI

No vendor-released patch identified at time of analysis-the affected repository shows no fixed version tagged on NuGet. Immediate mitigation: upgrade to the latest SharpCompress version when available and verify the fix is included in release notes, or contact the vendor for ETA. If upgrade is not immediately possible, implement path validation before extraction: apply Path.GetFullPath() normalization and StartsWith() bounds checking on all extracted paths as documented in the CVE (normalize destination root, compute full path of each entry, verify entry path begins with root before creation). Alternatively, extract archives into a temporary sandbox directory with strict permissions, then validate each entry's path before copying to the final location. For applications implementing SymbolicLinkHandler for TAR extraction, validate the linkTarget parameter before creating symlinks-reject any target containing .. or / prefixes that would escape the intended root. Document this requirement in extraction API contracts so callers understand the library does not validate symlink targets. Side effect of path validation: legitimate archives with directory entries using absolute paths or relative traversal (edge case, but may occur in legacy archives) will fail extraction with an ExtractionException; test archives in use to confirm compatibility before deployment.

Affected Packages

nuget sharpcompress fix: 0.48.0

Source: OSV (Open Source Vulnerabilities)

Affects your stack

Affects 1 package in nuget

Checking this CVE against your own stacks and servers is part of the Basic plan and up.

Technical ContextAI · show details

SharpCompress is a .NET compression library supporting ZIP, TAR, 7-Zip, and other formats. The vulnerability exists in the directory-entry extraction path (IArchiveExtensions.cs:48-61 and IAsyncArchiveExtensions.cs:70-84) which uses raw Path.Combine() without normalization or bounds checking. The library's file-entry path correctly applies Path.GetFullPath() and StartsWith() validation, but the directory fast-path was added without this guard. The root cause is CWE-22 (Improper Limitation of a Pathname to a Restricted Directory). Two .NET Path.Combine behaviors enable exploitation: (1) relative path traversal where .. segments are resolved by the OS after combining, and (2) absolute path override where a rooted second argument discards the base path entirely. For TAR archives with SymbolicLinkHandler, symlink targets are not validated before being passed to the caller, allowing symlink chaining to bypass the file-entry guard since Path.GetFullPath() does not resolve symlinks-only normalizes . and .. segments. ZIP does not support symlinks in SharpCompress, limiting that format to directory creation; TAR enables full file writes.

Know when the next one hits your stack

  • Watch products and get an email when something new is published
  • Check this CVE against your own stack and servers
  • Exploit and PoC references, threat intelligence from 22 sources

No credit card · 7-day full trial

Severity by source

NVD PRIMARY 6.5 MEDIUM
AV:N/AC:L/PR:N/UI:R/S:U/C:N/I:H/A:N

Primary rating from NVD · only source for this CVE.

CVSS VectorNVD

Attack Vector
Network
Attack Complexity
Low
Privileges Required
None
User Interaction
Required
Scope
Unchanged
Confidentiality
None
Integrity
High
Availability
None

Lifecycle Timeline

2
CVSS changed
Jul 23, 2026 - 11:22 NVD
5.9 (MEDIUM) 6.5 (MEDIUM)
CVE Published
May 08, 2026 - 23:50 nvd
MEDIUM 5.9

DescriptionNVD

Summary

A path traversal vulnerability in IArchive.WriteToDirectory() allows a malicious archive to create directories outside the intended extraction root. For TAR archives, this can be escalated to arbitrary file writes by chaining with a symlink entry, giving a full write primitive on the target filesystem subject to the permissions of the running process.

Details

The vulnerable code is in the directory-entry branch of WriteToDirectoryInternal (sync, IArchiveExtensions.cs:48-61) and WriteToDirectoryAsyncInternal (async, IAsyncArchiveExtensions.cs:70-84):

csharp
var dirPath = Path.Combine(destinationDirectory, entry.Key);
Directory.CreateDirectory(Path.GetDirectoryName(dirPath + "/"));

No Path.GetFullPath() normalisation and no bounds check are applied before the Directory.CreateDirectory call. Two .NET Path.Combine behaviours make this exploitable:

  • Relative traversal: Path.Combine("/safe/extract", "../../evil") → the OS resolves .. segments on the raw path, placing the directory outside the extraction root.
  • Absolute path override: Path.Combine("/safe/extract", "/tmp/evil") → returns "/tmp/evil" - the base is discarded entirely for rooted paths.

File entries are not directly affected - they route through ExtractionMethods.WriteEntryToDirectory which applies the correct guard (GetFullPath + StartsWith, see ExtractionMethods.cs:54-65). The directory-entry branch is a separate fast-path that was added without that guard.

Affected archive formats: ZIP and TAR (non-solid). Solid archives and 7-Zip use the reader path which calls the secure method.

Escalation to arbitrary file writes (TAR only)

Path.GetFullPath on .NET does not resolve symlinks - it only normalises . and .. segments. This means the file-entry guard in ExtractionMethods.WriteEntryToDirectory can be bypassed via symlink chaining in TAR archives when the caller supplies a SymbolicLinkHandler:

csharp
archive.WriteToDirectory("/safe/extract", new ExtractionOptions
{
    ExtractFullPath = true,
    SymbolicLinkHandler = (linkPath, linkTarget) =>
        File.CreateSymbolicLink(linkPath, linkTarget)  // naive - no validation of linkTarget
});

Attack sequence in a single TAR archive:

  1. Symlink entry - link → ../evil_outside/

The SymbolicLinkHandler creates /safe/extract/link pointing outside the extraction root.

  1. File entry - link/secret.txt

ExtractionMethods.WriteEntryToDirectory computes:

  • destdir = Path.GetFullPath("/safe/extract/link") → "/safe/extract/link" - textually inside root, check passes ✓
  • File.Open("/safe/extract/link/secret.txt") - OS follows symlink, file is written to /evil_outside/secret.txt

The library does not validate linkTarget before passing it to the caller's handler, and the XML docs do not warn that it may be a traversal path. The idiomatic handler implementation above is therefore silently exploitable.

ZIP does not support symlinks in SharpCompress (ZipEntry.LinkTarget always returns null), so this escalation is TAR-only.

AttackZIPTAR
Directory traversal (escape extraction root)YesYes
Escalate to arbitrary file writes via symlink chainNoYes (if caller provides SymbolicLinkHandler)

Recommended fix - apply the same pattern from ExtractionMethods.WriteEntryToDirectory to both affected files:

csharp
var fullDestDir = Path.GetFullPath(destinationDirectory);
if (!fullDestDir.EndsWith(Path.DirectorySeparatorChar))
    fullDestDir += Path.DirectorySeparatorChar;

var dirPath = Path.GetFullPath(Path.Combine(fullDestDir, entry.Key));
if (!dirPath.StartsWith(fullDestDir, PathComparison))
    throw new ExtractionException(
        "Entry is trying to create a directory outside of the destination directory.");

Directory.CreateDirectory(dirPath);

Additionally, the library should validate LinkTarget before invoking the caller's SymbolicLinkHandler, or document clearly that callers must validate it themselves.

PoC

A self-contained .NET console app is available at: https://github.com/svenclaesson/poc-sharpcompress-traversal

git clone https://github.com/svenclaesson/poc-sharpcompress-traversal
cd poc-sharpcompress-traversal
dotnet run

The PoC crafts a ZIP with three directory entries (../../escaped_relative/, /tmp/escaped_absolute/, safe_subdir/) using System.IO.Compression (stdlib), then extracts with SharpCompress. Output shows [ESCAPED] for the two malicious entries and [ok] for the legitimate one, on both sync and async APIs.

Tested against SharpCompress 0.47.4 (latest NuGet).

Impact

This is a path traversal / zip slip vulnerability (CWE-22). Any application that calls archive.WriteToDirectory() on an untrusted archive is affected - which covers the primary documented extraction API.

For ZIP archives the impact is limited to arbitrary directory creation, which can be used to stage privilege escalation (e.g. cron drop-ins, XDG config paths, service spool directories) or shadow expected paths to alter application behaviour.

For TAR archives, callers that implement a SymbolicLinkHandler - which is the only way to faithfully restore a TAR - are exposed to a full arbitrary file write primitive via the symlink chaining described above.

Threat Intelligence Overview

EPSS Score
0.0%
Top 97% exploitable
Threat Intel
1
1 source
Data Quality
5 sources
Confidence: Medium
NVD CVE.org EPSS GHSA GitHub VulDB

How this decision was reached

The engine reads each signal below and applies a fixed list of rules from top to bottom. The first rule that matches sets the recommended action – like a statement, every line is shown.

SignalValue
Severity MEDIUM
CISA KEV No
Public POC No
EPSS 0.0%
Patch available Yes
Active threat No
Deciding rule
MEDIUM severity (CVSS 4.0-6.9)
What every action level means
Emergency Immediate action required. Criteria: CRITICAL + in CISA KEV (actively exploited) without patch, OR CRITICAL + EPSS > 30% without patch, OR CRITICAL + active threat signals without patch.
Act Now Prioritize within 24-48h. Criteria: in KEV with patch available, OR CRITICAL + public POC, OR HIGH + EPSS > 10%, OR CRITICAL + active threat, OR any CRITICAL severity.
This Week Schedule remediation this week. Criteria: HIGH severity (CVSS 7.0-8.9). Patch within normal change window.
This Month Plan within 30 days. Criteria: MEDIUM severity (CVSS 4.0-6.9), lower exploitation probability. Include in regular patch cycle.
Monitor Track and reassess. Criteria: LOW severity (CVSS 0.1-3.9), minimal exploitation risk. No immediate action needed.

SSVC AssessmentENISA

SSVC Decision· derived
Scheduled
Exploitation· derived
None
System Exposure· derived
Open
Automatable· derived
No
Human Impact· derived
Medium

Priority Score

32
Low Medium High Critical
KEV: 0
EPSS: 0
CVSS: +32
PoC: 0
Weaponized: 0
Threat intel: 0
Gov advisory: 0

Attack Technique

Privilege escalation occurs when an attacker leverages flaws in access control mechanisms to gain permissions beyond what they were originally granted.

Path traversal exploits occur when applications use user-controlled input to construct file system paths without proper validation.

Affected Products (CPE)NVD

pkg:nuget/sharpcompress

This site uses cookies essential for authentication and security. No tracking or analytics cookies are used. Privacy Policy