/

CVE-2026-126492

Severity:

HIGH RISK

(7.1)

Second-Order SQL Injection (CWE-89) in OpenEMR Finder

CVE-2026-126492

Analyzed

Vulnerability type

Category:

Second-Order SQL Injection

CWE:

CWE-89

Impact:

Potential unauthorized database access or modification, depending on the affected query and database permissions

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 has a second-order SQL injection vulnerability in which a low-privileged authenticated user can store a malicious SQL fragment in a patient-column preference. The fragment may be executed later when dynamic_finder.php incorporates the stored value into a SELECT query.

Affected context

The issue affects OpenEMR versions before 8.5.0. It occurs when a value submitted through library/ajax/addlistitem.php is stored as the recent_patient_columns option's option_id, then later used by dynamic_finder.php to construct a SELECT query. Risk depends on the stored value reaching that query without adequate validation or safe SQL construction.

Exploit preconditions

  • Attack surface: OpenEMR's authenticated application functionality involving patient-column preferences
  • Required access: A low-privileged authenticated account able to submit and store the relevant preference value
  • Trigger point: A later operation that causes dynamic_finder.php to use the stored value in a SELECT query
  • Why exploitation is possible: The stored value is incorporated into SQL dynamically rather than being safely handled as data

Why this happens

This is a second-order SQL injection flaw mapped to CWE-89: Improper Neutralization of Special Elements used in an SQL Command. A value that may appear harmless when initially stored is later treated as part of SQL syntax when concatenated into a query. Storing input does not make it trustworthy; values must be safely handled at the point they are used in a database operation.

Potential impact

  • An attacker may be able to influence database query behavior.
  • Depending on query context and database permissions, sensitive records could be exposed.
  • Database data could be modified or deleted if the vulnerable query path permits it.
  • Application features that rely on the affected query could be disrupted.

General mitigation guidance

Common defensive patterns include:

  • Use parameterized queries for values and avoid concatenating user-controlled data into SQL.
  • Where dynamic identifiers or SQL fragments are required, select them from a strict, predefined allowlist rather than accepting arbitrary stored values.
  • Validate data at both storage and use boundaries; treat persisted user-controlled values as untrusted.
  • Apply least-privilege database permissions to limit the effects of unintended query behavior.

How teams detect issues like this

  • Use static analysis and taint tracking to identify user-controlled values flowing from storage into SQL construction.
  • Review code paths where preferences or other persisted input are later concatenated into queries.
  • Enforce parameterized-query and approved-identifier allowlist policies in code review and CI checks.
  • Monitor database and application logs for unexpected query patterns or errors associated with the affected functionality.

Sources

SourceLink
github.comgithub.com/openemr/openemr/security/advisories/GHSA-hrf6-qx6w-vgh9
vulncheck.comvulncheck.com/advisories/openemr-before-8.5.0-second-order-sql-injection-via-dynamic-finder-php

Frequently asked

questions

It can be reachable through the application by an authenticated user, provided that user can submit the relevant preference and trigger a later query that uses it.

The description identifies low-privileged authenticated access as sufficient to store the value. The stored value must subsequently be used by the affected query path.

Keep user-controlled data out of SQL syntax by using parameterized queries. If dynamic SQL identifiers are necessary, choose them only from a strict allowlist.

Track input through storage and into later query construction, treat persisted input as untrusted, and enforce secure query patterns through code review and automated checks.

Find out what's already
exploitable in your codebase.