3 ms·
Just to be a little bit pedantic about the article. Do not contain any sensitive data in a JWT. If there's nothing sensitive in the JWT then why might we
by ejcx 10y ago
Just to be a little bit pedantic about the article.
Do not contain any sensitive data in a JWT.
If there's nothing sensitive in the JWT then why might we encrypt it? Sometimes the whole purpose of a JWT is to pass some sensitive auth information whether as a session cookie or an authentication token that a service uses.
If you worried about replay attacks, include a nonce (jti claim), expiration time (exp claim), and creation time (iat claim) in the claims
This isn't always the case... One of the reasons JWT is so powerful is the asymmetric key operations built in to the spec. If some JWT generation and signing body signs a JWT and someone else steals the JWT, all consumer services of the signing service are vulnerable to a replay attack. The JWT is valid for use at ALL consumer services.
If you have symmetric keys and are encrypting/signing a JWT to communicate, and you want to prevent replay attacks with a JTI and EXP, you've lost the stateless property of JWT in order to do it correctly, and you haven't solved the problem of using the JWTs at OTHER services. It only works for 1 to 1 communication.
If you're preventing replay attacks inside of a JWT you've chose the wrong battle and you've decided to design a cryptographic protocol on top of JWTs. Don't pick this fight. Just go home.
The secret signing key should only be accessible by the issuer and the consumer
This won't be the case for asymmetric keys. Services that create JWTs and sign them for other services to verify should not share the private key with other services. This is basic crypto but if someone reads this ONLY this article they may not know.
- omgitstom 10y agoThanks, Evan. these are all good points, I'm surprised to see this on HN since it is an old article I wrote. In regards to the replay attacks, if you are using JWTs in a 3 party setup, and they are validating JWTs locally (not sending them back to a validation endpoint), the jti claim won't be enough. Thanks again for clearing that up! Considering this blog post may still have a use, I'll update it soon.
- ejcx 10y agoHeheheh, no problem. I recognized it was your article, Tom. Sorry to be pedantic. Jose is really just way too complicated. Go Dukes!
- omgitstom 10y agoDefinitely not pedantic! Believe it or not, JOSE was still a draft when this blog post was released into the wild.
- monknomo 10y agoWhat would you need in addition to a jti claim in a 3 party setup with local validation?
- BillinghamJ 10y agoOP is most likely using "JWT" to refer to a JWS - the most common form of JWT by a very wide margin. JWSes are not encrypted, only signed, so it is true that you must not put sensitive information inside a JWS. You might want to use a JWE, but that is not in scope for the article.