Skip to content

Commit 8827919

Browse files
authored
Merge pull request #5 from ietf-wg-httpapi/multiple-values
Allow reporting problems on multiple digests
2 parents 8734094 + 798a0b2 commit 8827919

File tree

1 file changed

+91
-61
lines changed

1 file changed

+91
-61
lines changed

draft-ietf-httpapi-digest-fields-problem-types.md

Lines changed: 91 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ normative:
4444
STRUCTURED-FIELDS: RFC9651
4545
HTTP: RFC9110
4646
RFC8792:
47+
JSON: RFC8259
4748

4849
informative:
4950

@@ -69,10 +70,14 @@ Want-Content-Digest: sha-512=3, sha-256=10
6970

7071
{
7172
"type": "https://iana.org/assignments/http-problem-types#\
72-
digest-unsupported-algorithm",
73-
"title": "hashing algorithm is not supported",
74-
"unsupported-algorithm": "foo",
75-
"header": "Want-Content-Digest"
73+
digest-unsupported-algorithms",
74+
"title": "Unsupported hashing algorithms",
75+
"unsupported-algorithms": [
76+
{
77+
"algorithm": "foo",
78+
"header": "Want-Content-Digest"
79+
}
80+
]
7681
}
7782
~~~
7883

@@ -90,25 +95,30 @@ interpreted as described in {{PROBLEM}}.
9095

9196
The terms "request", "response", "intermediary", "sender", "client", and "server" are from {{HTTP}}.
9297

98+
The problem types in this document are defined using JSON {{JSON}}. They can be serialized into an equivalent XML format as outlined in {{Appendix B of PROBLEM}}.
99+
93100
# Problem Types
94101

95102
The following section defines three problem types to express common problems that occur when handling integrity or integrity preference fields on the server. These problem types use the `digest-` prefix in their type URI. Other problem types that are defined outside this document, yet specific to digest related problems, may reuse this prefix.
96103

97-
## Unsupported Hashing Algorithm
104+
Requests can include multiple integrity or integrity preference fields. For example, they may use the `Content-Digest` and `Repr-Digest` fields simultaneously or express preferences for content and representation digests at the same time. Therefore, similar problems can appear multiple times for one request. The problem types defined in this document allow expressing multiple appearances, while each time identifying the corresponding header that contained the problematic value.
105+
106+
## Unsupported Hashing Algorithms
98107

99-
This section defines the "https://iana.org/assignments/http-problem-types#digest-unsupported-algorithm" problem type.
100-
A server MAY use this problem type if it wants to communicate to the client that
101-
one of the hashing algorithms referenced in the integrity or integrity preference fields present in the request
102-
is not supported.
108+
This section defines the "https://iana.org/assignments/http-problem-types#digest-unsupported-algorithms" problem type.
109+
A server can use this problem type to communicate to the client that
110+
one or more of the hashing algorithms referenced in the integrity or integrity preference fields present in the request
111+
are not supported.
103112

104-
Two problem type extension members are defined, which SHOULD be populated for all responses using this problem type:
113+
For this problem type, the `unsupported-algorithms` extension member is defined, whose value is a JSON {{JSON}} array of entries identifying each unsupported algorithm.
114+
Each entry in the array is a JSON object with the following members:
105115

106-
- The `unsupported-algorithm` extension member identifies the unsupported algorithm from the request. Its value is the corresponding algorithm key.
107-
- The `header` extension member as defined in {{identifying-problem-causing-headers}}.
116+
- The `algorithm` member is a JSON string containing the algorithm key of the unsupported algorithm.
117+
- The `header` member is a JSON string containing the name of the integrity or integrity preference field that referenced the unsupported algorithm.
108118

109119
The response can include the corresponding integrity preference field to indicate the server's algorithm support and preference.
110120

