/

CVE-2026-27625

Severity:

HIGH RISK

(8.1)

Path Traversal File Write in Stirling-PDF Markdown-to-PDF

CVE-2026-27625

Analyzed

Vulnerability type

Category:

Path Traversal / Arbitrary File Write

CWE:

CWE-22, CWE-23

Impact:

Authenticated Arbitrary File Write

Severity:

HIGH RISK

(8.1)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

Stirling-PDF versions prior to 2.5.2 contain a path traversal vulnerability in the /api/v1/convert/markdown/pdf endpoint, where ZIP archives are extracted without validating entry paths.

An authenticated user can craft ZIP entries that write files outside the temporary working directory, enabling arbitrary file writes as the stirlingpdfuser process user and potentially compromising application data and behavior.

Affected context

The vulnerability occurs in Stirling-PDF deployments that expose the /api/v1/convert/markdown/pdf endpoint and allow authenticated users to upload ZIP content for markdown-to-PDF conversion.

When the server unpacks user-supplied ZIP archives, it does not enforce path normalization or restrict extraction to a dedicated directory.

As a result, ZIP entries containing directory traversal sequences (e.g., parent directory references) are written relative to the server's filesystem rather than being confined to the intended temporary working directory.

Exploit preconditions

  • Attack surface: HTTP(S) API endpoint /api/v1/convert/markdown/pdf
  • Required access: Valid authenticated Stirling-PDF user account with permission to invoke the markdown-to-PDF conversion feature
  • User-controlled input: ZIP file contents, including file names and paths within the archive
  • Trigger point: Server-side extraction of the ZIP archive during markdown-to-PDF conversion
  • Why exploitation is possible: The extraction logic does not validate or normalize archive entry paths, nor does it enforce that all extracted paths remain within a dedicated temporary or sandbox directory, allowing directory traversal to write files to unintended locations.

Why this happens

This issue stems from improper handling of file paths when extracting user-supplied ZIP archives.

The backend accepts ZIP entries and writes them directly to disk without checking for traversal patterns, absolute paths, or other mechanisms that escape the intended working directory.

This aligns with CWE-22: Improper Limitation of a Pathname to a Restricted Directory, and is closely related to CWE-23: Relative Path Traversal, where user-controlled relative paths are used without normalization or enforcement of a safe root.

At an abstract level, the bug arises from trusting archive entry names as safe filesystem destinations instead of treating them as untrusted, requiring canonicalization and containment checks.

Potential impact

  • Authenticated users could write arbitrary files to locations writable by stirlingpdfuser.
  • Existing writable files (e.g., configuration, logs, or temporary data) could be overwritten, impacting data integrity.
  • Application behavior could be altered by modifying files the service reads at runtime, potentially leading to denial of service or unexpected features.
  • In certain environments, file writes into web-accessible paths or integration directories could facilitate further compromise of the hosting application or adjacent services.

General mitigation guidance

Mitigation generally focuses on constraining file system writes and treating archive contents as untrusted:

  • Restrict archive extraction to a dedicated, isolated directory and enforce that all resolved paths remain within that directory.
  • Normalize and canonicalize file paths (resolving .., symbolic links, and special components) before writing, rejecting entries that escape the intended root.
  • Implement a strict allowlist for file types and directory structures that the application genuinely needs during conversion.
  • Run the Stirling-PDF service under a minimally privileged account and ensure the process has write access only to directories required for normal operation.
  • Use temporary directories with appropriate permissions and consider periodic cleanup to limit long-lived artifacts from user uploads.

How teams detect issues like this

Effective detection typically involves a mix of code-level and runtime monitoring:

  • Static analysis: Configure rules to flag file operations that use user-derived paths, especially in archive extraction or upload handling code.
  • Code review: Look for ZIP/tar extraction logic that does not normalize paths or validate that the target directory is preserved; pay attention to uses of relative paths and missing directory traversal checks.
  • Logging and monitoring: Log archive extraction operations and unexpected write locations; alert on writes outside approved working directories.
  • Policy enforcement: Include secure file-handling guidelines in development standards, and use automated review tools to enforce path traversal and file-write best practices during CI.

Sources

SourceLink
github.comgithub.com/Stirling-Tools/Stirling-PDF/releases/tag/v2.5.2
github.comgithub.com/Stirling-Tools/Stirling-PDF/security/advisories/GHSA-wccq-mg6x-2w22

Frequently asked

questions

Yes, but only by authenticated users who can access the /api/v1/convert/markdown/pdf endpoint and upload ZIP archives. It is not exploitable by unauthenticated visitors.

An attacker needs valid Stirling-PDF credentials with permission to invoke the markdown-to-PDF conversion API. No direct shell access is required; the attack is carried out through crafted ZIP uploads.

The most robust fix is to confine all extracted entries to a dedicated directory by normalizing each archive entry's path, verifying that it remains under a predefined root, and rejecting any entry that attempts to escape that directory.

Treat all file paths derived from user input or archives as untrusted, apply canonicalization and containment checks, confine file operations to restricted directories, and enforce these patterns via secure coding standards, code review, and static analysis rules.

Find out what's already
exploitable in your codebase.