Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DPoP Proof JWT should not have kid within its JWT header paramenters #307

Open
peppelinux opened this issue Nov 15, 2024 · 3 comments · May be fixed by #329
Open

DPoP Proof JWT should not have kid within its JWT header paramenters #307

peppelinux opened this issue Nov 15, 2024 · 3 comments · May be fixed by #329
Assignees
Milestone

Comments

@peppelinux
Copy link
Member

The current implementation of DPoP (Demonstration of Proof-of-Possession) is incorrect. It requires the inclusion of a kid (Key ID) in the dpop+jwt (JSON Web Token), which is not necessary according to the DPoP specification.

@peppelinux peppelinux self-assigned this Nov 19, 2024
@peppelinux peppelinux added this to the 0.9.1 milestone Nov 19, 2024
@peppelinux peppelinux moved this from Todo to In Progress in EUDI WALLET IT Python Jan 10, 2025
@LadyCodesItBetter
Copy link
Collaborator

Currently, the kid is automatically added by the cryptojwt library during key generation. For example, in the test_dpop.py file, we use the method new_ec_key:

PRIVATE_JWK_EC = new_ec_key('P-256')

This method automatically assigns a kid if none is explicitly provided, through the _rk.add_kid() call in the library.

The question is: do we want to remove the kid afterward to comply with the DPoP specification, or is it acceptable to keep it as a SHOULD NOT meaning?

If we decide to remove the kid, we could implement an explicit solution in both the tests and the DPoPIssuer class to ensure the parameter is excluded from the JWT header.

@peppelinux looking for confirmation on how to proceed to align with the specification and avoid any ambiguity.

@peppelinux
Copy link
Member Author

before using the key for the signature, remove the kid from the EC object

@Zicchio
Copy link
Collaborator

Zicchio commented Jan 15, 2025

We already have a flag to include (or drop) a kid from a token header; but I'm not if it is unit tested and the logic might not be 100% sound - maybe start from there

kid_in_header: bool = True,

if kid_in_header and signer_kid:
protected["kid"] = signer_kid # note that is actually redundant as the underlying library auto-update the header with the kid
# this is a hack: if the header to be signed does NOT have kid and we do
# not want to include it, then we must remove it from the signing kid
# otherwise the signing library will auto insert it
if not kid_in_header and not header_kid:
signing_key = deepcopy(signing_key)
signing_key.pop("kid", None)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: In Progress
3 participants