Vulnerability DatabaseCVE-2026-126491

CVE-2026-126491: 
OpenEMR vulnerability analysis and mitigation

Overview

CVE-2026-126491 is a stored (second-order) SQL injection vulnerability in OpenEMR's getByPatientDemographics() function located in library/patient.inc.php. It affects all OpenEMR versions before 8.5.0 and represents an incomplete fix for a prior related vulnerability, CVE-2026-33910. The flaw allows an attacker with Layout Editor (admin/super) access to plant a malicious field_id value in the layout_options table, which is then unsafely concatenated into a patient search SQL query — exploitable by any authenticated low-privilege user. It carries a CVSS v3.1 base score of 7.6 (High) and a CVSS v4.0 base score of 8.3 (High) (GitHub Advisory, Feedly).

Technical details

The root cause is CWE-89 (SQL Injection): the getByPatientDemographics() function at line 690 of library/patient.inc.php uses add_escape_custom() — which wraps mysqli_real_escape_string() — to sanitize field_id values fetched from layout_options before concatenating them as SQL column identifiers in a WHERE clause. String escaping is ineffective in identifier context, so a value like 1 OR 1=1 passes through unmodified and alters query logic. The sibling function getByPatientDemographicsFilter() (line 712) was correctly patched using escape_sql_column_name() (a whitelist-based column validator), but getByPatientDemographics() was missed. The malicious field_id can be planted via the Layout Editor UI or the UPDATE layout_options SQL path; the trigger endpoint interface/main/finder/patient_select.php with findBy=Any requires only a valid CSRF token and an authenticated session — no elevated ACL check is performed (GitHub Advisory).

Impact

Successful exploitation enables any authenticated low-privilege user (e.g., a Front Office account) to exfiltrate data from the patient_data and users_secure tables, exposing sensitive patient demographics and bcrypt password hashes. While the OpenEMR database user is least-privileged (file_priv=N, no stacked queries), the realistic attack chain extends from SQL injection to bcrypt hash exfiltration, offline cracking, and subsequent admin-level access — enabling further exploitation via admin-RCE primitives such as module installation, backup manipulation, or global configuration changes. The scope change (CVSS S:C) reflects that a low-privilege trigger session can access data beyond its own authorization boundary (GitHub Advisory).

Exploitability

A proof-of-concept is publicly available in the GitHub Security Advisory (GHSA-pc2q-9pcw-v899), including specific curl-based reproduction steps, the tautology payload (1 OR 1=1), and a Docker-based test environment. The exploit is classified as poc_steps with medium confidence by Feedly analysis. There is no evidence of in-the-wild exploitation at this time. The EPSS score is approximately 0.00346 (low probability of near-term exploitation), and the vulnerability is not listed in the CISA KEV catalog. Exploitation is not automatable without prior admin-level access to plant the payload (GitHub Advisory, Feedly).

Exploitation steps

  1. Reconnaissance: Identify an OpenEMR instance running a version prior to 8.5.0. Confirm access to the Layout Editor (requires admin or super role).
  2. Plant the malicious payload: Using the Layout Editor UI (Admin → Forms → Layouts → Demographics), rename a field's field_id (e.g., fname) to a SQL injection payload such as 1 OR 1=1. Alternatively, execute directly: UPDATE layout_options SET field_id='1 OR 1=1' WHERE form_id='DEM' AND title='Name' AND field_id='fname' AND uor != 0;
  3. Authenticate as a low-privilege user: Log in as any authenticated user (e.g., Front Office). Obtain a session cookie via POST to main_screen.php?auth=login.
  4. Obtain a CSRF token: Scrape csrf_token_form from any in-session page, e.g., GET /interface/main/finder/dynamic_finder.php.
  5. Trigger the vulnerable search: Send a GET request to patient_select.php?popup=0&findBy=Any&patient=ZZZZ_no_match&csrf_token_form=<token>. The planted field_id is concatenated into the WHERE clause of getByPatientDemographics(), turning it into a tautology.
  6. Extract leaked data: Parse the HTML response for <td class='srName'> and <tr class='oneresult' id=...> elements to read returned patient records that should not match the search term.
  7. Escalate (optional): Use boolean or error-based blind SQLi payloads (up to 31 chars, e.g., 1=(SELECT id FROM users_secure) or EXTRACTVALUE(1,USER())) to exfiltrate bcrypt hashes from users_secure, then crack offline and escalate to admin (GitHub Advisory).

