News for hackers. Stuff that matters.
Re:Should I Use jwts For Authentication Tokens? by torginus on Tuesday May 28, 2024 @01:17AM (#40497544)
Honestly, do you even need support for revoke? If you have a token whose lifetime can be measured in 2-3 minutes, I don't think the abuse potential is huge, especially when some other security measures are in place.

Thing is, token refresh service can be stateless, but adding a revoke service basically kills JWTs main advantage, since every time we check its validity, we need a query to see if its been revoked.

Re:Should I Use jwts For Authentication Tokens? by nine_k on Tuesday May 28, 2024 @01:37AM (#40497650)
Revocation is needed because you want to disable access to an intruder in the very second you detect unauthorized access using a stolen token. Same for certain kinds of banned users who must lose access immediately.

But since such a revocation list is going to be short (usually 0 entries, dozens at worst), it's trivial to replicate across all the auth service nodes (which can as well be worker nodes) or keep it in Redis replicated per DC, with sub-millisecond lookup times.

Things get harder if you want a feature like logging out other sessions, or just an explicit logout on a shared computer (think about business settings: stores, pharmacies, post offices), you may have to have larger revocation lists. This may still not be a problem: a million tokens is a few dozen megabytes, again, a per-DC replicated Redis cluster would handle it trivially and very cheaply.

Re:Should I Use jwts For Authentication Tokens? by torginus on Tuesday May 28, 2024 @02:18AM (#40497877)
I still feel like the need for revocation kills the simplicity of JWT and thus the reason for its existence.

I'm of a more gradual opinion regarding this - say you operate a movie streaming service and control access to movies via JWT. It's not a problem if an attacker has access for two more minutes than intended.

If you are talking to a single client, I think checking the remote IP address and encoding it in the token might work to see if the token is not stolen, but don't quote me on that.

Re:Should I Use jwts For Authentication Tokens? by g15jv2dp on Tuesday May 28, 2024 @10:53AM (#40501292)
It's a complicated problem. I don't see why it should have a simple solution.
Re:Should I Use jwts For Authentication Tokens? by stickfigure on Tuesday May 28, 2024 @10:31AM (#40501090)
> Revocation is needed because you want to disable access to an intruder in the very second you detect

I get that this has conceptual appeal, but I doubt this makes any difference in real life. Unless you have some very sophisticated infrastructure, it takes many minutes to discover the issue and then many more minutes even to decide what to do about it. A few extra minutes to cut off access is probably not going to make a big difference one way or another.

Re:Should I Use jwts For Authentication Tokens? by nine_k on Tuesday May 28, 2024 @02:53PM (#40504142)
An intruder might be not a sophisticated black hat hacker. It could be somebody who picked up an unlocked phone or keyboard.

When I had a chance to design a token-based authn/authz system, we had two types of tokens, general access (with hours of expiration, mostly read-only access) and privileged access, with expiration time set to a minute or so. All auto-refreshed on use, all separately revokable.

Re:Should I Use jwts For Authentication Tokens? by stickfigure on Wednesday May 29, 2024 @07:00PM (#40518111)
Sure, but isn't it still going to take you N minutes/hours/days to discover the violation? Does it make a material difference that you can revoke access this hot second as opposed to up-to-5-minutes when the token expires?

Seems to me that for most applications, the irrevocable 5-minute token seems "good enough".

Re:Should I Use jwts For Authentication Tokens? by withinboredom on Tuesday May 28, 2024 @02:20AM (#40497885)
All you really need for revocation in a revocation service are two fields: user id + inb (issued not before) and a bloom filter.

To revoke a token:

1. issue a new token to the revoker that is issued at current time (if business rules require revoker to be logged in).

2. set user inb to current time - 1 second with a TTL of longest issue * 1.5.

3. Add user to bloom filter.

4. upload bloom filter to s3, every service downloads this every 5 minutes.

5. Then on request, check bloom filter. If the user id is in the bloom filter, check with revocation service that inb > issued time.

This is probably less than five hundred lines of code and pretty easy to maintain.

Re:Should I Use jwts For Authentication Tokens? by littlecranky67 on Tuesday May 28, 2024 @09:31AM (#40500573)
Often overlooked middle-ground that vastly simplifies your revocation logic: Just have a single field "not-issued-before" timestamp assigned to each user account. Instead of revoking a single token, you have a "log out from all devices" logic - i.e. you revoke all tokens at once based on their "iat" claim (issued at). No need for revocation lists alltogether, you just make sure any tokens "iat" is never before the "not-issued-before" associated with the user. Sure, this is not as perfect UX as being able to revoke individual tokens, but token revocation in generall is something only a fraction of your uses is ever going to need.
Re:Should I Use jwts For Authentication Tokens? by withinboredom on Tuesday May 28, 2024 @09:34AM (#40500601)
Yeah, this works very well. A nice "log me out of everywhere, including this device" link is often all you need on the settings page.

It also makes e2e testing very easy since you should be logged out after pushing that button.

Re:Should I Use jwts For Authentication Tokens? by pico303 on Tuesday May 28, 2024 @06:29AM (#40499248)
How about invalidate the user’s refresh token and the public signing key, which forces everyone to refresh and then logs out the hacked account. If it’s really serious, lock the account before doing this so the user can’t login again.

But yeah, if you have a revoke service, might as well just use session keys.

Edit: typo

Re:Should I Use jwts For Authentication Tokens? by littlecranky67 on Tuesday May 28, 2024 @09:38AM (#40500653)
No you don't, thats why i.e. even big players like Amazon with their AWS Cognito service (OAuth/OpenID Connect) don't even support revoking access tokens (only refresh tokens).