/

CVE-2026-29187

Severity:

HIGH RISK

(8.1)

SQL Injection in OpenEMR Patient Search Parameters

CVE-2026-29187

Analyzed

Vulnerability type

Category:

SQL Injection

CWE:

CWE-89

Impact:

Data Exposure and Manipulation via Blind SQL Injection

Severity:

HIGH RISK

(8.1)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

A blind SQL injection flaw in OpenEMR's Patient Search popup allows crafted HTTP parameter keys to alter backend SQL queries.

When an authenticated user can control parameter names in requests to the search endpoint, they may inject arbitrary SQL, impacting the confidentiality and integrity of medical records.

Affected context

This vulnerability occurs in OpenEMR's Patient Search functionality at /interface/new/new_search_popup.php.

It is exposed when:

  • Users are authenticated into OpenEMR,
  • The server processes patient search requests based on HTTP parameters,
  • SQL query construction trusts parts of the HTTP request, including parameter keys, without rigorous validation or parameterization.

The issue is tied to how search filters and inputs are mapped into SQL clauses for querying patient data.

Exploit preconditions

  • Attack surface: HTTP(S) interface of the OpenEMR application, specifically the Patient Search popup endpoint.
  • Required access: Valid authenticated session (e.g., clinician, staff, or any user role with access to patient search).
  • Trigger point: Submission of a crafted request where the HTTP parameter names (keys) are manipulated to alter the SQL query structure.
  • Why exploitation is possible: The server-side code interpolates request parameter keys directly into SQL fragments, without strict whitelisting or prepared statements for dynamic identifiers, enabling an attacker to influence the query logic through blind SQL injection techniques.

Why this happens

The root cause aligns with CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection').

Instead of treating HTTP parameters as untrusted input requiring strict handling, the Patient Search implementation appears to:

  • Dynamically construct SQL statements using parameter keys to build column lists, filters, or conditions.
  • Omit robust validation of parameter names against a fixed, known-safe set of columns or operators.
  • Rely on string concatenation or similarly unsafe patterns when building SQL queries.

Because parameter keys are not properly constrained or parameterized, an attacker can introduce SQL syntax in places the application assumes are "safe," resulting in blind SQL injection where responses must be inferred indirectly (e.g., via timing or boolean conditions).

Potential impact

  • Extraction of sensitive patient information and medical records through crafted blind queries.
  • Unauthorized modification or deletion of patient data and related clinical records.
  • Tampering with practice management data such as appointments, billing, or user accounts.
  • Potential creation of backdoor administrative accounts or escalation of privileges at the application layer.
  • Indirect impact on data availability, including causing query failures or partial denial of service by breaking SQL logic.

General mitigation guidance

Effective mitigation focuses on enforcing strict separation between untrusted input and SQL construction:

  • Constrain request parameters to a whitelisted set of known-safe keys (e.g., predefined column names and operators) and reject any unexpected parameters.
  • Use prepared statements and parameterized queries for all data values, and avoid concatenating user input into SQL fragments.
  • For dynamic query building (such as optional search filters), construct the SQL using server-side constants and safe mappings, not user-controlled strings.
  • Normalize and validate input types (e.g., integers, dates, enumerations) before including them in query logic.
  • Apply least-privilege database accounts so that the application's DB user can perform only the minimum required operations.
  • Introduce centralized query-building utilities or an ORM pattern that discourages raw string composition of SQL.

How teams detect issues like this

Organizations can identify similar SQL injection patterns using multiple complementary approaches:

  • Static analysis: Configure SAST tools or custom rules to flag raw SQL concatenation involving $_GET, $_POST, or framework request objects, including use of variable keys when building field lists or WHERE clauses.
  • Code review: Manually inspect search and filtering code paths for:
  • Dynamic construction of column names, order-by fields, or operators from request parameter keys.
  • Absence of strict whitelists and type checks for all dynamic components.
  • Direct use of superglobals or request objects in SQL strings.
  • Runtime testing: Use DAST or manual security testing to:
  • Send requests with malformed or SQL-like parameter keys and look for behavior changes, timing anomalies, or database error patterns.
  • Evaluate boolean and time-based blind injection indicators without relying on explicit error messages.
  • Database monitoring: Enable logging and monitoring for unusual query patterns, such as injected tautologies, unexpected functions, or anomalous WHERE clauses driven by user input.

Sources

SourceLink
github.comgithub.com/openemr/openemr/commit/c61887aa7c83e83b3282db05246f1c00de3aa21d
github.comgithub.com/openemr/openemr/releases/tag/v8_0_0_3
github.comgithub.com/openemr/openemr/security/advisories/GHSA-2r7h-xm8v-m872

Frequently asked

questions

Yes, if the OpenEMR instance is exposed over the internet and an attacker can obtain valid credentials, they can reach the vulnerable Patient Search endpoint through standard HTTP(S) requests.

Yes. The vulnerability is in an authenticated patient search feature, so a valid user session with access to that functionality is required.

The safest approach is to strictly whitelist allowed parameter keys, map them to predefined column names or operations on the server side, and use parameterized queries for all variable parts of the SQL, avoiding any direct concatenation of user-controlled strings.

Adopt secure query-building patterns (ORMs or centralized query helpers), enforce code review rules that ban ad-hoc SQL string concatenation with request data, integrate SAST/DAST into CI pipelines to detect injection primitives early, and maintain clear input validation and whitelisting guidelines for all search and filtering features.

Find out what's already
exploitable in your codebase.