111-
This problem type is a hint to the client about algorithm support, which the client could use to retry the request with a different, supported, algorithm.
121+
This problem type is a hint to the client about algorithm support, which the client could use to retry the request with different, supported, algorithms.
112122

113123
Example:
114124

@@ -119,24 +129,34 @@ Content-Type: application/json
119129
Accept: application/json
120130
Accept-Encoding: identity
121131
Repr-Digest: sha-256=:mEkdbO7Srd9LIOegftO0aBX+VPTVz7/CSHes2Z27gc4=:
132+
Content-Digest: sha-256=:mEkdbO7Srd9LIOegftO0aBX+VPTVz7/CSHes2Z27gc4=:
122133

123134
{"title": "New Title"}
124135
~~~
125-
{: title="A request with a sha-256 integrity field, which is not supported by the server"}
136+
{: title="A request with sha-256 integrity fields, which are not supported by the server"}
126137

127138
~~~ http-message
128139
# NOTE: '\' line wrapping per RFC 8792
129140

130141
HTTP/1.1 400 Bad Request
131142
Content-Type: application/problem+json
132143
Want-Repr-Digest: sha-512=10, sha-256=0
144+
Want-Content-Digest: sha-512=10, sha-256=0
133145

134146
{
135147
"type": "https://iana.org/assignments/http-problem-types#\
136-
digest-unsupported-algorithm",
137-
"title": "Unsupported hashing algorithm",
138-
"unsupported-algorithm": "sha-256",
139-
"header": "Repr-Digest"
148+
digest-unsupported-algorithms",
149+
"title": "Unsupported hashing algorithms",
150+
"unsupported-algorithms": [
151+
{
152+
"algorithm": "sha-256",
153+
"header": "Repr-Digest"
154+
},
155+
{
156+
"algorithm": "sha-256",
157+
"header": "Content-Digest"
158+
}
159+
]
140160
}
141161
~~~
142162
{: title="Response indicating the problem and advertising the supported algorithms"}
@@ -159,23 +179,28 @@ Content-Type: application/problem+json
159179

160180
{
161181
"type": "https://iana.org/assignments/http-problem-types#\
162-
digest-unsupported-algorithm",
163-
"title": "Unsupported hashing algorithm",
164-
"unsupported-algorithm": "sha",
165-
"header": "Want-Repr-Digest"
182+
digest-unsupported-algorithms",
183+
"title": "Unsupported hashing algorithms",
184+
"unsupported-algorithms": [
185+
{
186+
"algorithm": "sha",
187+
"header": "Want-Repr-Digest"
188+
}
189+
]
166190
}
167191
~~~
168192
{: title="Response indicating the problem and advertising the supported algorithms"}
169193

170-
## Invalid Digest Value
171-
172-
This section defines the "https://iana.org/assignments/http-problem-types#digest-invalid-value" problem type. A server MAY use this problem type when responding to a request, whose integrity fields include a digest value, that cannot be generated by the corresponding hashing algorithm. For example, if the digest value of the `sha-512` hashing algorithm is not 64 bytes long, it cannot be a valid SHA-512 digest value and the server can skip computing the digest value. This problem type MUST NOT be used if the server is not able to parse the integrity fields according to {{Section 4.5 of STRUCTURED-FIELDS}}, for example because of a syntax error in the field value.
194+
## Invalid Digest Values
173195

174-
One problem type extension member is defined, which SHOULD be populated for all responses using this problem type:
196+
This section defines the "https://iana.org/assignments/http-problem-types#digest-invalid-values" problem type. A server can use this problem type when responding to a request, whose integrity fields include a digest value, that cannot be generated by the corresponding hashing algorithm. For example, if the digest value of the `sha-512` hashing algorithm is not 64 bytes long, it cannot be a valid SHA-512 digest value and the server can skip computing the digest value. This problem type MUST NOT be used if the server is not able to parse the integrity fields according to {{Section 4.5 of STRUCTURED-FIELDS}}, for example because of a syntax error in the field value.
175197

