Only accept private JWTs for client authentication if their lifetime is shorter than some time t ("fresh tokens") #555
Mushroomator
started this conversation in
Feature requests
Replies: 1 comment 3 replies
The replay cache stores the JTI using an absolute expiration timestamp based on the private key JWT's For example, given a token with the following payload: {
"iss": "interactive.confidential.jwt",
"sub": "interactive.confidential.jwt",
"aud": "https://demo.duendesoftware.com/connect/token",
"jti": "ffe2586bd6ce435e80d288ac4a5bfa98",
"iat": 1781262757,
"exp": 1781266357
}The |
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
I want to use private JWT Bearer authentication for client authentication. I have hooked up an
IDistributedCacheimplementation to detect replay attacks. However, currently that cache only storesJTIs fixed up to 5 minutes.That is also fine, since obviously not all JTIs can/ should be stored indefinitely. But that means if somebody were to create a JWT with a lifetime of 10 minutes, the token would be stolen and replayed after 5 minutes have elapsed a replay attack would still be possible.
In order to prevent that, the replay cache expiration could be aligned with the token lifetime. So if the cache TTL is 5 minutes, a token which has a longer lifetime than 5mins would not be accepted. So basically a token would only be accpected if the following holds true:
While I could probably work with the default currently, preferrably cache TTL for JWT Bearer auth and clock skew could be configurable as well globally or per-client (as is the case with other options). Maybe there would even be an option for
StrictReplayDetection = true/ falseso it could be turned on or off.I know I could implement this already by decorating the default
ClientSecretValidatorimplementation, accessing theParsedSecretinside it, re-read the JWT token (as the parsedJsonWebTokeninstance is unfortunately not available in the context) to get the claim values, add client properties for clock skew etc. and fail the secret validation if my additional check fails. Still, I think this should be a common enough security issue that it would make sense to include it in the product directly.All reactions