Summary
Medplum's /oauth2/register endpoint could disclose the client_secret of a preconfigured OAuth client when a supplied redirect_uri matched that client's configuration. An attacker who can identify or influence a matching redirect URI may obtain credentials that could enable unauthorized OAuth client use, depending on deployment configuration.
Affected context
The issue affects Medplum deployments using versions 4.1.10 through 5.1.6 where preconfigured OAuth clients are defined through the defaultOAuthClients server configuration. Risk arises when the registration endpoint returns sensitive client credentials based on a matching redirect_uri, rather than limiting disclosure to authorized administrative or provisioning workflows.
Exploit preconditions
- Attack surface: The
/oauth2/registerOAuth client registration endpoint - Required access: Ability to reach the endpoint and provide a redirect URI that matches a preconfigured client
- Trigger point: Processing of a registration request containing the matching
redirect_uri - Why exploitation is possible: The endpoint may include a preconfigured client's
client_secretin its response without adequately restricting access to that secret
Why this happens
The underlying issue is exposure of sensitive information through an externally reachable registration workflow. The endpoint associates caller-controlled redirect URI data with preconfigured OAuth client records and returns the corresponding secret, allowing a value intended to remain confidential to cross a trust boundary. This behavior maps to CWE-200: Exposure of Sensitive Information to an Unauthorized Actor.
Potential impact
- An attacker may obtain a preconfigured OAuth client's secret
- Unauthorized parties could impersonate or operate the affected OAuth client
- Downstream applications may accept requests associated with a compromised client identity
- The incident could increase the risk of unauthorized data access, depending on OAuth scopes and deployment permissions
General mitigation guidance
Mitigation generally focuses on preventing public registration workflows from returning secrets belonging to preconfigured clients.
Common defensive patterns include:
- Keep client secrets server-side and never include them in responses to untrusted callers
- Separate public client registration from administrative provisioning of confidential clients
- Treat redirect URIs as untrusted input and validate them against tightly controlled records
- Apply authentication and authorization checks before exposing client metadata
- Use least-privilege OAuth scopes and narrowly scoped client permissions
- Rotate potentially exposed secrets and review related access logs as part of incident response
How teams detect issues like this
Organizations can look for this class of issue through:
- Static analysis and code review checks for secrets returned from OAuth registration or discovery endpoints
- Tests that verify confidential client credentials never appear in responses to unauthenticated requests
- Review of redirect URI matching logic and trust-boundary transitions
- API gateway policies that restrict registration endpoints and redact sensitive response fields
- Monitoring for unexpected client registration requests, unusual redirect URIs, and access patterns associated with affected clients
Automated security testing can help identify sensitive fields exposed by API responses.

