Skip to content

Commit c255349

Browse files
authored
Merge pull request modelcontextprotocol#449 from wdawson/wils/auth-cleanup
Various cleanups and standardizations to the authorization draft.
2 parents dc4fda9 + aa661ae commit c255349

File tree

1 file changed

+36
-27
lines changed

1 file changed

+36
-27
lines changed

docs/specification/draft/basic/authorization.mdx

Lines changed: 36 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,9 @@ while maintaining simplicity:
4848
1. MCP servers **MUST** implement OAuth 2.0 Protected Resource Metadata ([RFC9728](https://datatracker.ietf.org/doc/html/rfc9728)).
4949
MCP clients **MUST** use OAuth 2.0 Protected Resource Metadata for authorization server discovery.
5050

51-
1. MCP authorization servers and MCP clients **MUST** implement OAuth 2.0 Authorization
51+
1. MCP authorization servers **MUST** provide OAuth 2.0 Authorization
5252
Server Metadata ([RFC8414](https://datatracker.ietf.org/doc/html/rfc8414)).
53+
MCP clients **MUST** use the OAuth 2.0 Authorization Server Metadata.
5354

5455
### 2.1.1 OAuth Grant Types
5556

@@ -72,7 +73,8 @@ capable of accepting and responding to protected resource requests using access
7273
An MCP client acts as an [OAuth 2.1 client](https://www.ietf.org/archive/id/draft-ietf-oauth-v2-1-12.html#name-roles),
7374
making protected resource requests on behalf of a resource owner.
7475

75-
The authorization server is responsible for interacting with the user and issuing access tokens for use at the MCP server. The implementation details of the authorization server are beyond the scope of this specification. It may be the same server as the
76+
The authorization server is responsible for interacting with the user (if necessary) and issuing access tokens for use at the MCP server.
77+
The implementation details of the authorization server are beyond the scope of this specification. It may be hosted with the
7678
resource server or a separate entity. Section [2.3 Authorization Server Discovery](#2-3-authorizaton-server-discovery)
7779
specifies how an MCP server indicates the location of its corresponding authorization server to a client.
7880

@@ -83,7 +85,7 @@ clients can determine authorization server endpoints and supported capabilities.
8385

8486
### 2.3.1 Authorization Server Location
8587

86-
MCP servers **MUST** implement OAuth 2.0 Protected Resource Metadata ([RFC9728](https://datatracker.ietf.org/doc/html/rfc9728))
88+
MCP servers **MUST** implement the OAuth 2.0 Protected Resource Metadata ([RFC9728](https://datatracker.ietf.org/doc/html/rfc9728))
8789
specification to indicate the locations of authorization servers. The Protected Resource Metadata document returned by the MCP server **MUST** include
8890
the `authorization_servers` field containing at least one authorization server.
8991

@@ -95,15 +97,14 @@ Implementors should note that Protected Resource Metadata documents can define m
9597
[RFC9728 Section 7.6 "Authorization Servers"](https://datatracker.ietf.org/doc/html/rfc9728#name-authorization-servers).
9698

9799
MCP servers **MUST** use the HTTP header `WWW-Authenticate` when returning a _401 Unauthorized_ to indicate the location of the resource server metadata URL
98-
as described in OAuth 2.0 Protected Resource Metadata ([RFC9728](https://datatracker.ietf.org/doc/html/rfc9728)).
100+
as described in [RFC9728 Section 5.1 "WWW-Authenticate Response"](https://datatracker.ietf.org/doc/html/rfc9728#name-www-authenticate-response).
99101

100102
MCP clients **MUST** be able to parse `WWW-Authenticate` headers and respond appropriately to `HTTP 401 Unauthorized` responses from the MCP server.
101103

102104
#### 2.3.2 Server Metadata Discovery
103105

104-
MCP clients **MUST** follow the OAuth 2.0 Authorization Server Metadata protocol defined
105-
in [RFC8414](https://datatracker.ietf.org/doc/html/rfc8414) to obtain the information
106-
required to interact with the authorization server.
106+
MCP clients **MUST** follow the OAuth 2.0 Authorization Server Metadata [RFC8414](https://datatracker.ietf.org/doc/html/rfc8414)
107+
specification to obtain the information required to interact with the authorization server.
107108

108109
#### 2.3.4 Sequence Diagram
109110
The following diagram outlines an example flow:
@@ -147,7 +148,7 @@ For example: `MCP-Protocol-Version: 2024-11-05`
147148
### 2.5 Dynamic Client Registration
148149

149150
MCP clients and authorization servers **SHOULD** support the
150-
[OAuth 2.0 Dynamic Client Registration Protocol](https://datatracker.ietf.org/doc/html/rfc7591)
151+
OAuth 2.0 Dynamic Client Registration Protocol [RFC7591](https://datatracker.ietf.org/doc/html/rfc7591)
151152
to allow MCP clients to obtain OAuth client IDs without user interaction. This provides a
152153
standardized way for clients to automatically register with new authorization servers, which is crucial
153154
for MCP because:
@@ -200,18 +201,19 @@ sequenceDiagram
200201
A->>C: Access token (+ refresh token)
201202
C->>M: MCP request with access token
202203
M-->>C: MCP response
204+
Note over C,M: MCP communication continues with valid token
203205
```
204206

205207
### 2.7 Access Token Usage
206208

207209
#### 2.7.1 Token Requirements
208210

209-
Access token handling **MUST** conform to
210-
[OAuth 2.1 Section 5](https://datatracker.ietf.org/doc/html/draft-ietf-oauth-v2-1-12#section-5)
211-
requirements for resource requests. Specifically:
211+
Access token handling when making requests to MCP servers **MUST** conform to the requirements defined in
212+
[OAuth 2.1 Section 5 "Resource Requests"](https://datatracker.ietf.org/doc/html/draft-ietf-oauth-v2-1-12#section-5).
213+
Specifically:
212214

213-
1. MCP client **MUST** use the Authorization request header field
214-
[Section 5.1.1](https://datatracker.ietf.org/doc/html/draft-ietf-oauth-v2-1-12#section-5.1.1):
215+
1. MCP client **MUST** use the Authorization request header field defined in
216+
[OAuth 2.1 Section 5.1.1](https://datatracker.ietf.org/doc/html/draft-ietf-oauth-v2-1-12#section-5.1.1):
215217

216218
```
217219
Authorization: Bearer <access-token>
@@ -232,10 +234,10 @@ Authorization: Bearer eyJhbGciOiJIUzI1NiIs...
232234

233235
#### 2.7.2 Token Handling
234236

235-
Resource servers **MUST** validate access tokens as described in
236-
[Section 5.2](https://datatracker.ietf.org/doc/html/draft-ietf-oauth-v2-1-12#section-5.2).
237+
MCP servers, acting in their role as an OAuth 2.1 resource server, **MUST** validate access tokens as described in
238+
[OAuth 2.1 Section 5.2](https://datatracker.ietf.org/doc/html/draft-ietf-oauth-v2-1-12#section-5.2).
237239
If validation fails, servers **MUST** respond according to
238-
[Section 5.3](https://datatracker.ietf.org/doc/html/draft-ietf-oauth-v2-1-12#section-5.3)
240+
[OAuth 2.1 Section 5.3](https://datatracker.ietf.org/doc/html/draft-ietf-oauth-v2-1-12#section-5.3)
239241
error handling requirements. Invalid or expired tokens **MUST** receive a HTTP 401
240242
response.
241243

@@ -246,7 +248,6 @@ own resources.
246248

247249
MCP servers **MUST NOT** accept or transit any other tokens.
248250

249-
250251
### 2.8 Error Handling
251252

252253
Servers **MUST** return appropriate HTTP status codes for authorization errors:
@@ -259,32 +260,38 @@ Servers **MUST** return appropriate HTTP status codes for authorization errors:
259260

260261
## 3. Security Considerations
261262

262-
Implementations **MUST** follow OAuth 2.1 security best practices as laid out in [Section 7. Security Considerations](https://datatracker.ietf.org/doc/html/draft-ietf-oauth-v2-1-12#name-security-considerations).
263+
Implementations **MUST** follow OAuth 2.1 security best practices as laid out in [OAuth 2.1 Section 7. "Security Considerations"](https://datatracker.ietf.org/doc/html/draft-ietf-oauth-v2-1-12#name-security-considerations).
263264

264265
### 3.1 Token Theft
266+
265267
Attackers who obtain tokens stored by the client, or tokens cached or logged on the server can access protected resources with
266268
requests that appear legitimate to resource servers.
267269

268-
Clients **MUST** implement secure token storage and follow OAuth best practices,
269-
as outlined in [OAuth 2.1, section 7.1](https://datatracker.ietf.org/doc/html/draft-ietf-oauth-v2-1-12#section-7.1).
270+
Clients and servers **MUST** implement secure token storage and follow OAuth best practices,
271+
as outlined in [OAuth 2.1, Section 7.1](https://datatracker.ietf.org/doc/html/draft-ietf-oauth-v2-1-12#section-7.1).
270272

271-
MCP authorization servers SHOULD issue short-lived access tokens token to reduce the impact of leaked tokens. For public clients, MCP authorization servers MUST rotate refresh tokens as described in [Section 4.3.1 of OAuth 2.1](https://datatracker.ietf.org/doc/html/draft-ietf-oauth-v2-1-12#section-4.3.1).
273+
MCP authorization servers SHOULD issue short-lived access tokens token to reduce the impact of leaked tokens.
274+
For public clients, MCP authorization servers **MUST** rotate refresh tokens as described in [OAuth 2.1 Section 4.3.1 "Refresh Token Grant"](https://datatracker.ietf.org/doc/html/draft-ietf-oauth-v2-1-12#section-4.3.1).
272275

273276
### 3.2 Communication Security
274-
Implementations MUST follow [OAuth 2.1 section 1.5](https://datatracker.ietf.org/doc/html/draft-ietf-oauth-v2-1-12#section-1.5).
277+
278+
Implementations **MUST** follow [OAuth 2.1 Section 1.5 "Communication Security"](https://datatracker.ietf.org/doc/html/draft-ietf-oauth-v2-1-12#section-1.5).
275279

276280
Specifically:
281+
277282
1. All authorization server endpoints **MUST** be served over HTTPS.
278283
1. All redirect URIs **MUST** be either `localhost` or use HTTPS.
279284

280285
### 3.3 Authorization Code Protection
281286

282-
An attacker who has gained access to an authorization code contained in an authorization response can try to redeem the authorization code for an access token or otherwise make use of the authorization code. (Further described in [OAuth 2.1, section 7.5](https://datatracker.ietf.org/doc/html/draft-ietf-oauth-v2-1-12#section-7.5))
283-
284-
MCP clients **MUST** implement PKCE according to [OAuth 2.1 section 7.5.2](https://datatracker.ietf.org/doc/html/draft-ietf-oauth-v2-1-12#section-7.5.2). PKCE helps prevent authorization code interception and injection attacks by requiring clients to create a secret verifier-challenge pair, ensuring that only the original requestor can exchange an authorization code for tokens.
287+
An attacker who has gained access to an authorization code contained in an authorization response can try to redeem the authorization code for an access token or otherwise make use of the authorization code.
288+
(Further described in [OAuth 2.1 Section 7.5](https://datatracker.ietf.org/doc/html/draft-ietf-oauth-v2-1-12#section-7.5))
285289

290+
To mitigate this, MCP clients **MUST** implement PKCE according to [OAuth 2.1 Section 7.5.2](https://datatracker.ietf.org/doc/html/draft-ietf-oauth-v2-1-12#section-7.5.2).
291+
PKCE helps prevent authorization code interception and injection attacks by requiring clients to create a secret verifier-challenge pair, ensuring that only the original requestor can exchange an authorization code for tokens.
286292

287293
### 3.3 Open Redirection
294+
288295
An attacker may craft malicious redirect URIs to direct users to phishing sites.
289296

290297
MCP clients **MUST** have redirect URIs registered with the authorization server.
@@ -294,13 +301,15 @@ Authorization servers **MUST** validate exact redirect URIs against pre-register
294301
MCP clients **SHOULD** use and verify state parameters in the authorization code flow
295302
and discard any results that do not include or have a mis-match with the original state.
296303

297-
Authorization servers **MUST** take precautions to prevent redirecting user agents to untrusted URI's, following suggestions laid out in [OAuth 2.1, Section 7.12.2](https://datatracker.ietf.org/doc/html/draft-ietf-oauth-v2-1-12#section-7.12.2)
304+
Authorization servers **MUST** take precautions to prevent redirecting user agents to untrusted URI's, following suggestions laid out in [OAuth 2.1 Section 7.12.2](https://datatracker.ietf.org/doc/html/draft-ietf-oauth-v2-1-12#section-7.12.2)
298305

299306
Authorization servers **SHOULD** only automatically redirect the user agent if it trusts the redirection URI. If the URI is not trusted, the authorization server MAY inform the user and rely on the user to make the correct decision.
300307

301308
### 3.4 Confused Deputy Problem
302309

303-
Attackers can exploit MCP servers acting as intermediaries to third-party APIs, leading to confused deputy vulnerabilities. By using stolen authorization codes, they can obtain access tokens without user consent. See [Security Best Practices 2.1](/specification/draft/basic/security_best_practices) for details.
310+
Attackers can exploit MCP servers acting as intermediaries to third-party APIs, leading to confused deputy vulnerabilities.
311+
By using stolen authorization codes, they can obtain access tokens without user consent.
312+
See [Security Best Practices 2.1](/specification/draft/basic/security_best_practices) for details.
304313

305314
MCP proxy servers using static client IDs **MUST** obtain user consent for each dynamically
306315
registered client before forwarding to third-party authorization servers (which may require additional consent).

0 commit comments

Comments
 (0)