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

OIDC: increase length of generated nonce parameter from 30->32 chars #18109

Merged
merged 4 commits into from
Jan 27, 2025

Conversation

anoadragon453
Copy link
Member

This PR slightly increases the character length (and thus the entropy) of the nonce value (from the default 30 characters -> 32 characters) that Synapse generates when performing an OIDC login.

This is so that Synapse's OIDC implementation complies with the relevant portion of the TI-Messenger spec - which aims to standardise Matrix as the communication layer for healthcare in Germany.

The spec requires (translation via Google Translate):

The Authorization Server service MUST generate a nonce (random value) at runtime in accordance with [ RFC7636 # section-4.1 ]. The nonce MUST contain an entropy of at least 43 and a maximum of 128 characters.

We clarified with Gematik (the German government body in charge of writing this spec) what they meant exactly by "an entropy of at least 43". They replied that they meant to write "43 characters".

When sent to the Identity Provider, the nonce value is encoded using base64url. A 32 character string encoded to base64url results in a 43 character length string. Thus, this change aligns Synapse's generated nonce value with the spec.


While this change is intended to satisfy an external spec, the change only increases security (while only adding three extra bytes to a request). The matrix spec does not cover this flow, instead (rightly) offloading it to RFC7636. That RFC only demands a 43 character length for the code_verifier parameter, which Synapse does comply with. Whereas Gematik have opted to adapt that length requirement to the nonce parameter as well.

When converted to base64url, this becomes 43 characters in length.
@anoadragon453 anoadragon453 marked this pull request as ready for review January 27, 2025 14:17
@anoadragon453 anoadragon453 requested a review from a team as a code owner January 27, 2025 14:17
synapse/handlers/oidc.py Show resolved Hide resolved
@anoadragon453 anoadragon453 enabled auto-merge (squash) January 27, 2025 17:54
@anoadragon453 anoadragon453 merged commit b41a9eb into develop Jan 27, 2025
39 checks passed
@anoadragon453 anoadragon453 deleted the anoa/nonce_length branch January 27, 2025 18:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants