oauth-wg / oauth-selective-disclosure-jwt

https://datatracker.ietf.org/doc/draft-ietf-oauth-selective-disclosure-jwt/
Other
55 stars 27 forks source link

Review of verification algorithms #389

Closed jyasskin closed 5 months ago

jyasskin commented 7 months ago

While reviewing https://github.com/w3c/vc-jose-cose/pull/190, I had to understand some of the SD-JWT verification algorithms. I noticed some issues, which I've listed here. I haven't filed individual issues yet because I'm not sure how you'll want to group them. Thanks to @OR13 for doing a first pass; any remaining mistakes are probably because I didn't take his advice.

5.1. Issuer-signed JWT Payload

5.2.1. Disclosures for Object Properties

5.3. Key Binding JWT

5.3.1. Integrity Protection of the Presentation

8.1. Verification of the SD-JWT

8.2. Processing by the Holder

8.3. Verification by the Verifier

16. Informative References

bc-pi commented 7 months ago

Thanks for the review Jeffrey! I'm acknowledging it with this comment but also noting that there's a lot here so response/action will take some time.

bc-pi commented 7 months ago

Many of these should be normative. For example,...

1c1f165ab821dea5350f62225f103bdceff31532 one was an oversight and one was a tooling issue and oversight. I think that covers them tho.

bc-pi commented 7 months ago

"Check that the Key Binding JWT is valid in all other respects" should call a particular algorithm from the other specs that it cites.

Those other specs don't have algorithms that can be called nor do they have suitable sections to reference directly.

bc-pi commented 7 months ago

Why is 128 bits only recommended and not required for the salt?

Some contributors want to leave open the option of a more computationally expensive hash with smaller salt values.

bc-pi commented 7 months ago

"The claim name, or key, as it would be used in a regular JWT payload. The value MUST be a string." <- I assume the "value" is the key, and not the key's value in the JSON object?

Yes and I've tried to remove any ambiguity there by just not using the word "value" with d015a3de2ae50623b4a294590fb2d0249e7d33b5

bc-pi commented 7 months ago

5.1. Issuer-signed JWT / 5.3. Key Binding JWT ... should follow https://www.rfc-editor.org/rfc/rfc7515.html#section-7 by specifying "what serialization and serialization features are used" ...

Per RFC7519, "JWTs are always represented using the JWS Compact Serialization" the compact serialization is already specified.

bc-pi commented 7 months ago

5.3.1. Integrity Protection of the Presentation

This mentions "bytes preceding the KB-JWT in the Presentation", but several other places mention "Key Binding is provided by means not defined in this specification", in which case the relevant bytes don't precede the KB-JWT. These should be consistent.

That is for the sd_hash claim in Key Binding JWT so isn't relevant elsewhere.

bc-pi commented 7 months ago

Are "Upon receiving an SD-JWT, a Holder or a Verifier MUST ensure that" and "The Holder or the Verifier MUST perform the following (or equivalent) steps when receiving an SD-JWT" accomplishing the same thing?

&

This is clearer that "Verifiers MUST ensure that" is accomplished by the steps in the following algorithm, but I don't like the redundant MUST. You can just say "Verifiers need to ensure that" and then leave the normative requirements to the algorithm.

Yeah, with 2a0e270f2e1dbfa9664bb5ce4989a2f6a1765217 I basically applied your suggestion to both places.

bc-pi commented 7 months ago

"Validate the signature over the Issuer-signed JWT" should cite an algorithm for doing that. Is that https://www.rfc-editor.org/rfc/rfc7515.html#section-5.2?

Yup 7d68d4ed9b91e49a0aa00254475bf7c116669dd6

bc-pi commented 7 months ago

"Separate the SD-JWT" should cite an algorithm for doing that. I think it's "5. SD-JWT Data Formats" which implies it's just "split on '~'"?

Yes but I believe it's sufficiently clear in the context of the draft.

bc-pi commented 7 months ago

This draft is not structured such that it has input parameters to algorithms so suggestions to make something an input parameter to an algorithm are not actionable or practical.

bc-pi commented 7 months ago

"Validate the signature" <- again, cite how to do this.

e9acd5ed665b107776b6b41355680470cde89f2c

bc-pi commented 7 months ago

