/

CVE-2026-126488

Severity:

HIGH RISK

(7.7)

SQL Injection (CWE-89) in OpenEMR OnsiteDocument.Query

CVE-2026-126488

Analyzed

Vulnerability type

Category:

SQL Injection

CWE:

CWE-89

Impact:

Unauthorized database read and exposure of sensitive information

Severity:

HIGH RISK

(7.7)

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's patient portal OnsiteDocument.Query endpoint has an SQL injection flaw involving certain criteria parameters. An authenticated patient may exploit it to read database records beyond their own patient scope, including other patients' demographics and users_secure password hashes.

Affected context

The issue occurs in the patient portal's OnsiteDocument.Query endpoint when _BitwiseAnd criteria values are incorporated into SQL queries. It is risky when authenticated portal users can supply these parameters and the resulting query does not properly constrain access to the requesting patient's records.

Exploit preconditions

  • Attack surface: Patient portal endpoint that processes OnsiteDocument.Query requests
  • Required access: An authenticated patient portal account
  • Trigger point: Processing of attacker-controlled _BitwiseAnd criteria parameters
  • Why exploitation is possible: The values are placed into SQL without adequate parameterization; escaping quote characters alone does not prevent SQL injection or preserve patient-level query boundaries

Why this happens

The endpoint constructs SQL using criteria values that are not safely bound as parameters. Escaping quote characters is not a reliable substitute for parameterized queries, particularly when values are inserted into SQL in an unquoted form. This is CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection').

Potential impact

  • An attacker could read records outside their own patient scope.
  • Sensitive demographic information belonging to other patients may be exposed.
  • The database may disclose users_secure password hashes.
  • Exposed information could be used for further account or privacy attacks.

General mitigation guidance

Defensive approaches focus on keeping user-controlled values out of SQL syntax and enforcing authorization at the data-access layer. Common patterns include:

  • Use parameterized queries with correctly typed and bound values.
  • Validate criteria against strict allowlists and expected data types.
  • Apply patient-level authorization constraints in every relevant query.
  • Limit database account privileges to the minimum required for the endpoint.
  • Avoid relying on character escaping as the primary SQL injection defense.

How teams detect issues like this

Review query-building code for concatenation or interpolation of request-controlled criteria, especially values inserted without quoting or binding. Static analysis can flag dynamically constructed SQL and missing parameterization; code review should verify both safe query construction and patient-scope authorization. Runtime policies and database monitoring can also help identify unusual query patterns or access to records beyond expected patient boundaries.

Sources

SourceLink
github.comgithub.com/openemr/openemr/security/advisories/GHSA-g2xw-rvhq-x543
vulncheck.comvulncheck.com/advisories/openemr-before-8.5.0-sql-injection-via-onsitedocument-query-bitwiseand

Frequently asked

questions

The described attack requires an authenticated patient portal account and access to the affected query functionality.

The flaw may allow an authenticated patient to read database data beyond their own patient scope, including other patients' demographics and password hashes.

Bind user-supplied values using parameterized queries, and enforce patient-level authorization independently of the query criteria.

Use strict input types and allowlists, avoid assembling SQL from untrusted values, review query construction with static analysis, and apply least-privilege database access.

Find out what's already
exploitable in your codebase.