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

JWT x5c Header seems to be invalid #124

Closed
c2bo opened this issue Mar 13, 2024 · 4 comments · Fixed by #127
Closed

JWT x5c Header seems to be invalid #124

c2bo opened this issue Mar 13, 2024 · 4 comments · Fixed by #127
Assignees
Labels
bug Something isn't working

Comments

@c2bo
Copy link

c2bo commented Mar 13, 2024

The x5c JOSE header of the Request Object JWT seems to be malformed:

private fun List<X509Certificate>.toBase64PEMEncoded(): List<Base64> =
this.map { X509CertUtils.toPEMString(it) }.map { Base64.encode(it) }

generates a list of base64 encoded PEM, whereas the RFC defines it as a list of base64 encoded DER (https://datatracker.ietf.org/doc/html/rfc7515#section-4.1.6). Every Request Object JWT will have an invalid x5c header and can't be verified with default JWT/JAR implementations.

This issue is probably present in the client implementation as well?

@dzarras
Copy link
Contributor

dzarras commented Mar 14, 2024

Dear @c2bo,

Thanks for reporting this. We are currently actively investigating it, and will keep you posted.

Kind regards.

@dzarras dzarras added the bug Something isn't working label Mar 14, 2024
@dzarras
Copy link
Contributor

dzarras commented Mar 14, 2024

Dear @c2bo,

We acknowledge the issue. It is indeed a bug.
Even though the client implementation is correct, we didn't detect this issue earlier due to the following:

When trying to parse a X509 certificate you end up in sun.security.provider.X509Factory.engineGenerateCertificate(InputStream).
This method uses internally sun.security.provider.X509Factory.readOneBlock(InputStream).
The javadoc of the latter reads:

Returns an ASN.1 SEQUENCE from a stream, which might be a BER-encoded binary block or a PEM-style BASE64-encoded ASCII data. In the latter case, it's de-BASE64'ed before return. After the reading, the input stream pointer is after the BER block, or after the newline character after the -----END SOMETHING----- line.

In effect this method is able to decode both base64 encoded DERs and base64 encoded PEMs.

Thanks again for reporting this.

@babisRoutis
Copy link
Contributor

@dzarras We need to double check the swift implementation

@dzarras
Copy link
Contributor

dzarras commented Mar 19, 2024

Dear @c2bo v0.1.1 of Verifier Endpoint has been released. This new version contains the fix for the bug you reported and is already deployed.

Thanks again for reporting this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants