Introduction
Electronic health record systems sit on some of the most sensitive data a healthcare provider holds, and the FHIR APIs that expose Patient resources are meant to be gated behind careful authorization. A recently patched flaw in OpenEMR shows how two small inconsistencies in OAuth scope handling can combine to let an unauthenticated attacker read, modify, and create Patient records as the API system user.
OpenEMR is a free, open source electronic health records and medical practice management platform maintained by a community of volunteers and contributors. A January 2023 HHS HC3 alert described it as used by more than 100,000 medical providers serving more than 200 million patients, which makes its OAuth and FHIR handling a meaningful part of the healthcare software ecosystem. CVE-2026-126473 affects versions before 8.4.0 and is classified as CWE-863, Incorrect Authorization.
Technical Information
The vulnerability is not a single bug. It is a chain of two separate authorization defects, each defeating a different control. Patching only one would leave part of the chain working.
Defect A: inconsistent scope canonicalization
OpenEMR's scope parser, ScopeEntity::createFromString(), accepts either a slash or a colon between the scope context and the resource. getScopeLookupKey() then converts either spelling to the canonical slash form. This means system:Patient.read is treated as a valid server scope, equivalent to system/Patient.read.
The approval gate, however, does not use the parsed representation. In 8.3.0, ScopeRepository::hasSystemScopes() searched the raw registration strings for the literal text system/:
private function hasSystemScopes(array $scopes): bool { return $this->scopeArrayHasString($scopes, 'system/'); }
Because the colon spelling never contains the literal system/, it evades this privileged scope check. ClientRepository::insertNewClient() then persists the client as enabled (is_enabled=1), bypassing the administrator approval requirement that privileged system/* clients are supposed to pass.
Defect B: incorrect permission containment
The second flaw is a logic bug in the legacy (v1) permission check. In 8.3.0, ScopeEntity::containsScope() returned the requested permission flag itself as the answer, so any request for .write was treated as already granted:
$otherPermissions = $otherScope->getPermissions(); if ($otherPermissions->v1Read) { return $otherPermissions->v1Read; } if ($otherPermissions->v1Write) { return $otherPermissions->v1Write; }
The same function backs both the server supported scope check in getScopeEntityByIdentifier() and the per-client check in finalizeScopes(). As a result, a client registered only for Patient read can receive Patient write, even though neither the server allowlist nor the client registration contains that system permission. Legacy .read maps to read plus search; .write maps to create, update, and delete.
Attack flow
Under the documented configuration (FHIR API enabled, system scopes enabled, automatic approval enabled), the demonstrated chain requires no OpenEMR account, no existing client, no admin action, no race, and no victim interaction:
- The attacker generates an RSA key pair locally and submits an unauthenticated dynamic client registration for the scope string
openid api:fhir system:Patient.read, embedding the public JWK, withtoken_endpoint_auth_methodofprivate_key_jwtandgrant_typesofclient_credentials. - The colon-form scope passes parsing and validation but evades the approval detector, so the client is persisted immediately enabled.
- The attacker requests a token for canonical
system/Patient.readusing aprivate_key_jwtclient assertion signed with RS384, receiving a usable system-read token. - A second token request adds the unregistered
system/Patient.write; the faulty containment check grants both read and write. - The tokens are used against
/apis/default/fhir/Patientto search, read, update (PUT), and create (POST) Patient records as the API system user, outside any patient or user context.
A validly issued OAuth token is not evidence that its permissions were correctly authorized. That is the core lesson of this chain.
Proof of Concept
A complete, working reproduction harness is published in the official OpenEMR advisory GHSA-6xh3-fmm5-jjp4. VulnCheck maps CVE-2026-126473 to that advisory, even though the GitHub advisory itself lists "No known CVE." The issue was reported by mcspicyenjoyer and tested against openemr/openemr:8.3.0-2026-08-20 (commit ebb62eb3036a726314ab3e1c3e9263a41608b17b).
The advisory's verifier exercises three canonical scope strings:
const canonicalReadScope = "openid api:fhir system/Patient.read"; const alternateReadScope = "openid api:fhir system:Patient.read"; const escalatedTokenScope = "openid api:fhir system/Patient.read system/Patient.write";
The client assertions are minted locally using the attacker-generated RSA key. The signing routine from colon_scope_verifier.mjs:
function clientAssertion(clientId) { const now = Math.floor(Date.now() / 1000); const header = { alg: "RS384", typ: "JWT", kid: publicJwk.kid }; const claims = { iss: clientId, sub: clientId, aud: tokenUrl, iat: now, exp: now + 240, jti: randomUUID(), }; const signingInput = `${base64UrlJson(header)}.${base64UrlJson(claims)}`; const signature = sign("RSA-SHA384", Buffer.from(signingInput), privateKey); return `${signingInput}.${signature.toString("base64url")}`; }
The PoC ships several artifacts:
poc/production-compose.yml, a disposable loopback-only Docker Compose usingmariadb:11.8.8and the 8.3.0 image, binding only127.0.0.1:8400and127.0.0.1:9400and setting the three requiredOPENEMR_SETTING_*variables.poc/setup.sqlandpoc/cleanup.sql, which insert and then fully remove a single synthetic victim Patient (id/pid8395301, pubpidcrit_auth_victim_20260821).poc/colon_scope_verifier.mjs, a self-contained Node.js 18+ differential verifier using only built-in APIs that refuses non-loopback targets.poc/verify.sh, a Bash runner that enforces loopback-only targets, seeds the fixture, asserts stored client states and exact DB write effects, and guarantees cleanup with six zero residual-count checks.
The expected differential on a vulnerable build, per the advisory: the slash-form control registration returns HTTP 200 but is persisted disabled (is_enabled=0) and its token request fails HTTP 401 invalid_client; the colon-form registration returns HTTP 200 and is persisted enabled (is_enabled=1); the colon canonical read token returns HTTP 200 granting system/Patient.read; the escalated token returns HTTP 200 granting both read and the unregistered system/Patient.write; the FHIR identifier search returns HTTP 200 with a Bundle total=1; direct read returns HTTP 200; update plus verify returns HTTP 200/200 with the controlled name changed to crit_auth_modified; and create returns HTTP 201. On a pristine site the first system-client token request may return HTTP 500 server_error ("Server was not properly setup"), and the verifier permits exactly one retry, which then succeeds.
This PoC was reviewed from the advisory, not independently executed, and the snippets above are reproduced exactly as published.
Patch Information
The fixed version is OpenEMR 8.4.0. The advisory lists < 8.4.0 as vulnerable and 8.4.0 as patched. The bookkeeping is a little confusing: the 8.4.0 release notes (published 2026-09-13) do not mention this advisory. It first appears in the Security Fixes list for 8.5.0 (published 2026-10-27), and the advisory itself went public on 2026-10-28. The v8_4_0 tag already contains corrections for both root causes, with no single public fix commit mapping one-to-one to the advisory.
Fix 1: colon can no longer pass as a different scope
In 8.4.0 the parser rejects the colon delimiter for any permission-bearing context. Only legacy SMART contexts that genuinely use a colon are allow-listed:
private const COLON_LEGACY_CONTEXTS = ['api', 'site']; ... private static function rejectNonLegacyColonDelimiter(string $scopeString): void { if (!preg_match('/^([a-zA-Z_]+):[a-zA-Z0-9\*_\-]+/', $scopeString, $matches)) { return; } if (in_array($matches[1], self::COLON_LEGACY_CONTEXTS, true)) { return; } throw new \InvalidArgumentException(sprintf( "Scope '%s' uses the colon delimiter for context '%s'; use the slash form ('%s/...') instead.", ...
createFromString() runs this check first, so getScopeEntityByIdentifier() catches the InvalidArgumentException and returns null for system:Patient.read. The approval check also stops searching strings and compares the parsed context instead:
private function hasSystemScopes(array $scopes): bool { return ScopeEntity::arrayHasContext($scopes, 'system'); }
hasUserScopes() gets the same change with 'user'. arrayHasContext() runs every scope through createFromString() and checks getContext() === $context, so even a respelled privileged scope would still count as system and still require administrator approval.
Fix 2: containsScope checks what the holder actually has
In 8.4.0, every requested permission is checked against $this->permissions, which holds what the server allowlist or client registration actually grants, and fails closed if anything is missing:
$otherPermissions = $otherScope->getPermissions(); $containsScope = true; if ($otherPermissions->v1Read && !$this->permissions->v1Read) { $containsScope = false; // We don't have v1 read permission } if ($otherPermissions->v1Write && !$this->permissions->v1Write) { $containsScope = false; // We don't have v1 write permission } if ($otherPermissions->read && !$this->permissions->read) { $containsScope = false; // We don't have read permission } // ...same pattern for create, update, delete, search return $containsScope;
Because this function backs both the server-supported-scope check in getScopeEntityByIdentifier() and the per-client check in finalizeScopes(), this one change closes the escalation at both boundaries. A client registered only for system/Patient.read can no longer get an unregistered system/Patient.write into its token, even a legitimately approved read-only client.
If you upgrade to 8.5.0 instead, you also get the closely related advisory GHSA-6cmr-r2rh-755m ("SMART/OAuth scope finalization can lead to unauthorized write-capable token scopes"), listed alongside further OAuth scope changes such as PR #14317.
Detection Methods
There are no ready-made Sigma, YARA, Suricata/Snort, or Nuclei rules for CVE-2026-126473, and no campaign IoCs. Detection depends on understanding the attack chain, since each step leaves records in reverse-proxy logs, OAuth logs, and the OpenEMR database.
1. Exposure triage
The chain only works in one configuration:
rest_fhir_api=1 rest_system_scopes_api=1 oauth_app_manual_approval=0
The first two are off by default; the third is the default value. Check whether each instance runs a version below 8.4.0 and has this configuration (via globals or OPENEMR_SETTING_* variables in container deployments). Manual approval blocks only the unauthenticated chain; the faulty write-scope check is still reachable through admin-approved read-only clients, so audit token checks even when manual approval is on.
2. Registration-time signal: colon-form resource scopes
The first step of an attack is an unauthenticated POST to the dynamic registration endpoint (/oauth2/default/registration) whose scope field uses a colon between the context and a resource, such as system:Patient.read. Legitimate SMART clients use the slash form. Ignore legitimate colon scopes like api:fhir and site:default, and alert specifically on system:, user:, or patient: followed by a resource name. Supporting indicators in the registration body include grant_types of client_credentials, token_endpoint_auth_method of private_key_jwt, and an attacker-generated public JWK embedded inline in jwks. This requires request-body logging on the registration endpoint.
3. Database hunt: enabled system clients nobody approved
The colon-form client is saved in oauth_clients already enabled. Review that table for rows whose stored scope contains a colon-form resource scope, and for enabled clients with system scopes that no administrator approved. Trace any suspicious client through api_token, api_refresh_token, oauth_trusted_user, and jwt_grant_history to show whether tokens were issued and used.
4. Token-issuance signal: granted scope larger than registered scope
In the exploit chain the client registered for read only, then asked the token endpoint (/oauth2/default/token) for system/Patient.read system/Patient.write and received both. The server's own allowlist adds Patient write only in the user context, so on a vulnerable build any issued token containing system/Patient.write or any system write permission is a strong indicator. Compare each token's granted scopes against the client's registered scope in oauth_clients and flag any token holding permissions the client never registered, remembering that legacy .write maps to create, update, and delete. A 500 followed by a 200 from a newly registered client is consistent with the published verifier's documented first-request behavior.
5. FHIR activity: correlate the full sequence
No single request proves exploitation. The strongest signal is the whole sequence from one client in a short window: registration with a colon scope, a token request (possibly 500 then 200), a second token request adding write, then GET searches and reads on /apis/default/fhir/Patient followed by PUT to /apis/default/fhir/Patient/{id} or POST to /apis/default/fhir/Patient (HTTP 201). These tokens act as the API system user, so watch especially for system-context Patient writes from recently registered clients and for records changed or created by the API system user without a known integration behind them.
6. Active verification: lab only
The advisory's differential verifier registers a slash-form control client and a colon-form test client. On a vulnerable build, the slash client is stored disabled and its token request fails HTTP 401 invalid_client, while the colon client is stored enabled and its token requests return HTTP 200 with read, then with both read and the unregistered write; the escalated token's search, read, and update return 200, and create returns 201. This test writes to patient records, refuses non-loopback targets, and is built for a disposable Docker lab. Use it only against lab builds, never production.
Affected Systems and Versions
All OpenEMR versions before 8.4.0 are affected. The controlled testing specifically used OpenEMR 8.3.0 (openemr/openemr:8.3.0-2026-08-20). The vulnerability is patched in OpenEMR 8.4.0. The demonstrated unauthenticated chain requires FHIR API enabled (rest_fhir_api=1), system scopes enabled (rest_system_scopes_api=1), and automatic application approval (oauth_app_manual_approval=0), with registration, token, and FHIR routes network-reachable. The first two settings default to off; automatic approval is the default. The containment defect remains reachable through admin-approved read-only clients even when manual approval is enabled.
Vendor Security History
OpenEMR has documented prior security cases involving distinct failure classes. The Sonar findings discussed by HHS HC3 combined unauthenticated file read, authenticated local file inclusion, and reflected XSS capable of instance takeover; HHS records initial reporting on October 24, 2022, followed by patched software (OpenEMR 7.0.0) on November 30, 2022. The fax/SMS disposeDocument advisory described file path and access control flaws permitting an authenticated user to read and write files and achieve code execution, patched in 8.3.0. These cases have different prerequisites and consequences, and the code execution finding in the disposeDocument case does not transfer to this OAuth vulnerability. The project identifies GitHub security advisory reporting as its preferred vulnerability reporting route.
References
- NVD: CVE-2026-126473
- CVE Record: CVE-2026-126473
- OpenEMR GitHub Security Advisory GHSA-6xh3-fmm5-jjp4
- VulnCheck Advisory: OpenEMR before 8.4.0 OAuth Authorization Bypass via Scope Canonicalization
- OpenEMR 8.4.0 Release
- ScopeEntity.php at v8_4_0
- ScopeRepository.php at v8_4_0
- GitHub Security Advisory API: GHSA-6xh3-fmm5-jjp4
- GitHub Release API: v8_4_0
- GitHub Release API: v8_5_0
- HHS HC3 Sector Alert: Multiple Vulnerabilities in OpenEMR
- VulnCheck Advisory: OpenEMR before 8.3.0 Arbitrary File Read/Write via disposeDocument
- GitHub Advisory GHSA-wf4w-mx2w-j4vv (disposeDocument)
- Securing OpenEMR Project Wiki
- OpenEMR Project Site



