# CVE-2024-56331: Local File Inclusion (LFI) via Improper URL Handling in uptime-kuma's `Real-Browser` monitor

> Authenticated attackers can read sensitive local server files by exploiting improper URL validation in the real-browser monitor feature.

- **Severity:** Medium 6.8 (`CVSS:3.1/AV:N/AC:L/PR:L/UI:R/S:C/C:H/I:N/A:N`)
- **Exploited in the wild:** Not known
- **Login needed:** Any signed-in user
- **Attackable:** Over the internet
- **Victim action needed:** A user has to click or open something
- **Fix available:** Yes
- **Published:** 20 Dec 2024
- **Updated:** 27 Dec 2024
- **Also known as:** GHSA-2qgm-m29m-cj2h

## What is CVE-2024-56331?

CVE-2024-56331 is a medium-severity path traversal vulnerability in louislam uptime-kuma, published on 20 Dec 2024. Any signed-in user can exploit it over the network, and only if a user opens a file or follows a link.

### Official description

Uptime Kuma is an open source, self-hosted monitoring tool. 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. This 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. 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. Any **authenticated user** who can submit a URL in "real-browser" mode is at risk of exposing sensitive data through screenshots of these files. This issue has been addressed in version 1.23.16 and all users are advised to upgrade. There are no known workarounds for this vulnerability.

Weakness: CWE-22 (Improper Limitation of a Pathname to a Restricted Directory)

## Which versions are affected by CVE-2024-56331?

4 open source packages ship an affected version, including uptime-kuma.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `uptime-kuma` | npm | From 1.23.0 | 1.23.16 |
| `uptime-kuma` | npm | From 1.23.0 | 1.23.16 |
| `uptime-kuma` | npm | From 2.0.0-beta.0 | 2.0.0-beta.1 |
| `uptime-kuma` | npm | From 2.0.0-beta.0 | 2.0.0-beta.1 |

## How do I fix CVE-2024-56331?

Upgrade uptime-kuma to a fixed version for your release line: 1.23.16 or 2.0.0-beta.1.

## Is CVE-2024-56331 being exploited?

It is not confirmed as exploited in the wild, but public exploit code for CVE-2024-56331 exists.

Public exploit code:

- https://github.com/griisemine/CVE-2024-56331 (github_poc): https://github.com/griisemine/CVE-2024-56331

## Fix prompt for AI coding agents

```text
Check this codebase for CVE-2024-56331 and fix it if it is affected.

What it is: CVE-2024-56331 is a medium-severity path traversal vulnerability in louislam uptime-kuma, published on 20 Dec 2024. Any signed-in user can exploit it over the network, and only if a user opens a file or follows a link.
Exploitation: It is not confirmed as exploited in the wild, but public exploit code for CVE-2024-56331 exists.

Affected packages and fixed versions:
- uptime-kuma (npm): affected from 1.23.0; fixed in 1.23.16
- uptime-kuma (npm): affected from 1.23.0; fixed in 1.23.16
- uptime-kuma (npm): affected from 2.0.0-beta.0; fixed in 2.0.0-beta.1
- uptime-kuma (npm): affected from 2.0.0-beta.0; fixed in 2.0.0-beta.1

Task:
1. Search the dependency manifests and lockfiles (for example package.json, package-lock.json, requirements.txt, poetry.lock, uv.lock, pom.xml, build.gradle, go.mod, Cargo.lock, Gemfile.lock) and any Dockerfiles for the affected packages, including transitive dependencies.
2. If an affected version is in use, upgrade it to the fixed version for its release line with the project's package manager, so the lockfile is regenerated. Prefer the smallest upgrade that fixes it.
3. If there is no fix, or the upgrade would break the build, do not guess: explain the risk and the safest workaround instead.
4. Run the tests and summarise what changed and why.
5. If nothing in the project is affected, say so and change nothing.

Reference: https://insights.sbomify.com/CVE-2024-56331/ (Markdown: https://insights.sbomify.com/CVE-2024-56331/index.md)
```

## Sources

- CVE record: https://www.cve.org/CVERecord?id=CVE-2024-56331
- NVD: https://nvd.nist.gov/vuln/detail/CVE-2024-56331
- OSV: https://osv.dev/vulnerability/CVE-2024-56331

---
From sbomify Insights: https://insights.sbomify.com/CVE-2024-56331/
Summaries are generated and may contain mistakes; the official description above is the record.
