I don’t see the point in Revoking or Blacklisting JWT

I heard someone asking today for support for Revocation of JWT, and I thought
about it a little, and decided I don’t see the point.

Specifically, I don’t see the point of the process described in this post regarding “Blacklisting JWT in express-jwt“. I believe that it’s possible to blacklist JWT. I just don’t see the point.

Let’s take a step back and look at OAuth

For those unaware, JWT refers to JSON Web Token, which is a type of token that can be used in APIs. The format of JWT is self-describing.

Here’s the key problem tokens address: how does a server decide whether to honor or reject a request? It’s a matter of authorization. OAuthV2 has been proposed and is now being used by the industry as the model or framework for enabling authorization in API-oriented apps. Basically it says, “give apps tokens, then grant access based on the token.”

Often the way things work under the OAuth framework is:

  1. an app running on a mobile phone connects to a token dispensary (a server) to request a token
  2. the server requires the client (==app) to provide some credentials before generating and dispensing a token. Sometimes the server also requires user authentication before token delivering a token. (This is done in the Authorization Code grant or the password grant.)
  3. the client app then sends this token to a different server to ask for services.
  4. the API server evaluates the token before granting service. Often this requires contacting the original token dispensary to see if the token is good, and to see if the token should be honored for the particular service being requested.

You can see there are three parties in the game: the app, the token dispensary, and the API server.

One handy optimization is to put the API endpoint behind an OAuth-aware proxy server, like Apigee Edge. (Disclaimer: I work for Apigee). The app then contacts Edge for a token (via POST /token). If the credentials are good, Edge generates and stores an opaque token, which looks like n06ztxcf2bRpN42cDwVUNvroGOO6tMdt, and delivers it back to the app. The app then requests service (via GET /service, or whatever), passing the previously obtained token. Edge sees this request, extracts the token within it, evaluates whether the token is good, and either passes the request through to the API endpoint or rejects it based on the token status.

The key thing: these tokens are opaque. The app doesn’t know what that token is, beyond a string of characters. The app cannot tell what the token is good for, unless it asks the token dispensary, which is the final arbiter. Sometimes when dispensing the token, the token dispensary also delivers metadata about the token, like: expiry, scopes, and other attributes. But that is not required, and not always done. So, bearer tokens are often opaque, and they are opaque by default in Apigee Edge.

And by “Bearer”, we mean… an app that possesses a token is presumed to “own” the token, and should be granted service based on that token alone. In other words, the token is a secret. It’s like cash money – if you lose it, someone else can spend it. But not exactly like cash. An opaque token is more like a promissory note or an IOU; to determine if it’s worth anything you need to go back to the issuing party, to ask “are you willing to pay up on this note?”

How is JWT different?

JWT is a different kind of OAuth token. OAuth is just a framework, and does not stipulate exactly the kind of token that needs to be generated and delivered. One type of token is the opaque bearer kind. JWT is an alternative format. Rather than being an opaque string, JWT is a self-describing format for bearer tokens. Generally, a JWT includes an encoded payload that can be decoded and read by anyone, and that payload contains a bunch of claims. The standard set of claims includes: when the token was generated (“issued at”), who generated it (the “issuer”), the intended audience, the expiry, and other things. JWT can include custom claims, such as “the user is a good person”. But more often the custom claim is: “this user is authorized to invoke /serviceA at endpoint http://example.com”, although this kind of claim is shortened quite a bit and is encoded in JSON, rather than in English.

Optionally accompanying that payload with its claims is a signature, which can be verified by any party possessing the public key used to sign it, (or, when using secret key encryption, the secret key). This is what is meant by “self describing”. The self-describing nature of JWT is the opposite of opaque. [JWT can be unsigned, can be signed, or can be encrypted. The encryption part is an optional part of the spec.]

(Commercial message: I said above that Apigee Edge generates opaque bearer tokens by default. You can also configure Apigee Edge to generate signed JWT.)

Why Self-describing Tokens?

The main benefit of a model that uses self-describing tokens is that the API endpoint need not contact the token dispensary in order to determine if the token is good, not-expired, and if a request bearing such a token ought to be honored. In other words, JWT supports federation. One party issues the token, another party can verify it, without contacting the issuer. Remember, JWT is a bearer model, which means the possessor of the token is presumed to be authorized to get service based on what’s in the token. This is truly like cash money this time, because … when honoring a JWT, the API endpoint need not contact the issuer, just as when accepting a $20 bill, you don’t have to contact the US Treasury to see if the bill is worth $20.

So how ’bout Revocation of JWT?

This is a long story and I’m finally getting to the point: If you want JWT with powers to revoke the token, then you abandon the federation benefit.

Making the JWT self-descrbing means no honoring party needs to contact the issuer. Just verify the signature (verify the $20 bill is real), and then grant service. If you add in revocation as a requirement, then the honoring party then needs to contact the issuer: “I have $20 bill with serial number T128-DCQ-2872JKDJ; should I honor it?”

It means a synchronous call across the two parties. Which means federation is effectively broken. You abandon the federation benefit.

