8.2high
OpenMRS Core arbitrary file read via path traversal in ModuleResourcesServlet
- Severity
- 8.2high CVSS:4.0 by GitHub_M
- Exploit likelihood
- 0.56% (higher than 47% of CVEs; EPSS, by FIRST)
- Published
- Last changed
- Assigned by
- GitHub_M
- Also known as
- GHSA-jjgj-cx3q-pw4w
Description
OpenMRS Core is an open source electronic medical record system platform. In versions 2.7.8 and earlier and versions 2.8.0 through 2.8.5, the `/openmrs/moduleResources/{moduleid}` endpoint is vulnerable to a path traversal attack. The ModuleResourcesServlet constructs a filesystem path from user-controlled input without performing path boundary validation — the getFile() method concatenates the user-supplied path into an absolute filesystem path without calling normalize() or checking that the result stays within the allowed module resources directory. Because this endpoint serves static resources required for rendering the login page, it is not protected by authentication filters, allowing unauthenticated exploitation. An attacker can traverse directories and read arbitrary files from the server filesystem, including /etc/passwd and application configuration files containing database credentials. Successful exploitation requires the target deployment to run on Apache Tomcat versions prior to 8.5.31, where the ..; path parameter bypass is not mitigated by the container. Deployments on Tomcat 8.5.31 or later and Tomcat 9.0.10 or later are protected at the container level, though the underlying code defect remains. This issue has been fixed in versions after 2.7.8 (within the 2.7.x branch) and in version 2.8.6 and later.
Affected
| Product or package | Versions | Reported by |
|---|---|---|
| openmrs openmrs-core | <= 2.7.8, >= 2.8.0, <= 2.8.5 | CVE List |
| org.openmrs.web:openmrs-web (Maven) | up to 2.7.8, from 2.8.0 before 2.8.6 | GitHub Advisory Database |
| openmrs openmrs | up to 2.7.8, from 2.8.0 up to 2.8.5 | NVD |
All scores
| GitHub_M | 8.2high CVSS:4.0 | CVSS:4.0/AV:N/AC:L/AT:P/PR:N/UI:N/VC:H/VI:N/VA:N/SC:N/SI:N/SA:N |
| GitHub | 7.5high CVSS:3.1 | CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N |
| GitHub | high CVSS:4.0 | CVSS:4.0/AV:N/AC:L/AT:P/PR:N/UI:N/VC:H/VI:N/VA:N/SC:N/SI:N/SA:N |
| NVD | 7.5high CVSS:3.1 | CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N |
Classification
SSVC (CISA-ADP): exploitation poc, automatable yes, technical impact partial.
What each source says
CVE List
OpenMRS Core is an open source electronic medical record system platform. In versions 2.7.8 and earlier and versions 2.8.0 through 2.8.5, the `/openmrs/moduleResources/{moduleid}` endpoint is vulnerable to a path traversal attack. The ModuleResourcesServlet constructs a filesystem path from user-controlled input without performing path boundary validation — the getFile() method concatenates the user-supplied path into an absolute filesystem path without calling normalize() or checking that the result stays within the allowed module resources directory. Because this endpoint serves static resources required for rendering the login page, it is not protected by authentication filters, allowing unauthenticated exploitation. An attacker can traverse directories and read arbitrary files from the server filesystem, including /etc/passwd and application configuration files containing database credentials. Successful exploitation requires the target deployment to run on Apache Tomcat versions prior to 8.5.31, where the ..; path parameter bypass is not mitigated by the container. Deployments on Tomcat 8.5.31 or later and Tomcat 9.0.10 or later are protected at the container level, though the underlying code defect remains. This issue has been fixed in versions after 2.7.8 (within the 2.7.x branch) and in version 2.8.6 and later.
GitHub Advisory Database
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 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
- Identify a valid installed module ID on the target OpenMRS instance (e.g.,
legacyui). - Send the following HTTP request:
- The server responds with HTTP 200 and the contents of
/etc/passwd:
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.
NVD (es)
OpenMRS Core es una plataforma de sistema de registro médico electrónico de código abierto. En las versiones 2.7.8 y anteriores, y en las versiones 2.8.0 a 2.8.5, el endpoint '/openmrs/moduleResources/{moduleid}' es vulnerable a un ataque de salto de ruta. El ModuleResourcesServlet construye una ruta del sistema de archivos a partir de una entrada controlada por el usuario sin realizar una validación de límites de ruta - el método getFile() concatena la ruta proporcionada por el usuario en una ruta absoluta del sistema de archivos sin llamar a normalize() ni verificar que el resultado permanezca dentro del directorio de recursos del módulo permitido. Debido a que este endpoint sirve recursos estáticos necesarios para renderizar la página de inicio de sesión, no está protegido por filtros de autenticación, lo que permite la explotación no autenticada. Un atacante puede atravesar directorios y leer archivos arbitrarios del sistema de archivos del servidor, incluyendo /etc/p4ssd y archivos de configuración de aplicaciones que contienen credenciales de base de datos. La explotación exitosa requiere que la implementación objetivo se ejecute en versiones de Apache Tomcat anteriores a la 8.5.31, donde el bypass del parámetro de ruta '..;' no es mitigado por el contenedor. Las implementaciones en Tomcat 8.5.31 o posterior y Tomcat 9.0.10 o posterior están protegidas a nivel de contenedor, aunque el defecto de código subyacente permanece. Este problema ha sido solucionado en versiones posteriores a la 2.7.8 (dentro de la rama 2.7.x) y en la versión 2.8.6 y posteriores.
References
| https://github.com/openmrs/openmrs-core/security/advisories/GHSA-jjgj-cx3q-pw4w | exploit, mitigation, vendor-advisory, web | |
| https://nvd.nist.gov/vuln/detail/CVE-2026-40075 | advisory | |
| https://github.com/openmrs/openmrs-core | package | |
Sources
| Source | Record | Licence |
|---|---|---|
| CVE List | CVE-2026-40075 changed 2026-05-06 | CVE Terms of Use |
| GitHub Advisory Database | GHSA-jjgj-cx3q-pw4w changed 2026-05-08 | CC-BY-4.0 |
| NVD | CVE-2026-40075 changed 2026-07-24 | Public domain |