Skip to main content
Vulnerability Database/CVE-2024-37169

CVE-2024-37169: jmondi/url-to-png Path Traversal Vulnerability

CVE-2024-37169 is a path traversal flaw in jmondi/url-to-png that allows arbitrary file read through Playwright screenshot exploitation. This post explains its technical details, affected versions, and mitigation.

Published:

Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.

Sources: National Vulnerability Database, CISA KEV, Exploit-DB

CVE-2024-37169 Overview

CVE-2024-37169 affects @jmondi/url-to-png, a self-hosted utility that converts URLs into PNG screenshots using Playwright. Versions prior to 2.0.3 accept any URL protocol as input, allowing attackers to supply file:// URIs. This enables arbitrary local file read on the host running the screenshot service. The flaw is tracked as a path traversal weakness [CWE-22] and was patched in version 2.0.3 by restricting the accepted protocols to http and https.

Critical Impact

Unauthenticated remote attackers can read arbitrary files from the server hosting the screenshot service by submitting file:// URIs to the screenshot endpoint.

Affected Products

  • @jmondi/url-to-png versions prior to 2.0.3
  • Self-hosted deployments exposing the screenshot API
  • Downstream applications embedding the utility as a dependency

Discovery Timeline

  • 2024-06-10 - CVE-2024-37169 published to the National Vulnerability Database (NVD)
  • 2026-06-17 - Last updated in NVD database

Technical Details for CVE-2024-37169

Vulnerability Analysis

The @jmondi/url-to-png service accepts a URL parameter and uses Playwright's page.goto() method to render the target before capturing a PNG screenshot. Prior to version 2.0.3, the input validation schema only enforced that the supplied string was a syntactically valid URL. It did not restrict the URL scheme.

Playwright honors any protocol Chromium supports, including the file:// scheme. An attacker submits a URL such as file:///etc/passwd to the screenshot endpoint. The headless browser reads the local file and renders its contents. The returned PNG contains a visual representation of the file, disclosing its contents to the attacker.

The flaw sits at the trust boundary between untrusted HTTP input and the local file system exposed by the browser wrapper. It requires no authentication and no user interaction.

Root Cause

The root cause is missing protocol validation in the Zod schema used to parse incoming query parameters. The original schema z.string().url() accepts any well-formed URL regardless of scheme, delegating enforcement to downstream consumers that never applied it.

Attack Vector

Exploitation requires network access to the screenshot endpoint. The attacker crafts a request substituting file:// for http:// in the url parameter and retrieves the rendered PNG containing file contents. Impact is limited to files readable by the process user running the service.

typescript
// Patch: src/lib/schema.ts
// Restrict the URL schema to http/https protocols
   .transform(x => x === "true")
   .pipe(z.boolean());
 
-const zodStringUrl = z.string().url();
+const urlSchema = z
+  .string()
+  .url()
+  .refine(
+    val => {
+      try {
+        const url = new URL(val);
+        return url.protocol === "http:" || url.protocol === "https:";
+      } catch (err) {
+        return false;
+      }
+    },
+    {
+      message: "must start with http or https",
+    },
+  );
 
 export const PlainConfigSchema = z.object({
-  url: zodStringUrl,
+  url: urlSchema,

Source: GitHub Commit 9336020

Detection Methods for CVE-2024-37169

Indicators of Compromise

  • Requests to the screenshot endpoint containing url=file:// or URL-encoded variants such as url=file%3A%2F%2F
  • HTTP access logs referencing local paths such as /etc/passwd, /proc/self/environ, or Windows equivalents like C:\Windows\win.ini
  • Screenshot outputs of unusual dimensions or containing plaintext file content rather than web page renders

Detection Strategies

  • Inspect application logs for query strings whose url parameter does not begin with http: or https:
  • Add web application firewall (WAF) rules that reject requests with non-web URL schemes in the url parameter
  • Alert on outbound Playwright or Chromium child processes accessing sensitive files on disk

Monitoring Recommendations

  • Forward reverse-proxy and application logs from the screenshot host to a centralized analytics platform for query-parameter inspection
  • Baseline normal url parameter values and alert on deviations from the http/https scheme
  • Monitor egress and file-access telemetry from the container or host running the service

How to Mitigate CVE-2024-37169

Immediate Actions Required

  • Upgrade @jmondi/url-to-png to version 2.0.3 or later
  • Audit any exposed screenshot endpoints and restrict access to trusted callers with authentication or network controls
  • Review historical access logs for requests containing non-http/https schemes in the url parameter

Patch Information

Version 2.0.3 fixes the issue by adding a Zod refine check that rejects URLs whose protocol is not http: or https:. See the GitHub Release v2.0.3 and the GitHub Security Advisory GHSA-665w-mwrr-77q3 for details. Additional context is available in the GitHub Issue Discussion.

Workarounds

  • No official workarounds exist aside from upgrading, per the vendor advisory
  • As a compensating control, place the service behind a reverse proxy that validates the url query parameter and rejects any value not prefixed with http:// or https://
  • Run the service as an unprivileged user in an isolated container with a minimal file system to reduce the value of any file read
bash
# Example nginx compensating control: reject non-http(s) url parameters
location /screenshot {
    if ($arg_url !~* "^https?://") {
        return 400 "invalid url scheme";
    }
    proxy_pass http://url_to_png_upstream;
}

Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.

Sources: National Vulnerability Database, CISA KEV, Exploit-DB

Experience the Most Advanced Cybersecurity Platform

See how the world’s most intelligent, autonomous cybersecurity platform can protect your organization today and into the future.