176-
- The `header` extension member as defined in {{identifying-problem-causing-headers}}.
198+
For this problem type, the `invalid-digests` extension member is defined, whose value is a JSON {{JSON}} array of entries identifying each invalid digest.
199+
Each entry in the array is a JSON object with the following members:
177200

178-
The server SHOULD include a human-readable description why the value is considered invalid in the `title` member.
201+
- The `algorithm` member is a JSON string containing the algorithm key.
202+
- The `header` member is a JSON string containing the name of the integrity field that contained the invalid digest value.
203+
- The `reason` member is a JSON string containing a human-readable description why the value is considered invalid.
179204

180205
This problem type indicates a fault in the sender's calculation or encoding of the digest value. A retry of the same request without modification will likely not yield a successful response.
181206

@@ -199,28 +224,35 @@ Content-Type: application/problem+json
199224

200225
{
201226
"type": "https://iana.org/assignments/http-problem-types#\
202-
digest-invalid-value",
203-
"title": "digest value for sha-512 is not 64 bytes long",
204-
"header": "Repr-Digest"
227+
digest-invalid-values",
228+
"title": "Invalid digest values",
229+
"invalid-digests": [
230+
{
231+
"algorithm": "sha-512",
232+
"header": "Repr-Digest",
233+
"reason": "digest value is not 64 bytes long"
234+
}
235+
]
205236
}
206237
~~~
207238
{: title="Response indicating that the provided digest is too short"}
208239

209-
## Mismatching Digest Value
240+
## Mismatching Digest Values
210241

211-
This section defines the "https://iana.org/assignments/http-problem-types#digest-mismatching-value" problem type. A server MAY use this problem type when responding to a request, whose integrity fields include a digest value that does not match the digest value that the server calculated for the request content or representation.
242+
This section defines the "https://iana.org/assignments/http-problem-types#digest-mismatching-values" problem type. A server can use this problem type when responding to a request, whose integrity fields include a digest value that does not match the digest value that the server calculated for the request content or representation.
212243

213-
Three problem type extension members are defined, which SHOULD be populated for all responses using this problem type:
244+
For this problem type, the `mismatching-digests` extension member is defined, whose value is a JSON {{JSON}} array of entries identifying each mismatching digest.
245+
Each entry in the array is a JSON object with the following members:
214246

215-
- The `algorithm` extension member is the algorithm key of the used hashing algorithm.
216-
- The `provided-digest` extension member is the digest value taken from the request's integrity fields. The digest value is serialized as a byte sequence as described in {{Section 4.1.8 of STRUCTURED-FIELDS}}.
217-
- The `header` extension member as defined in {{identifying-problem-causing-headers}}.
247+
- The `algorithm` member is a JSON string containing the algorithm key of the hashing algorithm.
248+
- The `provided-digest` member is a JSON string containing the digest value taken from the request's integrity fields. The digest value is serialized as a byte sequence as described in {{Section 4.1.8 of STRUCTURED-FIELDS}}.
249+
- The `header` member is a JSON string containing the name of the integrity field that contained the mismatching digest value.
218250

219251
The problem type intentionally does not include the digest value calculated by the server to avoid attackers abusing this information for oracle attacks.
220252

221253
If the sender receives this problem type, the request might be modified unintentionally by an intermediary. The sender could use this information to retry the request without modification to address temporary transmission issues.
222254

223-
The following example shows a request with the content `{"hello": "woXYZ"}` (plus LF), but the representation digest for `{"hello": "world"}` (plus LF). The subsequent response indicates the mismatching SHA-256 digest values.
255+
The following example shows a request with the content `{"hello": "woXYZ"}` (plus LF), but the representation digest for `{"hello": "world"}` (plus LF). The subsequent response indicates the mismatching SHA-256 digest value.
224256