The corollary to the above is that you also still incur all the overhead of the JWT handling – the signing and verification. So you get all the costs of JWT and none of the benefits.

If revocation of bearer tokens is important to you, you could do the same thing with an opaque bearer token and eliminate all the fussy signature and validation stuff.

When you’re using an API Proxy server like Apigee Edge for both issuing and verifying+validating tokens, then there is no expensive additional remote call to check the revocation status. But you still lack the federation benefit, and you still incur this signing and verification nonsense.

I think when people ask for the ability to handle JWT with revocation, they don’t really understand what they’re asking.

Architecture , ,


  1. Guillaume Berche

    [Typo fixed]

    Thanks for this great blog. Can you please help me find the apigee documentation which describe how to configure apigee to generate signed JWT access tokens, and how apigee would support resource servers (api endpoints) verifying the signed JWT access tokens (i.e sharing secret or public /private keys) ?

    • dpc

      Hi Guillaume,
      First, In general with questions like this about Apigee’s products, I suggest that you post to http://community.apigee.com, which is the Q-and-A forum monitored by all the Apigeeks.

      Specific to this question though, I have build an Apigee Edge callout in Java which does Verification of JWT. And also another which does generation of JWT. The verifier can verify signatures either done in HMAC or with RSA public/private key pairs, and can verify the presence of specific custom or standard claims in the JWT. Once the JWT is verified, Apigee Edge could inject a header into the request before proxying it to the backend api resource. The header could be something as simple as “approved” or it could be a compound value with elaborations from the JWT contained within it. An Apigee technical field person can show you all of this.

  2. Denis

    Exactly my thoughts.

    If you are gonna be revoking or blacklisting JWT tokens most of the time you could just use normal opaque tokens with same functionality but less complexity.

    The only benefit of JWT tokens in this scenario is that you could check validity and expiry of token before hitting the Auth server.

  3. I’m looking at implementing a JWT token service soon and had been thinking about this. My thought was as the blacklist probably won’t be that big or updating too often then the auth service could publish a bloom filter of blacklisted jti’s. Services would keep a copy of the bloom filter to minimize requests to the auth service to check the validity of the token.

  4. Peter Schulz

    Good post.

    I think there is another angle to the revocation problem.

    I believe the easiest way to handle this “issue” is simply issuing tokens with (short) expiration periods. People asking for revocation must be attempting to issue indefinitely valid tokens, or expiration periods in terms of years, like the way you issue SSL certificates. For me such a use borders on misuse of JWT. They are for authenticating on the web – you log in, you do some actions, you are gone (and so is the token!). It’s fast and short and that’s what JWT is IMHO really meant for.

    Used that way the question of “revocation” does not even enter the picture.

    • dpc

      YES! Exactly right. Short-lived tokens are the best tokens. How short is short? Probably 30-60 minutes. Refreshing a token should be pretty easy and painless for the user.

  5. Thanks for this great post. I agree with most part of it.

    However, I still think there is a point in JWT revocation from a security point of view.

    First of all, JWT does not only apply to OAuth. You can have a custom authentication system and still use JWT. But, as you said, talking about OAuth, and being Authorization Server and Resource Server different servers (which it is not always the case), you loose the federation benefit. In other scenarios, maintaining a blacklist or some other revocation mechanism, you also loose the benefit of stateless tokens.

    However, as I said, I see some security benefits in using JWT and being able to revoke them. Opaque tokens have some security concerns related with the fact they are persisted in the server, just like passwords: the need to store them hashed, timing attacks, an expiration mechanism… This is not the case for JWT, even if you store its `jti` claim in a blacklist (alone, it is useless information).

    If third party clients are accessing a server that uses JWT, it is unacceptable to trust those clients will do the right job and destroy tokens from its store. A lot of times, using short lived tokens is not usable. But, again, I think that in these scenarios, using JWT with an stateful revocation system, even with its looses, have security benefits.

    • Well, doing further research I see that JWT could be sensitive to timing attack just like with any opaque token. The comparison exists anyway… I got confused. Still you gain not having to hash anything and, usually with current libraries, expiration time management for free. But it is one point less for it in my personal scoreboard 🙂

    • dpc

      Absolutely right! JWT are useful in scenarios outside of OAuth.
      Rather than focusing on how to revoke JWT, I think it might be better to just enforce short-lived JWT, and focus on revoking the clients, if necessary.

      But that’s just my perspective.

  6. jsonwebtoken

    hey.. the module below lets you authenticate JWT based on IP of incoming request. is this any useful?

    • dpc

      I haven’t seen the module, but yes, sure! that’s a possibly valuable approval mechanism or restriction.
      For example, a client runs on a particular IP address. It obtains a JWT, and then presents it back when requesting service. When checking the token, the service side can verify the IP claim in the JWT against the actual IP on the inbound request. That means if the JWT gets swiped, it cannot be used from a different IP address. so, yes, could be very useful.

Leave a Reply

Your email address will not be published. Required fields are marked *