News for hackers. Stuff that matters.
Re:Biscuit Authorization by jameshart on Thursday December 14, 2023 @12:36AM (#38638178)
JWTs let you reject unauthorized requests on their face, without having to even make a database call.

Protecting your database from even being queried when the request is unauthorized reduces your attack surface enormously.

Re:Biscuit Authorization by marcus_holmes on Thursday December 14, 2023 @02:31AM (#38638757)
I don't get why that's a reduction in attack surface?

I guess DDOS attacks - if we're checking the session ID on every request then that's a potential attack if you just make up uuids and throw them at the server.

But JWT's themselves are an attack vector, surely? If there's any mistake in the encryption (or any vulnerability in the libraries used) then this is a door open very wide indeed.

The beauty of session IDs is the simplicity of it - very few moving parts, so very few opportunities for mischief. JWTs seem to be the opposite: lots of moving parts, lots of opportunities.

Re:Biscuit Authorization by antran22 on Thursday December 14, 2023 @06:18AM (#38640151)
JWT doesn't encrypt (by default) the payload. The header & payload is passed through base64 and appended with a hash to produce a JWT. JWT verifying doesn't require making API call, and is essentially a hash check. Any verifier with a public verification key can determine if the JWT is bogus by a quick hash check and reject the request right away.

Comparing to session IDs, you have no way to know if an unique id is bogus or not. You have to check from a list, be it a cache or a database. This limits the scalability of the solution. I'm not an expert, but AFAIK JWT verifier can be stationed on the edge of the application network, and I have not checked this but I suspect they can even make a hardware solution for those kind of activity. That's definitely a big reduction of attack surface in terms of DDOS.

IMO JWT doesn't have that many moving parts. Encryption parameters are handled by libraries according to tested standards. The only real thing you need to do is to keep your private key safe.

Re:Biscuit Authorization by GTP on Thursday December 14, 2023 @07:51AM (#38640773)
> Any verifier with a public verification key can determine if the JWT is bogus

So you have to check a signature, right? Maybe this is what the other commenter meant when mentioned encryption.

Re:Biscuit Authorization by marcus_holmes on Thursday December 14, 2023 @07:47PM (#38649636)
Yeah. The mechanics of JWTs are complex, involving maths that is easy to get wrong. Hopefully the implementation is based on a standard library and the author didn't roll their own crypto. Hopefully the library hasn't got any known vulnerabilities. Hopefully the implementation hasn't got any problems. Because the JWT actually contains sensitive information that is useful to an attacker, and if they can forge their own JWTs then the system is wide open; all the attacker needs to do is work out the username of an admin (or worse, the JWT itself tells the system if the user is an admin).

Session IDs don't have any of these problems. It does mean you have to do a database lookup on every request, and that can cause problems with scale, but if you have to hit the database anyway for other reasons then you have that problem anyway and have to solve it for those other reasons.

Re:Biscuit Authorization by tptacek on Thursday December 14, 2023 @12:56AM (#38638280)
So does every Rails and Django encrypted session token.
Re:Biscuit Authorization by gkbrk on Thursday December 14, 2023 @01:38AM (#38638484)
How do you revoke an encrypted session token that doesn't need to hit the database to see if the request is authorized?
Re:Biscuit Authorization by DecoPerson on Thursday December 14, 2023 @01:46AM (#38638531)
Include an expiry time in the encrypted part. The encryption, and the fact the token decrypts invalidly if not encrypted with the correct key, acts like a discount JWT.

Encrypted session tokens with embedded expiry will serve the needs of 99% of applications/services.

Re:Biscuit Authorization by tonyhb on Thursday December 14, 2023 @02:13AM (#38638652)
In that case why not use JWTs which do this for you? In your case you end up building a subset of JWTs yourself.
Re:Biscuit Authorization by grey-area on Thursday December 14, 2023 @04:35AM (#38639505)
A subset of JWTs sounds great given the previous security vulnerabilities found in JWTs and the huge surface area they give you:

https://www.akto.io/blog/jwt-none-algorithm-test

Re:Biscuit Authorization by robertlagrant on Thursday December 14, 2023 @04:51AM (#38639608)
This is not a huge surface area. I don't know why this keeps coming up, but, while a silly default, is incredibly straightforward to not configure / remove / test for.
Re:Biscuit Authorization by grey-area on Saturday December 16, 2023 @02:45AM (#38662543)
JWTs are definitely a much larger surface area than simpler encrypted sessions storage and most people don’t need that.

I cited this as one example of that surface area that led to serious vulnerabilities. Most people don’t need multiple ways to encrypt their data, and certainly not a ‘no encryption’ option. Each added option adds more ways to mess things up.

Re:Biscuit Authorization by the_gipsy on Thursday December 14, 2023 @03:10AM (#38638981)
These might predate JWTs.
Re:Biscuit Authorization by kevindamm on Thursday December 14, 2023 @03:34AM (#38639138)
Indeed, RFC 7519 dates from 2015 while both Rails and Django are older than that by a decade or more.
Re:Biscuit Authorization by DecoPerson on Thursday December 14, 2023 @07:30AM (#38640652)
JWTs are complex.

Encrypted session cookies are a proven solution, widely used, and easy to implement yourself using only core libraries (http, crypto, JSON) without introducing security flaws IFF you are an experienced programmer and don’t deviate from the norm.

JWTs are complex. Too complex to implement yourself, so you need to introduce dependencies. Dependencies are usually huge, and each line of code introduces risk (even if that line is for a configuration you don’t use!). Using JWTs at all is far more risky, even if you are an experienced programmer.

If JWTs provides immense benefits over session tokens for your use case, that risk might be worth it. However, for most web apps, session tokens are good enough.

Re:Biscuit Authorization by marcus_holmes on Sunday December 17, 2023 @09:31PM (#38678630)
No idea why you're being downvoted. This is the truth.
Re:Biscuit Authorization by NovemberWhiskey on Thursday December 14, 2023 @08:13AM (#38640959)
Revocation in this context almost always means "suspension of the validity of a token prior to expiration", so that's not really an answer.
Re:Biscuit Authorization by jameshart on Thursday December 14, 2023 @09:21AM (#38641599)
Sure. Just pushing back on the ‘you’re going to hit the database anyway’ argument. Having some kind of mechanism for eliminating obviously bogus requests is a good idea. Some sort of signed, expiring token is probably a good idea for that. Rolling your own expiry/signing mechanism is probably a bad idea. Correctly validated JWTs are an option (among many) for solving that problem.
Re:Biscuit Authorization by bzbz on Thursday December 14, 2023 @09:02AM (#38641404)
So sign your UUIDs and combine them into “$UUID:$HASH” strings for the same benefit. Or a more structured JWT-like payload that still verifies auth against the DB (as opposed to carrying authorization within the token).

No need to reinvision the rest of the auth flow if you just want to add hashing to reduce DB load.

Re:Biscuit Authorization by cchance on Friday December 15, 2023 @11:01AM (#38655413)
so ... recreate jwt?
Re:Biscuit Authorization by unscaled on Monday December 18, 2023 @05:49AM (#38681051)
If you're worried about DDoS (and also timing attacks, if you've got a B-Tree index), you can just append an HMAC to your random session ID.

I've even seen a few cases of Stateful JWTs, where the JWT contained a session ID and everything else was in the DB. Of course, this approach manages to be both an overkill and a security and inferior to the just-use-an-HMAC approach at the same time.