147 points · by pr0zac · 11y ago · 50 comments
http://www.thoughtcrime.org/blog/the-cryptographic-doom-prin...
This can be problematic and need some leg-work on a developer's side when the URLs to be whitelisted aren't documented. For example Apple use a similar signed blob to allow 3rd parties to verify a Game Center identity, using generateIdentityVerificationSignatureWithCompletionHandler. The data you get back includes the publicKeyUrl, but not which URLs to expect. A naive implementation would just download the public key and run with it. Bad for two reasons: you're now downloading data from an arbitrary location and you are trusting a signature that you verified using untrusted information. In case anyone is interested, the two locations I've seen Apple provide here are https://sandbox.gc.apple.com and https://static.gc.apple.com .
But these "typical JWT lib api vulns" are WAY SIMPLER than Vaudenay etc. Any programmer could do this in minutes or less. WOW. It's so obvious and straightforward (in hindsight I suppose). My mouth is still hanging open.
<3 OSS
If you're switching off an algorithm, you're probably doing it because it's been broken. And, if it's broken, you won't use it anyway.
OT but what does TFA stand for? I've seen you use it in two threads and I presume it's referring to the posted article in question but I can't figure out the actual meaning.
Where are the CVEs?! ... OK, I just sent a brief write-up to the oss-security list, we'll see what happens.
My team has been using ruby-jwt, so I'm glad to see that at least does not seem to be on the list of vulnerable libraries.
From the specificaiton: Even if a JWT can be successfully validated, unless the algorithm(s) used in the JWT are acceptable to the application, it SHOULD reject the JWT.
So what it is saying is that you should have code in your application to make sure to only trust algorithms that you like.
The other issue is that following the specifications rules for validation get you in a hairy spot where this vulnerability exist:
https://tools.ietf.org/html/draft-ietf-oauth-json-web-token-...
Your site may well find both HMAC and RSA to be acceptable algorithms. However if you can be tricked into using HMAC to verify something actually signed with RSA, then anyone can forge content you accept as valid.
What is important is not that the algorithm is acceptable. It is that the algorithm you use for verification is the algorithm that actually should be used.
payload = '{"loggedInAs":"admin","iat":1422779638}'
I've always worked under the assumption that everything the client sends is wrong; which means the only fields I issue are a user hash and session key. If either of those don't match the session table record then the token is rejected. Having group permissions issued from the client side seems like a bad design from the offset - however this seems a really obvious point to make, which makes me wonder if I'm missing the point of JWT's.Is anyone able to expand on this for me please?
The client can send something wrong? Yes, as long as the client can digital sign what is sending with the secret you expect.
JWTs can be signed with a symmetric key or an asymmetric key, the vulnerability mentioned in this post is when the server-side expect a token digitally signed with an asymmetric key but an unauthorized client uses the public key to create a signature as if the key where symmetric. The issue in this case is when the server is blindly accepting any algorithm.
For example, a Netflix employee can log onto the Netflix Single Sign On system, and that system can issue them a signed token saying "The bearer of this token can log into this AWS account with these powers until this time". The employee presents this to AWS and, if the signature is valid, AWS lets them log on.
That way each employee only needs one account - on the Netflix Single Sign On system - instead of them also needing an AWS account (with a separate password, 2FA and so on).
(SAML is another standard for doing this, but it's a standard with a lot of unnecessary complexity)
However, in certain cases it's useful to have stateless sessions (or rather, moving the state to the client, using signed and/or encrypted tokens).
In this case, JWT is used by e.g. OpenID-Connect, to pass data between systems. In some of these use-cases the client is an intermediary, passing along the token.
If you don't mind me asking a few more questions, how are the JSON web tokens typically authenticated if not via a database? Or are they assumed correct?
edit:
Would the guy who down voted me mind explaining why it's now bad etiquette to ask questions on HN? Or was there something more specific about the post which you took a dislike to?It's becoming impossible to navigate around the complex neuroticisms of every HN member (since it can take only 1 vote to make a comment grey) so a little assistance would be greatly appreciated. :)
They are signed with a private key (e.g. a secret random 32-bytes kept by the server) when they are issued. Revocation is typically based on an expiration time, hence the timestamp in the header.
The JWT libraries in this case failed their basic premise, that is, to verifying the signature. An unsigned token which contains trusted data is just an open door for the user to claim whatever they want.
The centralized session model is easier to reason about, but has many pitfalls. Now all your servers need to be able to contact that centralized state in order to service even a basic request. HMAC is very fast, much faster than pulling central state from a network service. If you're asking a client to maintain a session token, might as well ask them to maintain the session state itself if it's small enough to fit in a cookie.
I would guess the reason for any downvote is the question you're asking is directly addressed by TFA, so it strongly implies you didn't bother to read it.
Cryptography is used to verify them.
- Ruby, Java, Lua, Scala and .NET are unaffected
- updates are available for Node.js and Python
- there are still no fixed version for JavaScript and PHP libs
https://github.com/firebase/php-jwt/blob/master/Authenticati...
It's not in the methods array and the decode method specifically does a check to see if it's empty.
if (empty($header->alg)) { throw exception }
Can anyone throw some light on this?
As the original post describes, if your code expected to use a RSA public/private key pair, then it will pass the public key to decode(). Then an attacker can craft a JWT that claims to use a HMAC symmetric key and sign it with the public key, which is public. One and done.
(your code in that case expected the header to specify an RSA algorithm, and be signed with the private key. but the decode() function doesn't know that)
So now what? The draft [0] hasn't expired yet, so it's possible they'll just rip out the public-key stuff. What should they add to answer your reservations about CTR+HMAC?
[0] http://self-issued.info/docs/draft-ietf-oauth-json-web-token...
https://www.timmclean.net/2015/03/31/jwt-algorithm-confusion...
um...