CVE-2020-5300: Disallow replay of `private_key_jwt` by blacklisting JTIs in Hydra
Impact
When using client authentication method "privatekeyjwt" [1], OpenId specification says the following about assertion jti:
A unique identifier for the token, which can be used to prevent reuse of the token. These tokens MUST only be used once, unless conditions for reuse were negotiated between the parties
Hydra does not seem to check the uniqueness of this jti value. Here is me sending the same token request twice, hence with the same jti assertion, and getting two access tokens:
$ curl --insecure --location --request POST 'https://localhost//oauth2/token' \ --header 'Content-Type: application/x-www-form-urlencoded' \ --data-urlencode 'granttype=clientcredentials' \ --data-urlencode 'clientid=c001d00d-5ecc-beef-ca4e-b00b1e54a111' \ --data-urlencode 'scope=application openid' \ --data-urlencode 'clientassertiontype=urn:ietf:params:oauth:client-assertion-type:jwt-bearer' \ --data-urlencode 'clientassertion=eyJhb [...] jTw' {"accesstoken":"zeG0NoqOtlACl8q5J6A-TIsNegQRRUzqLZaYrQtoBZQ.VR6iUcJQYp3uj7pwvL7YtPqGhtyQe5OhnBE2KCp5pM","expiresin":3599,"scope":"application openid","tokentype":"bearer"}⏎ ~$ curl --insecure --location --request POST 'https://localhost//oauth2/token' \ --header 'Content-Type: application/x-www-form-urlencoded' \ --data-urlencode 'granttype=clientcredentials' \ --data-urlencode 'clientid=c001d00d-5ecc-beef-ca4e-b00b1e54a111' \ --data-urlencode 'scope=application openid' \ --data-urlencode 'clientassertiontype=urn:ietf:params:oauth:client-assertion-type:jwt-bearer' \ --data-urlencode 'clientassertion=eyJhb [...] jTw' {"accesstoken":"wOYtgCLxLXlELORrwZlmeiqqMQ4kRzV-STU2Sollas.mwlQGCZWXN7G2IoegUe1P0Vw5iGoKrkOzOaplhMSjm4","expiresin":3599,"scope":"application openid","tokentype":"bearer"}
Severity
We rate the severity as medium because the following reasons make it hard to replay tokens without the patch:
- TLS protects against MITM which makes it difficult to intercept valid tokens for replay attacks - The expiry time of the JWT gives only a short window of opportunity where it could be replayed
Patches
This will be patched with v1.4.0+oryOS.17
Workarounds
Two workarounds have been identified:
- Do not allow clients to use privatekeyjwt - Use short expiry times for the JWTs
References
https://openid.net/specs/openid-connect-core-10.html#ClientAuthentication
Upstream
This issue will be resolved in the upstream repository https://github.com/ory/fosite
Other sources
In Hydra (an OAuth2 Server and OpenID Certified™ OpenID Connect Provider written in Go), before version 1.4.0+oryOS.17, when using client authentication method 'privatekeyjwt' [1], OpenId specification says the following about assertion jti: "A unique identifier for the token, which can be used to prevent reuse of the token. These tokens MUST only be used once, unless conditions for reuse were negotiated between the parties". Hydra does not check the uniqueness of this jti value. Exploiting this vulnerability is somewhat difficult because: - TLS protects against MITM which makes it difficult to intercept valid tokens for replay attacks - The expiry time of the JWT gives only a short window of opportunity where it could be replayed This has been patched in version v1.4.0+oryOS.17
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Upgrade
Upgrade
go/github.com/ory/hydrato a version that resolves this vulnerability.Fixed in 1.4.0 - Upgrade
Upgrade
oryOS/hydrato a version that resolves this vulnerability.Fixed in v1.4.0+oryOS.17 - Configuration
Disallow clients from using the 'private_key_jwt' client authentication method (workaround: prevent replay by blocking this method).
Hydra (OAuth2 Server / OIDC Provider) client authentication method private_key_jwt = disallowed - Compensating control
Disallow replay of 'private_key_jwt' assertions by blacklisting JTIs in Hydra.
Event History
Frequently Asked Questions
What is the severity of CVE-2020-5300?
The severity of CVE-2020-5300 is classified as medium, as it can potentially expose tokens to reuse, impacting the security of user authentication.
How do I fix CVE-2020-5300?
To fix CVE-2020-5300, upgrade to version 1.4.0 or later of the ory/hydra package.
What is affected by CVE-2020-5300?
CVE-2020-5300 affects the ory/hydra package versions prior to 1.4.0.
What type of vulnerability is CVE-2020-5300?
CVE-2020-5300 is a token misuse vulnerability that arises from the improper implementation of the 'private_key_jwt' authentication method.
Can CVE-2020-5300 allow for token replay attacks?
Yes, CVE-2020-5300 could potentially allow for token replay attacks due to the lack of proper token uniqueness enforcement.