225257
~~~ http-message
226258
PUT /items/123 HTTP/1.1
@@ -240,21 +272,19 @@ Content-Type: application/problem+json
240272

241273
{
242274
"type": "https://iana.org/assignments/http-problem-types#\
243-
digest-mismatching-value",
244-
"title": "digest value from request does not match expected value",
245-
"algorithm": "sha-256",
246-
"provided-digest": ":RK/0qy18MlBSVnWgjwz6lZEWjP/lF5HF9bvEF8FabDg=:",
247-
"header": "Repr-Digest"
275+
digest-mismatching-values",
276+
"title": "Mismatching digest values",
277+
"mismatching-digests": [
278+
{
279+
"algorithm": "sha-256",
280+
"provided-digest": ":RK/0qy18MlBSVnWgjwz6lZEWjP/lF5HF9bvEF8FabDg=:",
281+
"header": "Repr-Digest"
282+
}
283+
]
248284
}
249285
~~~
250286
{: title="Response indicating the mismatching digests"}
251287

252-
# Identifying Problem Causing Headers
253-
254-
Requests can include multiple integrity or integrity preference fields. For example, they may use the `Content-Digest` and `Repr-Digest` fields simultaneously or express preferences for content and representation digests at the same time. To aid troubleshooting, it's useful to identify the header field, whose value caused the problem detailed in the response. For this reason, the `header` extension member is defined, which SHOULD be populated for all responses using the problem types defined in this document.
255-
256-
The `header` extension member's value is the header field name that caused the problem. Since HTTP header field names are case-insensitive and not all HTTP versions preserve their casing, the casing of extension member's value might not match the request header field name's casing.
257-
258288
# Security Considerations
259289

260290
Disclosing error details could leak information
@@ -271,46 +301,46 @@ the calculated digest to avoid exposing information that can be abused for oracl
271301

272302
IANA is asked to register the following entries in the "HTTP Problem Types" registry at <https://www.iana.org/assignments/http-problem-types>.
273303

274-
## Registration of "digest-unsupported-algorithm" Problem Type
304+
## Registration of "digest-unsupported-algorithms" Problem Type
275305

276306
Type URI:
277-
: https://iana.org/assignments/http-problem-types#digest-unsupported-algorithm
307+
: https://iana.org/assignments/http-problem-types#digest-unsupported-algorithms
278308

279309
Title:
280-
: Unsupported Hashing Algorithm
310+
: Unsupported Hashing Algorithms
281311

282312
Recommended HTTP status code:
283313
: 400
284314

285315
Reference:
286-
: {{unsupported-hashing-algorithm}} of this document
316+
: {{unsupported-hashing-algorithms}} of this document
287317

288-
## Registration of "digest-invalid-value" Problem Type
318+
## Registration of "digest-invalid-values" Problem Type
289319

290320
Type URI:
291-
: https://iana.org/assignments/http-problem-types#digest-invalid-value
321+
: https://iana.org/assignments/http-problem-types#digest-invalid-values
292322

293323
Title:
294-
: Invalid Digest Value
324+
: Invalid Digest Values
295325

296326
Recommended HTTP status code:
297327
: 400
298328

299329
Reference:
300-
: {{invalid-digest-value}} of this document
330+
: {{invalid-digest-values}} of this document
301331

302-
## Registration of "digest-mismatching-value" Problem Type
332+
## Registration of "digest-mismatching-values" Problem Type
303333

304334
Type URI:
305-
: https://iana.org/assignments/http-problem-types#digest-mismatching-value
335+
: https://iana.org/assignments/http-problem-types#digest-mismatching-values
306336

307337
Title:
308-
: Mismatching Digest Value
338+
: Mismatching Digest Values
309339

310340
Recommended HTTP status code:
311341
: 400
312342

313343
Reference:
314-
: {{mismatching-digest-value}} of this document
344+
: {{mismatching-digest-values}} of this document
315345

316346
--- back

0 commit comments

Comments
 (0)