# CVE-2026-40075: openmrs-web — Fixed in 2.8.6

☕ Maven

Not in CISA KEV

# CVE-2026-40075 — openmrs-web

CVE-2026-40075 is a Path Traversal vulnerability in org.openmrs.web:openmrs-web. A fix is available for org.openmrs.web:openmrs-web — see the affected versions and patch details below.

OpenMRS Core arbitrary file read via path traversal in ModuleResourcesServlet

Also known as[GHSA-jjgj-cx3q-pw4w](/vulnerability/GHSA-jjgj-cx3q-pw4w)

Published

May 5, 2026

Updated

Oct 28, 2026

Affected

2 pkgs

Patched

1 / 2

Exploits

None indexed

Exploitation data as of Nov 7, 2026 · OSV.dev, NVD, FIRST.org (EPSS)

## Exploitation Status

### Proof-of-concept exploit code exists

-   CISA’s SSVC triage found public proof-of-concept exploit code for this CVE, though no confirmed active exploitation.
-   CISA assesses this as automatable — exploitation doesn’t require manual, per-target effort, which raises the odds of mass scanning and opportunistic attacks.

Exploitation and automatability from CISA’s SSVC triage for CVE-2026-40075.

## EPSS Exploitation Probability

[via FIRST.org ↗](https://www.first.org/epss/)

0.6%probability of exploitation in next 30 days

Lower Risk0.00%

Lower risk than most CVEs47th percentile — riskier than 47% of all scored CVEsHighest risk

0.00%0.41%0.81%1.22%0.1%0.6%Jun 26Sep 26Nov 26

Probability of exploitation in the next 30 days, from [FIRST.org EPSS](https://www.first.org/epss/).

## Real-World Exposure

2 pkgs affected

☕`org.openmrs.web:openmrs-web`☕`org.openmrs.web:openmrs-web`

Real-time download stats are indexed for npm and PyPI packages. This vulnerability affects Maven packages — download data is not available via public APIs for these ecosystems.

## Description

### Affected Versions

version ≤ 2.7.8 (latest version at time of disclosure)

[https://github.com/openmrs/openmrs-core](https://github.com/openmrs/openmrs-core)

### Impact

The `/openmrs/moduleResources/{moduleid}` endpoint in OpenMRS Core is vulnerable to a path traversal attack. The `ModuleResourcesServlet` does not properly validate user-supplied path input, allowing an attacker to traverse directories and read arbitrary files from the server filesystem (e.g., `/etc/passwd`, application configuration files containing database credentials).

This endpoint serves static module resources (CSS, JS, images) and is **not protected by authentication filters**, as these resources are required for rendering the login page. Therefore, this vulnerability can be exploited by an **unauthenticated** attacker.

> **Note:** Successful exploitation requires the target deployment to run on **Apache Tomcat < 8.5.31**, where the `..;` path parameter bypass is not mitigated by the container. Deployments on Tomcat ≥ 8.5.31 / ≥ 9.0.10 are protected at the container level, though the underlying code defect remains.

### Steps to Reproduce

1.  Identify a valid installed module ID on the target OpenMRS instance (e.g., `legacyui`).
2.  Send the following HTTP request:

<img width="1038" height="798" alt="image" src="https://github.com/user-attachments/assets/7d10ee0e-4d81-4c01-bc84-a1bf5715f170" />

1.  The server responds with HTTP 200 and the contents of `/etc/passwd`:

<img width="1028" height="843" alt="image" src="https://github.com/user-attachments/assets/b6806a7e-ff52-4f51-8f7f-7ea4e9754d10" />

### Root Cause Analysis

The vulnerability exists in `ModuleResourcesServlet.java` (`web/src/main/java/org/openmrs/module/web/ModuleResourcesServlet.java`).

The `getFile()` method constructs a filesystem path from user-controlled input without performing path boundary validation:

```
protected File getFile(HttpServletRequest request) {
    // Step 1: User-controlled path input
    String path = request.getPathInfo();

    // Step 2: Extract module from path prefix
    Module module = ModuleUtil.getModuleForPath(path);
    if (module == null) { return null; }

    // Step 3: Strip module ID prefix — no traversal check
    String relativePath = ModuleUtil.getPathForResource(module, path);

    // Step 4: Concatenate into absolute path
    String realPath = getServletContext().getRealPath("")
        + MODULE_PATH
        + module.getModuleIdAsPath()
        + "/resources"
        + relativePath;  // contains "/../../../etc/passwd"

    realPath = realPath.replace("/", File.separator);

    // Step 5: No normalize().startsWith() boundary check
    File f = new File(realPath);
    if (!f.exists()) { return null; }

    return f;  // Arbitrary file returned to client
}
```

The helper method `ModuleUtil.getPathForResource()` only strips the module ID prefix and performs no sanitization:

```
public static String getPathForResource(Module module, String path) {
    if (path.startsWith("/")) {
        path = path.substring(1);
    }
    return path.substring(module.getModuleIdAsPath().length());
    // Returns unsanitized remainder, e.g., "/../../../../../../etc/passwd"
}
```

The resulting path resolves as:

```
{webapp}/WEB-INF/view/module/legacyui/resources/../../../../../../etc/passwd
  → /etc/passwd
```

Notably, the same codebase already implements correct path traversal protection in `StartupFilter.java`:

```
// StartupFilter.java — correct protection
fullFilePath = fullFilePath.resolve(httpRequest.getPathInfo());
if (!(fullFilePath.normalize().startsWith(filePath))) {
    log.warn("Detected attempted directory traversal...");
    return;  // Request rejected
}
```

This check is absent from `ModuleResourcesServlet`.

### Remediation

Add a path boundary check after constructing `realPath` and before returning the `File` object. The fix should use `normalize()` + `startsWith()` to ensure the resolved path stays within the allowed module resources directory:

```
File f = new File(realPath);
Path allowedBase = Paths.get(getServletContext().getRealPath(""), "WEB-INF", "view", "module");
if (!f.toPath().normalize().startsWith(allowedBase.normalize())) {
    log.warn("Blocked path traversal attempt: {}", request.getPathInfo());
    return null;
}
```

This is consistent with the existing pattern used in `StartupFilter.java` and `TestInstallUtil.java` within the same project.

## Affected Packages

2 total 1 fixed

Ecosystem

Package

Vulnerable range

Fix

☕Maven

`org.openmrs.web:openmrs-web` 

all versions

No fix

☕Maven

`org.openmrs.web:openmrs-web` 

≥ 2.8.0&&< 2.8.6

2.8.6`org.openmrs.web:openmrs-web:2.8.6`

## Affected Products

1 product · 2 configurations

Application

`openmrs`openmrs

≥ 2.8.0 && ≤ 2.8.5

range

## Detection & mitigation playbook

Open-source dependency

1.  ### Detect
    
    Scan your dependency tree (package-lock.json, pnpm-lock.yaml, requirements.txt, go.sum, etc.) for org.openmrs.web:openmrs-web, including transitive dependencies — a direct dependency you never call can still pull in a vulnerable version.
    
2.  ### Fix
    
    A fix is available for CVE-2026-40075; check the affected-versions list above or the advisory for the patched release of org.openmrs.web:openmrs-web, then make sure no transitive dependency still pins the vulnerable range.
    
3.  ### Workarounds
    
    Resolve every user-supplied path to its canonical form and reject anything that escapes the intended directory, and run the component under an account that has no read or write access outside the directory it legitimately serves.
    

## Frequently Asked Questions

\## Affected Versions version ≤ 2.7.8 (latest version at time of disclosure) https://github.com/openmrs/openmrs-core ## Impact The \`/openmrs/moduleResources/{moduleid}\` endpoint in OpenMRS Core is vulnerable to a path traversal attack. The \`ModuleResourcesServlet\` does not properly validate user-supplied path input, allowing an attacker to traverse directories and read arbitrary files from the server filesystem (e.g., \`/etc/passwd\`, application configuration files containing database credentials). This endpoint serves static module resources (CSS, JS, images) and is \*\*not protected by auth

O3 Security · Impact-Aware SCA

### Is CVE-2026-40075 in your dependencies?

Find it across Maven, including transitive dependencies.

[Scan my dependencies](/book-demo) [How O3 SCA works](/impact-aware-sca)