Indicators of compromise

  • Network: Unusual GET requests to /interface/main/finder/patient_select.php with findBy=Any and a nonsensical or impossible patient= value (e.g., ZZZZ_no_match) returning a large number of patient rows; repeated access to this endpoint from low-privilege accounts.
  • Database: Unexpected values in layout_options.field_id that contain SQL keywords or operators (e.g., OR, =, SELECT, EXTRACTVALUE); audit SELECT form_id, field_id, title FROM layout_options WHERE form_id='DEM' for anomalous entries.
  • Logs: Web server access logs showing patient_select.php requests with findBy=Any from accounts that do not normally perform patient searches; abnormally large response sizes from this endpoint.
  • File System: No direct file artifacts expected, but review OpenEMR audit logs (log table) for unexpected patient data access events by low-privilege users.
  • Process: No unusual process behavior expected given the DB user's restricted privileges (GitHub Advisory).

Mitigation and workarounds

Upgrade OpenEMR to version 8.5.0 or later, which applies the correct fix by replacing add_escape_custom($row["field_id"]) with escape_sql_column_name($row["field_id"], ['patient_data']) in getByPatientDemographics(). As an interim workaround, restrict Layout Editor access strictly to trusted administrative accounts and audit the layout_options table for any field_id values containing SQL syntax. Additionally, implement database activity monitoring to alert on anomalous queries against patient_data and users_secure tables (GitHub Advisory).

Community reactions

The advisory was published by OpenEMR maintainer bradymiller on October 28, 2026, crediting researcher farisv (StarPlatinu) as the finder. The advisory explicitly frames this as an incomplete fix for a prior CVE (CVE-2026-33910), noting that the development team used the correct sanitization primitive (escape_sql_column_name) in the sibling function but failed to apply it consistently — characterizing it as "drift between two functions that were meant to be kept in sync" rather than a knowledge gap (GitHub Advisory).

Additional resources


Source: This report was generated using AI

Related OpenEMR vulnerabilities:

CVE ID

Severity

Score

Technologies

Component name

CISA KEV exploit

Has fix

Published date

CVE-2026-126491HIGH8.3
  • OpenEMR logoOpenEMR
  • cpe:2.3:a:open-emr:openemr
NoYesNov 13, 2026
CVE-2026-126494HIGH7.1
  • OpenEMR logoOpenEMR
  • cpe:2.3:a:open-emr:openemr
NoYesNov 13, 2026
CVE-2026-126492HIGH7.1
  • OpenEMR logoOpenEMR
  • cpe:2.3:a:open-emr:openemr
NoYesNov 13, 2026
CVE-2026-134020MEDIUM6.5
  • OpenEMR logoOpenEMR
  • cpe:2.3:a:open-emr:openemr
NoYesNov 23, 2026
CVE-2026-126493MEDIUM4.8
  • OpenEMR logoOpenEMR
  • cpe:2.3:a:open-emr:openemr
NoYesNov 13, 2026

Free Vulnerability Assessment

Benchmark your Cloud Security Posture

Evaluate your cloud security practices across 9 security domains to benchmark your risk level and identify gaps in your defenses.

Request assessment

Additional Wiz resources

Get a personalized demo

Ready to see Wiz in action?

"Best User Experience I have ever seen, provides full visibility to cloud workloads."
David EstlickCISO
"Wiz provides a single pane of glass to see what is going on in our cloud environments."
Adam FletcherChief Security Officer
"We know that if Wiz identifies something as critical, it actually is."
Greg PoniatowskiHead of Threat and Vulnerability Management