
Differential PoC lab for CVE-2026-126473: exploits OpenEMR OAuth scope canonicalization and containment flaws to gain unauthenticated FHIR Patient write, with vuln/fixed/mitigation containers.
| CVE | CVE-2026-126473 (GHSA-6xh3-fmm5-jjp4, Critical 9.1 CVSS v3.1) |
| Component | OpenEMR — ScopeEntity (canonicalization + containsScope), ScopeRepository::hasSystemScopes, dynamic registration, client-credentials grant |
| Affected | < 8.4.0 (8.3.0 tested; official image 8.3.0-2026-08-20) |
| Fixed in | 8.4.0 — the colon-form resource scope is rejected at registration |
| CWE | CWE-863 (Incorrect Authorization) |
| Impact | An unauthenticated network attacker registers a colon-form system:Patient.read client that bypasses administrator approval, then obtains the unregistered system/Patient.write scope through the faulty containment check — yielding FHIR Patient create (and search) with a system token |
| Vector | Network: POST /oauth2/default/registration + POST /oauth2/default/token + FHIR endpoints; no account, no admin approval, no victim interaction |
| Trigger | Scope spelling system:Patient.read + token request with system/Patient.read system/Patient.write |
| Credit | Reported by @mcspicyenjoyer; advisory published by bradymiller (OpenEMR) |
OpenEMR 8.3.0 chains two independent OAuth scope defects into one unauthenticated compromise of the FHIR Patient record store. The scope parser accepts either / or : as the context delimiter, but the privileged-scope approval logic searches registration strings only for the literal system/ — so a client registered with system:Patient.read is persisted enabled while the identical slash-form client is persisted disabled. Independently, the legacy containment check containsScope() returns the requested permission instead of verifying the containing scope holds it, so the enabled read-only client obtains the unregistered system/Patient.write. The lab reproduces the complete chain against the official production image with database-level evidence of the approval differential, and demonstrates the fixed 8.4.0 build rejecting the colon-form registration outright.
Issue A — canonicalization inconsistency. ScopeEntity::createFromString() accepts either delimiter and getScopeLookupKey() canonicalizes to slash-form:
$regex = "/^([a-zA-Z_]+)(?:[\/:](https://github.com/googlesky/cve-2026-126473/blob/main/%5Ba-zA-Z0-9%5C%2A_%5C-%5D%2B)(?:\.([^\?]+))?)?(?:\?(.*))?$/";
// ...
return $this->context . '/' . $this->resource;
so system:Patient.read passes server scope validation. But the approval decision searches raw registration strings:
private function hasSystemScopes(array $scopes): bool
{
return $this->scopeArrayHasString($scopes, 'system/');
}
ClientRepository::insertNewClient() therefore persists the colon-form system client as enabled. The violated invariant: every system/* client requires administrator approval regardless of spelling.
Issue B — containment returns the requested permission. ScopeEntity::containsScope():
$otherPermissions = $otherScope->getPermissions();
if ($otherPermissions->v1Read) {
return $otherPermissions->v1Read;
}
if ($otherPermissions->v1Write) {
return $otherPermissions->v1Write;
}
asks "does the request carry write?" and answers itself. It is used for both the server-supported-scope check and the registered-client-scope check, so a read-only client receives system/Patient.write (create + update + delete) although neither the server allowlist nor its own registration contains it. The violated invariant: an issued token may contain only permissions the server supports and the client was granted.
| service | image | role |
|---|---|---|
mariadb | mariadb:11.8 | per-instance site databases |
openemr-vuln | openemr/openemr:8.3.0-2026-08-20 | vulnerable side, rest_fhir_api=1, rest_system_scopes_api=1, oauth_app_manual_approval=0 |
openemr-fixed | openemr/openemr:8.4.0 | fixed side, identical settings |
openemr-vuln-manual | 8.3.0-2026-08-20 | vulnerable side with the published mitigation (oauth_app_manual_approval=1) |
poc | — | stdlib Python driver (RSA via the openssl CLI) |
The three settings are applied through the image's documented OPENEMR_SETTING_* variables; the first two default off, the approval mode is the default. Every container is CPU/memory bounded on the isolated cve126473lab network and contains only synthetic Patient records created by the PoC itself.
./run-lab.sh build # PoC runner image
./run-lab.sh sweep # exploit (fresh vuln) / probe / mitigation / DB differential
./run-lab.sh down
Single mode:
podman run --rm --network=cve126473lab cve-2026-126473-poc:local exploit
poc/poc.py — stdlib-only Python (RSA keypair generated and parsed with the openssl CLI; OpenEMR requires RS384 client assertions — RsaSha384Signer — and validates the assertion audience against the token endpoint). Four modes:
| mode | purpose |
|---|---|
check | classify one instance: colon-form registration + read token + escalated scope request (creates one client — documented side effect) |
exploit | full differential on vuln and fixed: slash control disabled, colon enabled, unregistered write granted, FHIR create 201 |
probe | the flaws in isolation: Issue A behavioral pair, Issue B escalated scope, read-only-token FHIR search |
mitigation | the published workaround (oauth_app_manual_approval=1) on the same vulnerable binary — both spellings stay disabled; containment (Issue B) remains for approved clients |
Exit codes: 0 safe / workaround validated, 1 vulnerable, 2 target unreachable, 3 inconclusive, 4 internal error.
| reproduction path | vulnerable 8.3.0 | fixed 8.4.0 | evidence |
|---|---|---|---|
| slash control registration, canonical read token | registration 200, persisted is_enabled=0; token 401 invalid_client | same | evidence/poc-exploit.txt, evidence/db-is-enabled.txt |
colon registration system:Patient.read | 200, persisted is_enabled=1 — approval bypassed | registration 400 — colon-form scope rejected | evidence/db-is-enabled.txt, evidence/poc-exploit.txt |
| colon canonical read token | 200, system/Patient.read | 401 | evidence/poc-exploit.txt |
| colon escalated token (+ unregistered write) | 200, scope = system/Patient.read system/Patient.write | 401 | evidence/poc-exploit.txt |
| FHIR create with the escalated token | 201, synthetic Patient persisted (pid=1) | not reached | evidence/poc-exploit.txt |
| read-only token FHIR search | 200 | — | evidence/poc-probe.txt |
| mitigation: manual approval on the vulnerable binary | colon client stays disabled — token 401 | — | evidence/poc-mitigation.txt |
podman compose; --cpus 2 --memory 4g per container; isolated cve126473lab network.server_error; the advisory documents exactly one retry — the PoC permits it, deterministically.run-lab.sh sweep restarts the vulnerable instance for a clean run.