Skip to content

Commit 9420b5d

Browse files
acoburnTallTed
andauthored
Use RFC-9728 OAuth 2.0 Protected Resource Metadata for auth discovery (#256)
* Use RFC-9728 OAuth 2.0 Protected Resource Metadata for auth discovery * Update lws10-core/Authorization.html Co-authored-by: Ted Thibodeau Jr <[email protected]> * Add client discovery validation requirements * Add atrisk label --------- Co-authored-by: Ted Thibodeau Jr <[email protected]>
1 parent 47ca4b7 commit 9420b5d

3 files changed

Lines changed: 151 additions & 27 deletions

File tree

‎lws10-core/Authorization.html‎

Lines changed: 95 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -45,21 +45,18 @@ <h4>Authorization Server Discovery</h4>
4545
</p>
4646

4747
<p>
48-
A storage server generating a 401 (Unauthorized) response MUST send a <code>WWW-Authenticate</code> header
49-
field containing at least one conforming challenge. A conforming challenge will include the parameters described below:
48+
A storage server generating a 401 (Unauthorized) response MUST send a <code>WWW-Authenticate</code> header field
49+
containing at least one conforming challenge. A conforming challenge MUST include the
50+
<code>resource_metadata</code> parameter defined in Section 5.1 of [[!RFC9728]], whose value is the URL of the
51+
<a>protected resource metadata</a> document for the requested resource.
5052
</p>
5153

52-
<ul>
53-
<li>
54-
<strong><code>as_uri</code> REQUIRED</strong> — The value of this parameter is a URI identifying the authorization server
55-
where a client can retrieve an access token. The value of this parameter will be the same as the <code>iss</code> claim of a valid access token.
56-
</li>
57-
<li>
58-
<strong><code>realm</code> REQUIRED</strong> — The value of this parameter is a URI indicating the scope of protection.
59-
This value will be included in the audience (<code>aud</code>) claim of an access token. A client MUST verify that
60-
the URI of the originating request is logically contained within the <code>realm</code> presented in this response.
61-
</li>
62-
</ul>
54+
<p>
55+
The response MUST also include a <code>Link</code> header identifying the <a>storage</a> that contains the
56+
requested resource, as described in <a href="#storage-description-binding"></a>. A client supplies this URI as the
57+
<code>resource</code> parameter when requesting an access token, as described in
58+
<a href="#authorization-token-exchange-request"></a>.
59+
</p>
6360

6461
<p>
6562
Other headers and parameters MAY be included.
@@ -72,12 +69,82 @@ <h4>Authorization Server Discovery</h4>
7269
<pre id="example-unauthorized-response" class="example">
7370
HTTP/2 401 Unauthorized
7471
Link: &lt;https://storage.example/storage_1&gt;; rel="https://www.w3.org/ns/lws#storage"
75-
WWW-Authenticate: Bearer as_uri="https://authorization.example",
76-
realm="https://storage.example/storage_1",
72+
WWW-Authenticate: Bearer resource_metadata="https://storage.example/.well-known/oauth-protected-resource/storage_1/photos/img.jpg",
7773
error="invalid_token"
7874
</pre>
7975
</section>
8076

77+
<section id="protected-resource-metadata">
78+
<h4>Protected Resource Metadata</h4>
79+
80+
<p class="issue atrisk">
81+
The Working Group is actively seeking implementer feedback on Protected Resource Metadata support.
82+
If sufficient implementation experience is not gathered, this feature may be removed or changed.
83+
</p>
84+
85+
<p>
86+
A <dfn>protected resource metadata</dfn> document describes how a client can obtain an access token for a
87+
resource. It MUST conform to OAuth 2.0 Protected Resource Metadata [[!RFC9728]].
88+
</p>
89+
90+
<p>
91+
This specification extends [[RFC9728]] as follows: the <code>authorization_servers</code> parameter is REQUIRED in
92+
a protected resource metadata document, and its value MUST contain the issuer identifier of at least one
93+
authorization server.
94+
</p>
95+
96+
<p class="note">
97+
The <code>resource</code> value in a protected resource metadata document identifies the requested resource, not
98+
the <a>storage</a> that contains it. By contrast, the <code>resource</code> parameter of a token request
99+
identifies the storage, which becomes the audience of the access token.
100+
</p>
101+
102+
<p>
103+
An example protected resource metadata document is included below.
104+
</p>
105+
106+
<pre id="example-protected-resource-metadata" class="example">
107+
{
108+
"resource": "https://storage.example/storage_1/photos/img.jpg",
109+
"authorization_servers": ["https://authorization.example"]
110+
}
111+
</pre>
112+
</section>
113+
114+
<section id="authorization-discovery-validation">
115+
<h4>Discovery Validation by a Client</h4>
116+
117+
<p>
118+
The values a client uses to obtain an access token are supplied by the storage server in a 401 (Unauthorized)
119+
response. Before requesting an access token, a client MUST perform the following checks, each of which compares a
120+
discovered value against the requested URI that produced the 401 response. If any check fails, the client MUST NOT
121+
use the discovered values to request an access token.
122+
</p>
123+
124+
<ul>
125+
<li>
126+
The <code>resource_metadata</code> URL MUST have the same scheme and authority as the requested URI.
127+
</li>
128+
<li>
129+
The <code>resource</code> value of the <a>protected resource metadata</a> document MUST be identical to the
130+
requested URI, as required by Section 3.3 of [[!RFC9728]].
131+
</li>
132+
<li>
133+
The client MUST obtain the <a>storage description</a> of the <a>storage</a> identified by the <code>Link</code>
134+
header, and the <code>serviceEndpoint</code> of its <code>StorageRoot</code> service MUST have the same scheme
135+
and authority as the requested URI.
136+
</li>
137+
</ul>
138+
139+
<p class="note">
140+
These checks ensure that the protected resource metadata and the storage both describe the server to which the
141+
client sent its request, so that the TLS server authentication described in Section 7.3 of [[RFC9728]] applies to
142+
the metadata. Without them, a malicious server could cause a client to obtain an access token for a different
143+
storage and then replay that token. A client can cache a storage description to avoid retrieving it before each
144+
token request. See <a href="#security-resource-discovery"></a>.
145+
</p>
146+
</section>
147+
81148
<section id="authorization-server-metadata">
82149
<h4>Authorization Server Metadata</h4>
83150

@@ -162,10 +229,11 @@ <h5>Request</h5>
162229
</p>
163230

164231
<ul>
165-
<li>The <code>resource</code> parameter is REQUIRED. The value of this parameter MUST be a URI and will be used to populate the
166-
<code>aud</code> (audience) claim in the resulting access token. The supplied value will be the same as the
167-
<code>realm</code> parameter response in a <code>WWW-Authenticate</code> challenge. The authorization server
168-
MUST reject any request in which the resource parameter identifies an unknown or untrusted <a>storage</a>.
232+
<li>The <code>resource</code> parameter is REQUIRED. The value of this parameter MUST be a URI and will be used
233+
to populate the <code>aud</code> (audience) claim in the resulting access token. The supplied value MUST be the
234+
URI of the <a>storage</a> that contains the requested resource, as provided in the <code>Link</code> header of
235+
an unauthorized response. The authorization server MUST reject any request in which the resource parameter
236+
identifies an unknown or untrusted <a>storage</a>.
169237
</li>
170238

171239
<li>
@@ -218,9 +286,9 @@ <h5>Response</h5>
218286
<code>client_id</code> (client id) — <strong>REQUIRED</strong>. This claim MUST be a URI identifying the client.
219287
</li>
220288
<li>
221-
<code>aud</code> (audience) — <strong>REQUIRED</strong>. This claim MUST include the URI supplied by the client
222-
in the resource parameter. This value will be used to restrict the entities for which the access token is valid. This will
223-
be the same value as provided by a storage server in the <code>realm</code> parameter of a <code>WWW-Authenticate</code> challenge.
289+
<code>aud</code> (audience) — <strong>REQUIRED</strong>. This claim MUST include the URI supplied by the
290+
client in the resource parameter, which is the URI of a <a>storage</a>. This value will be used to restrict
291+
the entities for which the access token is valid.
224292
</li>
225293
<li>
226294
<code>exp</code> (expiration) — <strong>REQUIRED</strong>. Authorization servers SHOULD issue tokens with short lifetimes
@@ -284,7 +352,7 @@ <h5>Example access token</h5>
284352
"sub": "https://id.example/agent",
285353
"iss": "https://authorization.example",
286354
"client_id": "https://app.example/id",
287-
"aud": "https://storage.example",
355+
"aud": "https://storage.example/storage_1",
288356
"exp": 1735686300,
289357
"iat": 1735686000,
290358
"jti": "550e8400-e29b-41d4-a716-446655440000"
@@ -332,7 +400,8 @@ <h5>Validation</h5>
332400
Issuer Validation: Verify the <code>iss</code> claim matches the expected authorization server identifier.
333401
</li>
334402
<li>
335-
Audience Validation: Verify the <code>aud</code> claim contains exactly one value and this value is a URI identifying the storage server which logically contains the target resource.
403+
Audience Validation: Verify the <code>aud</code> claim includes the URI of the <a>storage</a> that contains
404+
the target resource.
336405
</li>
337406
<li>
338407
Temporal Validation, subject to an allowable clock skew between systems.
@@ -352,7 +421,8 @@ <h5>Validation</h5>
352421

353422
<p>
354423
If validation fails, the storage server MUST return 401 Unauthorized with a <code>WWW-Authenticate</code> header
355-
containing an appropriate error parameter (e.g., invalid_token, invalid_request, or insufficient_scope).
424+
containing the <code>resource_metadata</code> parameter and an appropriate error parameter (e.g.,
425+
<code>invalid_token</code>, <code>invalid_request</code>, or <code>insufficient_scope</code>).
356426
</p>
357427

358428
<p>

‎lws10-core/Operations/read-resource.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,4 +89,4 @@ The LWS server MUST support HEAD [[RFC9110]] for both <a>containers</a> and non-
8989
**Caching and Conditional Requests:** LWS leverages HTTP caching semantics. Servers SHOULD support conditional requests as defined in [[RFC9110]], including mechanisms such as entity tags (`ETags`) and date-based validators (like `If-Modified-Since` headers). If the resource or <a>container</a> listing has not changed, respond with `304 Not Modified` to avoid redundant transfers.
9090

9191

92-
**Discoverability and Authorization:** For enhanced discoverability, servers SHOULD include `WWW-Authenticate` headers on `401 Unauthorized` responses with parameters to guide clients without hardcoded URIs. Metadata links SHOULD be included where applicable.
92+
**Discoverability and Authorization:** For enhanced discoverability, `401 Unauthorized` responses include a `WWW-Authenticate` header with a `resource_metadata` parameter, as described in [Authorization Server Discovery](#authorization-server-discovery), so that clients can locate an authorization server without hardcoded URIs.

‎lws10-core/Security-Considerations.html‎

Lines changed: 55 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,68 @@ <h4>Token Security</h4>
2323
Short Lifetimes: Authorization servers that assign lifetimes of 300 seconds (5 minutes) or less to access tokens can limit the potential exposure of an exfiltrated credential.
2424
</li>
2525
<li>
26-
Audience Binding: Access tokens that are bound to a specific destination server, by means such as the <code>aud</code> claim, can rely on that binding to protect against token replay. Applications that handle credentials with an unrestricted audience need to be careful when sending these credentials to other entities, especially untrusted authorization servers. If a credential issuer is unable to restrict the audience of a token, clients can use a mechanism such as OAuth 2.0 Token Exchange [[RFC8693]] to create audience-constrained credentials before interacting with an authorization server in a different security domain.
26+
Audience Binding: Binding an access token to a specific destination server, by means such as the <code>aud</code>
27+
claim, protects against the token being replayed to a different server. An access token whose audience includes
28+
more than one server can be replayed by any of those servers to the others, which authorization servers avoid by
29+
issuing tokens with a single storage URI as the audience. Applications that handle credentials with an
30+
unrestricted audience need to be careful when sending these credentials to other entities, especially untrusted
31+
authorization servers. If a credential issuer is unable to restrict the audience of a token, clients can use a
32+
mechanism such as OAuth 2.0 Token Exchange [[RFC8693]] to create audience-constrained credentials before
33+
interacting with an authorization server in a different security domain.
34+
</li>
35+
<li>
36+
Sender-Constrained Tokens: A bearer token can be used by any party that obtains it, and an audience restriction
37+
does not prevent an exfiltrated token from being replayed to the intended storage server. Because the audience is
38+
a storage, a stolen token is usable for every resource within that storage that the agent is authorized to access.
39+
Binding an access token to a client key, such as with OAuth 2.0 Demonstrating Proof of Possession (DPoP)
40+
[[RFC9449]], limits use of a stolen token to the holder of that key. A protected resource metadata document can
41+
advertise the DPoP proof algorithms that a storage server supports and whether it requires DPoP-bound access
42+
tokens, using the <code>dpop_signing_alg_values_supported</code> and
43+
<code>dpop_bound_access_tokens_required</code> parameters defined in [[RFC9728]].
2744
</li>
2845
<li>
2946
Secure Storage: Applications that persist credentials need to ensure that these objects are stored safely. Any time an unencrypted token is stored in a browser's <code>localStorage</code>, in URLs, or in logs, that token is more susceptible to an exfiltration attack.
3047
</li>
3148
</ul>
3249
</section>
3350

51+
<section id="security-resource-discovery" class="informative">
52+
<h4>Resource Discovery</h4>
53+
54+
<p>
55+
A client learns the location of an authorization server from a response sent by a storage server that the client
56+
might not trust. The following considerations apply to this discovery process.
57+
</p>
58+
59+
<ul>
60+
<li>
61+
Untrusted Metadata: A malicious storage server can direct a client to an authorization server that the client does
62+
not trust, and a client that presents an <a>authentication credential</a> to that authorization server discloses
63+
the credential. Clients can reduce this risk by applying their own policy about which authorization servers to
64+
trust. The checks in <a href="#authorization-discovery-validation"></a>, which require that the protected resource
65+
metadata describe the requested resource on the same server, prevent a server from presenting metadata that
66+
belongs to a different resource server. The impact of disclosure is also reduced when a client uses an
67+
<a>authentication credential</a> whose audience is limited to the authorization server to which it is sent.
68+
</li>
69+
<li>
70+
Storage Binding: A client obtains the storage URI from a <code>Link</code> header in a response from the storage
71+
server. A malicious server can supply the URI of a different storage, causing the client to obtain an access token
72+
for that storage and present it to the malicious server, which can then replay it. For this reason, a client is
73+
required to confirm, using the <a>storage description</a>, that the requested URI is served from the same origin
74+
as the <a>storage root</a> before requesting an access token, as described in
75+
<a href="#authorization-discovery-validation"></a>.
76+
</li>
77+
<li>
78+
Server-Side Request Forgery: The <code>resource_metadata</code> URL in a challenge, the <a>storage</a> URI in a
79+
<code>Link</code> header, and the issuer identifiers in a protected resource metadata document are chosen by the
80+
storage server, and a client retrieves the documents they identify. Clients that perform this retrieval on behalf
81+
of other parties, such as a server-side application, are exposed to server-side request forgery, as described in
82+
Section 7.7 of [[RFC9728]]. Precautions include restricting retrieval to the <code>https</code> scheme and
83+
blocking requests to internal IP address ranges.
84+
</li>
85+
</ul>
86+
</section>
87+
3488
<section id="security-access-requests" class="informative">
3589
<h4>Access Requests and Grants</h4>
3690

0 commit comments

Comments
 (0)