/

CVE-2026-23627

Severity:

HIGH RISK

(8.8)

SQL Injection in OpenEMR Immunization Module

CVE-2026-23627

Analyzed

Vulnerability type

Category:

SQL Injection

CWE:

CWE-89

Impact:

Database Compromise and Potential Remote Code Execution

Severity:

HIGH RISK

(8.8)

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

An SQL injection flaw in OpenEMR's Immunization module allows any authenticated user to inject arbitrary SQL into database queries by abusing the patient_id parameter.

Under typical deployments, this can lead to full database compromise, exposure of protected health information (PHI), credential theft, and in some configurations potential remote code execution via database-level features.

Affected context

The vulnerability occurs in OpenEMR installations that use the Immunization module and accept user-controlled patient_id values as part of database lookup operations.

It is relevant where application users (including low-privileged or non-clinical roles) can influence patient identifiers through requests that reach the affected code path.

The risk is elevated in environments where the OpenEMR database stores PHI, user credentials, or where the database account has broad privileges, including write access or capabilities that can be chained to code execution.

Exploit preconditions

  • Attack surface: Web application endpoints associated with the Immunization module that consume a patient_id parameter.
  • Required access: Any authenticated user account with the ability to reach the vulnerable functionality (e.g., viewing or managing immunizations).
  • Trigger point: Submission of crafted patient_id values in HTTP requests that are later interpolated into SQL WHERE clauses.
  • Why exploitation is possible: The application constructs SQL statements by directly concatenating user-supplied patient_id input into query strings without parameterized queries or robust escaping, allowing attackers to alter the structure of the SQL command.

Why this happens

This issue stems from building SQL statements through string concatenation using untrusted input, a canonical example of CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection').

Instead of binding the patient_id as a typed parameter, the code interpolates it into the WHERE clause, so any SQL metacharacters or payloads included by an attacker are treated as part of the executable SQL.

The underlying bug class is insufficient separation between data and control instructions in database interactions, combined with over-trusting authenticated user input within the application boundary.

Potential impact

  • Full read access to the OpenEMR database, including PHI and other sensitive medical records.
  • Modification or deletion of clinical data, appointments, billing records, and audit trails.
  • Theft or manipulation of user and administrator credentials stored in the database.
  • Creation of backdoor accounts or alteration of authorization-related tables.
  • In some deployments, potential remote code execution via database-native features (e.g., execution of OS commands, loading of arbitrary extensions, or abuse of stored procedures), depending on database configuration and privileges.
  • Regulatory and compliance impact due to PHI exposure (e.g., HIPAA-related consequences in applicable jurisdictions).

General mitigation guidance

Effective mitigation focuses on consistently separating SQL control logic from user-supplied data and minimizing database privileges:

  • Replace all string-concatenated queries involving patient_id and similar inputs with parameterized queries or prepared statements, ensuring the database driver handles escaping and typing.
  • Adopt a central data access layer that enforces the use of safe query construction patterns and discourages ad hoc SQL string building.
  • Apply strict input validation to identifiers (e.g., numeric-only patient IDs) to reduce the attack surface, while not treating validation as a substitute for parameterization.
  • Ensure the application's database account follows least-privilege principles, granting only the minimal read/write operations required and avoiding unnecessary administrative rights.
  • Implement secure-by-default coding standards that ban direct concatenation of untrusted input in SQL and encourage the use of ORM or query builder patterns where appropriate.

How teams detect issues like this

Organizations can detect and monitor for this class of issue using a combination of preventive and detective controls:

  • Static analysis: Configure SAST tools or linters to flag dynamic SQL construction where user-controlled variables are concatenated into query strings, especially in modules handling PHI.
  • Code review: During peer review, explicitly look for direct use of request parameters in SQL, absence of prepared statements, and any bypass of centralized data access utilities.
  • Runtime monitoring: Use database auditing or application-layer logging to identify anomalous query patterns, such as unexpected UNION operations, stacked queries, or syntax errors in patient_id-driven queries.
  • Security testing: Integrate automated and manual application security testing (including authenticated SQL injection tests) into CI/CD workflows to catch regressions or new injection points.

Sources

SourceLink
github.comgithub.com/openemr/openemr/commit/cbf4ea4345b14a6c8362201e30c74ffb0949cdb1
github.comgithub.com/openemr/openemr/security/advisories/GHSA-x3hw-rwrg-v25h

Frequently asked

questions

Yes, if the OpenEMR instance is exposed over the network and an attacker can obtain or guess valid credentials. The flaw is reachable through normal web requests once authenticated, without requiring local system access.

No. The vulnerability can be triggered by any authenticated user who can interact with the Immunization module, regardless of whether they hold high-privilege roles. However, the eventual impact may be influenced by the database permissions configured for the application.

The most robust fix is to refactor all affected queries to use parameterized statements or equivalent safe query-building mechanisms. This should be enforced consistently across the module, ideally via a shared database abstraction that prevents direct concatenation of untrusted input into SQL.

Establish secure coding standards that mandate prepared statements for all database access, integrate static analysis focused on injection flaws into the development pipeline, and perform regular security reviews of modules handling sensitive data such as PHI. Combining these with least-privilege database accounts and strong input validation substantially reduces the risk of SQL injection.

Find out what's already
exploitable in your codebase.