/

CVE-2026-126491

Severity:

HIGH RISK

(7.6)

Stored SQL Injection (CWE-89) in OpenEMR Patient Search

CVE-2026-126491

Modified

Vulnerability type

Category:

Stored SQL Injection

CWE:

CWE-89

Impact:

Unauthorized disclosure of patient and user data

Severity:

HIGH RISK

(7.6)

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

OpenEMR contains a stored SQL injection vulnerability in patient demographic searches: values from the layout_options field_id are incorporated into a search query without adequate protection. A user with Layout Editor access could plant a malicious value that may later let an authenticated low-privilege user retrieve data from sensitive patient and user tables.

Affected context

The issue occurs in OpenEMR's getByPatientDemographics() patient-search functionality, where layout_options field identifiers are used to construct a WHERE clause. Deployments may be at risk when an attacker can edit layout configuration and the resulting values are later used in database queries without safe parameterization. The description identifies OpenEMR releases before 8.5.0 as affected.

Exploit preconditions

  • Attack surface: Patient demographic search and layout configuration.
  • Required access: The attacker planting the value needs Layout Editor access; the data-retrieving user needs an authenticated account.
  • Trigger point: A patient search processes the stored field_id value.
  • Why exploitation is possible: The value is concatenated into SQL rather than handled as a safely bound query parameter.

Why this happens

The underlying bug is stored SQL injection, mapped to CWE-89: Improper Neutralization of Special Elements used in an SQL Command. Application-controlled layout metadata is incorporated into a SQL statement as query text. When that value is not safely separated from SQL syntax, a planted value can alter the query's behavior when the search runs.

Potential impact

  • An authenticated user could retrieve information from patient_data.
  • An authenticated user could retrieve information from users_secure.
  • Sensitive patient or account data could be exposed beyond the user's intended access.

General mitigation guidance

Defensive patterns for this class of issue include:

  • Use parameterized queries for values and allowlist validation for identifiers that cannot be bound as parameters.
  • Treat stored layout metadata as untrusted input, even when it was created by a privileged user.
  • Keep database access scoped to the minimum permissions required by each operation.
  • Restrict Layout Editor access and review changes to layout configuration.
  • Apply authorization checks to search results so query behavior cannot bypass data-access boundaries.

How teams detect issues like this

  • Use static analysis to identify SQL statements built through string concatenation, especially where stored configuration or metadata is involved.
  • Review getByPatientDemographics() and adjacent query-building code for unsafe handling of field_id values.
  • Monitor and audit Layout Editor changes, and investigate unexpected modifications to layout metadata.
  • Enforce code-review or CI policies requiring parameterized queries and allowlisted SQL identifiers.

Sources

SourceLink
github.comgithub.com/openemr/openemr/security/advisories/GHSA-pc2q-9pcw-v899
vulncheck.comvulncheck.com/advisories/openemr-before-8.5.0-sql-injection-via-getbypatientdemographics-in-patient-inc-php

Frequently asked

questions

The described path uses stored layout configuration and patient search. Exploitation depends on access to the application and the ability to plant a malicious layout value; it is not described as unauthenticated access.

Planting the value requires Layout Editor access. The description indicates that a separate authenticated low-privilege user may then trigger a search that exposes data.

Keep SQL structure separate from data by using parameterized queries, and validate any identifiers that must be incorporated into query structure against a strict allowlist.

Treat stored configuration as untrusted, review query construction for concatenation, restrict configuration-editing privileges, and enforce secure query patterns in code review and automated checks.

Find out what's already
exploitable in your codebase.