In OAuth, or any other protocol where the token can be opaque or transparent, the benefits and risks swing based on what your desired result is:
- If you want the client to be able to parse the access token, you need the token to be transparent.
- If you don't want the client to be able to parse the access token, you need the token to be opaque.
Indeed, this is the definition of opaque and transparent tokens; the client can see into them, or not.
If your token is transparent, you must sign it, otherwise, anyone could simply edit your token contents, and claim anything they want.
So, the first obvious benefit of having an opaque token is that you can just throw away any signing mechanism; you don't need it, and conversely, if you have a proper transparent token, the client can read the token, but not edit it.
Another benefit of having an opaque token is it is more secure; No encryption method is truly random (i.e., there must be a way to decrypt it), meaning you can always tell which encryption protocol is used if you can read enough of the contents of the tokens (transparent tokens). This itself reduces the time to identify your cipher (knowing the protocol). Many people don't think this is very risky, and indeed, if you use more than 80 bits of entropy, they are right (10 truly random characters for your cipher, i.e. "secret key").
However, and this is much more of a risk; transparent tokens allow crackers to play with the contents (because they see them), and some protocols have serious weaknesses that allow you to create collisions or even decode the cipher in a much shorter period because the cracker will know the protocol as well as the contents of valid blocks (most encryption protocols use 16 byte-long blocks, so if your token contains 160 chars of data, you've given the cracker 10 valid combinations to your cipher. This decreases the time it will take for them to identify your cipher by an order of magnitude. Giving them more transparent tokens will further reduce this time as well. Some protocols have a reduced version of this risk, but by the nature of what encoding is, having the encoded block, and decoded block both in your hands, you're always going to make it easier to break.
This is why many choose opaque tokens. Indeed you should always opt for opaque tokens if there is no need for any external entity to be able to parse your token. An example of this is a service framework in which you only pass the token to the service as a blind claim; you have no idea what it says, but you know it works and identifies you. It is only up to the service to confirm it's you via the secret key or cipher.
Opaque tokens also don't require signing, which I mentioned above, they also don't require divulging anything about chosen protocols.
For this reason, they are much more secure, not only mathematically and logically, but get rid of human implementation errors, which is, to be honest, 99% of the reason cracks are ever made in the first place.
Interesting note
Even true randomness means a 36.7% loss (1 divided by e) of combination space when randomly guessing. This means a 1000 possibility combination lock, if guessed randomly, actually has a 1 in 630 chance of getting it correct.
So 1 / e is the absolute best chance you have, and that is pure random.
Any "possibility" that is interesting to a human, "information", is not truly random by definition, and worse, any protocol that is used to decode it, gives up some possible space for the cipher by the way the protocol works. So, in reality, your chances of randomly guessing an answer is significantly smaller than the entropy or combination space most people talk about or think they actually have; it's usually, when all accounts are measured by a good hacker, at least one order of magnitude easier than a layperson thinks.
You might think that given a random choice in the range of n, the chances of picking that choice randomly is 1 / n. But this is not what happens randomly, this is what happens when you also attach the behavior of avoiding duplicate guesses.
Given the range of n containing a single intended answer, and given n random guesses at finding this answer, you will duplicate 1 / e attempts, per attempt, if you opt for a random guess. Given the answers location is also random, it will also be placed in identical locations with a chance of 1 / e.
– Nick Steele Jul 31 '19 at 22:30