Hey, and welcome to this lightning talk on don't use JWT for authorization. My name is Sohan Maheshwar. I work in a startup called AuthZed. And the story behind this talk is it's actually pretty funny.
Some time ago, I released a YouTube video called Don't Use JWTs for Authorization. Yes, I know I have the very YouTube face in the thumbnail, etc. But what happened was about a week after putting this video out, this happened. About 35,000 views in just a week and turns out sometimes people on the internet can be not so nice because I got a lot of comments like this about calling me a genius but I think sarcastically.
People saying, hey, I have no idea what I'm talking about, something about a JWT marketplace, which I'm not sure what that is. Questioning if I've read the RSC for JWT, which admittedly is quite a boring read. And this one I think speaks for itself. So I thought I'll give this talk at a conference and see if people actually tell me this maybe in person or in the comments. But here goes. So the idea is don't use JWTs for authorization. To set context, JWTs or JSON Web Tokens are essentially a data exchange format. In this format, there are three things.
There's a header, a payload, and a signature. The two things we don't care about too much for this talk is the header, some stuff about an algorithm type, etc. and the signature, which is usually a cryptographic signature. Let's not focus on that. The part I want you to focus on for today is the payload. And this payload, again, has some data. And usually there's a name, a time of expiry, which is when the token expires, a role, and also scopes. And this is where things get interesting because how people have used JWT for authorization is in the scope add things like admin or read or write, etc. and associate that with permissions for a person in an app. So say I have read permissions and you have write permissions, that would be included in the scope and this token would be passed around when a service is created.
Now, interestingly, this scope isn't even from the original JWT or the JWT spec and actually comes from a different spec, which is the OR2 token exchange spec. So, you know, in a way, it maybe wasn't even created for this specifically for authorization and permissions, but here we are using it fairly regularly. The underlying assumption behind using this is permissions don't change during a token's lifetime. And that is very, very false, right? That's absolutely not true, especially in the complex systems that we are building today.
Comments