/

CVE-2026-124444

Severity:

HIGH RISK

(7.1)

SQL Injection (CWE-89) in OpenEMR OnsiteDocument API

CVE-2026-124444

Analyzed

Vulnerability type

Category:

SQL Injection

CWE:

CWE-89

Impact:

Unauthorized database access and sensitive data disclosure

Severity:

HIGH RISK

(7.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

OpenEMR's patient portal OnsiteDocument query API can incorporate request-controlled bitwise filter values directly into a SQL WHERE clause without quoting them safely. An authenticated patient portal user may exploit this behavior to read database records beyond their own, including other patients' information and staff password hashes.

Affected context

The issue affects the OnsiteDocument query API in OpenEMR versions before 8.4.0. It becomes risky when request parameters, including bitwise criteria such as Id_BitwiseAnd, are accepted and their values are inserted unquoted into SQL conditions without safe parameter handling.

Exploit preconditions

  • Attack surface: The patient portal OnsiteDocument query API
  • Required access: An authenticated patient portal account
  • Trigger point: A request that supplies a bitwise criteria parameter used to construct the SQL WHERE clause
  • Why exploitation is possible: Request-controlled values are incorporated into SQL without safe quoting or parameterization, allowing the query's logic to be altered

Why this happens

The underlying issue is unsafe construction of SQL from request parameters. The API allows mass-assigned filter values to influence a query, then places bitwise criteria values into the WHERE clause without treating them strictly as data. This is CWE-89: Improper Neutralization of Special Elements used in an SQL Command (SQL Injection).

Potential impact

  • An attacker may read records belonging to other patients.
  • Sensitive information in other database tables could be disclosed.
  • Staff password hashes may be exposed, potentially enabling further account compromise.
  • Broader database confidentiality could be affected, depending on the data accessible to the query.

General mitigation guidance

Defensive patterns focus on ensuring request data cannot alter SQL structure:

  • Use parameterized queries for values and construct SQL expressions from trusted, fixed templates.
  • Allowlist accepted filter names and types; reject unknown or unexpected fields rather than mass-assigning request parameters.
  • Validate bitwise criteria against a narrowly defined set of permitted values and operators.
  • Apply least-privilege database permissions so query paths have access only to the data they require.
  • Keep patient-level authorization checks separate from filtering, and enforce them on every query.

How teams detect issues like this

Review query-building code for request parameters that flow into SQL strings, especially filter maps, bitwise criteria, and unquoted values in WHERE clauses. Static analysis and code review can flag string concatenation or interpolation in SQL and mass assignment of request fields. Policy checks can require parameterized queries, allowlisted filters, and tests that verify patient-level authorization is enforced for API results.

Sources

SourceLink
github.comgithub.com/openemr/openemr/security/advisories/GHSA-hx8r-g8gw-6g2j
vulncheck.comvulncheck.com/advisories/openemr-before-8.4.0-sql-injection-via-onsitedocument-query-api

Frequently asked

questions

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

No. The SQL injection may allow queries to read other database records, including other patients' information and staff password hashes.

Keep SQL structure fixed and pass user-controlled values through parameterized queries. For filters that affect query structure, use strict allowlists and trusted templates.

Avoid mass-assigning request parameters into query filters, enforce authorization independently of filtering, and use code review and automated checks to detect unsafe SQL construction.

Find out what's already
exploitable in your codebase.