"the typ of the Key Binding JWT" <- is that in the header or payload? (cite 5.3. Key Binding JWT ...

typ is a JOSE header. Will cite sec 5.3. where that's more explicit 64a4c4519668c7a63f1a0be215176657895fa0c8

bc-pi commented 7 months ago

"verify the Key Binding according to the method used" <- how? This might be https://www.rfc-editor.org/rfc/rfc9449.html#section-6, but you should cite the details.

That sentence starts with "If Key Binding is provided by means not defined in this specification," so there are not specific details to cite. Alternatives to a Key Binding JWT mentions that other ways of proving Key Binding are possible.

DPoP/rfc9449 is one possibility but not the only one. Nor a particularly likely one. At least not likely enough to warrant mention here.

bc-pi commented 7 months ago

"Check that the SD-JWT is valid using claims such as nbf, iat, and exp" should say where those claims are defined and what part of which object they appear on. (https://www.iana.org/assignments/jwt/jwt.xhtml#claims, and the top level of the payload, not the header, right?)

The very next part of that sentence says "in the processed payload" and that's a non-exhaustive list of JWT claims for which a citation/reference isn't really needed.

bc-pi commented 7 months ago

"Remove all array elements for which the digest was not found" probably won't confuse anyone for long, but my first reading said that an array in the payload like [1, 2, 3] would wind up empty since no digests were found for the elements.

I feel like it's sufficiently clear from context and shouldn't confuse anyone for too long.

bc-pi commented 7 months ago

I would probably have written the algorithm to build a map of hash->disclosure and then call a recursive element-processing-and-replacing function, but this isn't too bad.

Noted.

bc-pi commented 7 months ago

How should the application "Validate the Issuer and that the signing key belongs to this Issuer"? I see that the details of distribution are out of scope (Section 11.9), but this should say something about the application having a map from (issuer ID, key ID) pairs to public keys, and which fields of the Issuer-signed JWT are used to look up keys in this map.

This draft intentionally doesn't prescribe how keys are distributed, identified, selected, trusted, etc. any more than JWT/JWS do (e.g. https://datatracker.ietf.org/doc/html/rfc7515#section-6, https://datatracker.ietf.org/doc/html/rfc7515#appendix-D, etc). A map from (issuer ID, key ID) pairs to public keys is one application but certainly not the only one.

bc-pi commented 7 months ago

How should the application "Check that the _sd_alg claim value is understood"? Where should it find the _sd_alg, in the JWT's header or payload? 5.1.1. Hash Function Claim answers this, so you could just reference that ...

referencing that 072a0605bcb62937e343aaa7812aa8ef86d8379f

bc-pi commented 7 months ago

What's a "claim"? https://www.rfc-editor.org/rfc/rfc7519#section-4 says the claims are the members of the JWT's payload, but the algorithm here also uses "claim" to describe nested object members and array elements.

That's a somewhat existential and loaded question but common usage of the word doesn't preclude it describing nested items and array elements. And this draft is not alone in that. In the intro it also says, '"Claims" here refers to both object properties (name-value pairs) as well as array elements.'

bc-pi commented 7 months ago

8.2. Processing by the Holder "create a Key Binding JWT" <- refer to the section that says how to do this. "Assemble the SD-JWT for Presentation" <- This should at least refer to "5. SD-JWT Data Formats"

cbee5f8457f447574400377dc6f7c9fe7f1c3c18

bc-pi commented 7 months ago

"Determine the public key for the Holder" <- how? This might be the 'cnf' claim, but you should say so.

a474e2b0b0ff7635af38c2ac95e70b40b2f82798 makes things a little more a bit more prescriptive about suggesting RFC7800 cnf/jwk be used to convey the Key Binding key and references that section from the "Verification by the Verifier" section.

Sakurann commented 7 months ago

Thank you so much, Brian! overall, agree with all the responses. I made few comments on the PR, but one thing to note here too: I think recommending cnf claim per comment here is inconsistent with a comment here that says that "this draft intentionally doesn't prescribe how keys are distributed, identified, selected, trusted, etc. any more than JWT/JWS do. so I think recommending is redundant and using cnf in examples is sufficient.

bc-pi commented 7 months ago

That latter comment was about (and in reply to a suggestion about) validating the signature on the Issuer-signed JWT and checking that the signing key belongs to this Issuer. While the former comment is about the holder's public key inside the Issuer-signed JWT itself. Different things so I don't believe there's really an inconsistency in my statements. Nor do I think that being a little more a bit more prescriptive and more clear about using RFC7800 cnf/jwk to convey the Key Binding key is redundant. Rather this review of a review seemed like a good opportunity to provide a little more clarity and guidance in an area the draft that could benefit from such.