# CIMD Security

Learn how FusionAuth protects itself when it fetches a Client ID Metadata Document from a URL a third party controls.

> For the index of this section of the site, see [llms.txt](https://fusionauth.io/docs/llms.txt)

> **PLAN:** This feature requires [an Enterprise plan](https://fusionauth.io/docs/get-started/core-concepts/plans-features.md#enterprise-features).

Available since `1.70.0`

A [Client ID Metadata Document](https://fusionauth.io/docs/lifecycle/authenticate-users/oauth/client-registration.md#client-id-metadata-documents) (CIMD) client uses a URL as its `client_id`. The first time that client logs in, FusionAuth fetches the document from that URL. The client, and so the URL, is controlled by a third party, so FusionAuth treats every fetch as untrusted input. This page describes the protections FusionAuth applies and the ones you configure.

## Protections On The Fetch

### The `client_id` URL

FusionAuth checks the `client_id` URL before it sends any request. The URL must meet all of these requirements:

*   The scheme is `https`.
*   The path is more than `/`, such as `/oauth/client.json`.
*   There is no fragment and no user info.
*   The URL is at most 2048 characters long.

FusionAuth rejects any other URL without fetching it.

### Where FusionAuth Will Connect

Because the URL comes from an outside party, an attacker could point it at a system inside your network. FusionAuth guards against this server-side request forgery (SSRF) by refusing to fetch from private, loopback, link-local and cloud-metadata addresses. FusionAuth also blocks other addresses that aren't publicly routable, including carrier-grade NAT (`100.64.0.0/10`), the IETF documentation and benchmarking ranges, multicast, and IPv6 addresses that embed a blocked IPv4 address.

FusionAuth resolves the host once and checks every address it returns. If any address is blocked, FusionAuth doesn't fetch the document. Otherwise, it connects to the first address and doesn't look up the host again for that fetch, so a DNS record that changes between the check and the connection can't redirect the request. When FusionAuth is configured with an outbound proxy, it sends the fetch through the proxy to the same checked address.

### The Request And Response

*   FusionAuth doesn't follow redirects, so a document can't send FusionAuth somewhere the URL checks didn't cover.
*   FusionAuth waits up to 2 seconds to connect and 5 seconds for the response.
*   FusionAuth accepts a `2xx` response of at most 5KB.
*   The `client_id` in the document must match the requested URL exactly. A document that names a different `client_id` is rejected.

### Failures Aren't Cached

FusionAuth caches only a document it accepted. An invalid document, an error response, or a failed fetch isn't cached, so fixing the document takes effect on the next login attempt instead of after a cache window.

## Protections You Configure

### Limit Who Can Register

A CIMD domain controls which clients can register. A domain that matches a specific origin accepts only clients whose `client_id` is on that origin. The `*` domain, or open mode, accepts any client that publishes a valid document.

In open mode, the [registration lambda](https://fusionauth.io/docs/extend/code/lambdas/cimd-client-registration.md) is the only thing that decides which clients FusionAuth accepts. Write a lambda that rejects any client you don't recognize, for example by checking `clientMetadata.clientId` against an allowlist, before you enable the `*` domain.

### Limit Registration Volume

Each new registration triggers an outbound fetch. Use [rate limiting](https://fusionauth.io/docs/operate/secure/advanced-threat-detection.md#customizable-rate-limiting) to cap how many new registrations a user can start in a time window.

### Limit Cache Lifetime

A shorter **Maximum cache duration** on the CIMD domain makes changes to a client, or a revocation through the lambda, take effect sooner, although FusionAuth never caches a document for less than 15 minutes. See [CIMD Registration Caching And Lifecycle](https://fusionauth.io/docs/lifecycle/authenticate-users/oauth/cimd-registration-lifecycle.md) for how FusionAuth calculates the cache window.

## Troubleshooting

If FusionAuth rejects your client, see [Host A Client ID Metadata Document](https://fusionauth.io/docs/lifecycle/authenticate-users/oauth/host-cimd-document.md#troubleshooting) to check your document and request against these requirements.

Related

[Lifecycle CIMD Registration Caching And Lifecycle Learn how long FusionAuth caches a Client ID Metadata Document, what happens when it expires, and how a CIMD client registration is refreshed or removed. cimdclient id metadata documentoauth client registration](https://fusionauth.io/docs/lifecycle/authenticate-users/oauth/cimd-registration-lifecycle.md)

[Lifecycle Host A Client ID Metadata Document (CIMD) Publish a Client ID Metadata Document so your OAuth client can log in to FusionAuth without being registered ahead of time. cimdclient id metadata documentoauth client registration](https://fusionauth.io/docs/lifecycle/authenticate-users/oauth/host-cimd-document.md)

[Extend CIMD Client Registration Lambda An overview of the CIMD client registration lambda. client id metadata documentcimdoauth client registration](https://fusionauth.io/docs/extend/code/lambdas/cimd-client-registration.md)

[Lifecycle OAuth Client Registration | Static and CIMD Learn how FusionAuth registers OAuth clients, either ahead of time as Applications or just-in-time from a Client ID Metadata Document. cimdclient id metadata document](https://fusionauth.io/docs/lifecycle/authenticate-users/oauth/client-registration.md)
---

## Other pages in Secure

> For the full index of this section, see [Operate](https://fusionauth.io/docs/llms-operate.txt).

- [Advanced Threat Detection](https://fusionauth.io/docs/operate/secure/advanced-threat-detection.md): Learn about the FusionAuth Advanced Threat Detection feature that provides various tools to secure your application.
- [Breached Password Detection](https://fusionauth.io/docs/operate/secure/breached-password-detection.md): Learn how to configure and use breached password detection.
- [Compliance Frameworks](https://fusionauth.io/docs/operate/secure/compliance.md): Learn how FusionAuth conforms to various compliance frameworks.
- [CORS Reference](https://fusionauth.io/docs/operate/secure/cors.md): Learn about FusionAuth and Cross-Origin Resource Sharing (CORS) configuration.
- [Secure](https://fusionauth.io/docs/operate/secure.md): Learn how to secure your installation by limiting network traffic.
- [Key Master](https://fusionauth.io/docs/operate/secure/key-master.md): An overview of FusionAuth Key Master, used to manage signing keys and certificates.
- [Key Rotation](https://fusionauth.io/docs/operate/secure/key-rotation.md): Learn how to rotate keys in FusionAuth.
- [Networking Configuration](https://fusionauth.io/docs/operate/secure/networking.md): Learn about FusionAuth networking configuration, especially IP resolution.
- [Token Storage](https://fusionauth.io/docs/operate/secure/token-storage.md): Learn how to secure tokens generated by FusionAuth.
