10 ms·
This is better than JWT. In particular: the whole protocol is versioned, rather than serving as a metaprotocol that negotiates the underlying cryptography. If y
by tptacek 9y ago
This is better than JWT. In particular: the whole protocol is versioned, rather than serving as a metaprotocol that negotiates the underlying cryptography. If you speak "v2" of this protocol, and refuse to accept any other version, then you're getting a token that is basically just Nacl.
My only nit --- apart from the "auth enc seal sign" names, which aren't coherent --- is why do public key at all? Yes, Nacl supports it, but that doesn't mean the token format does. What's the use case for it? Who's asking for it? Specifically who? The overwhelming majority of JWT implementations I see aren't public key (except for the fact that the format is negotiated and might be tricked into being that).
Why not punt "seal" and "sign" into a "v3", when/if it's needed?
- CiPHPerCoder 9y ago> My only nit --- apart from the "auth enc seal sign" names, which aren't coherent --- is why do public key at all? > Why not punt "seal" and "sign" into a "v3", when/if it's needed? Would you be happier seeing something like this? - v1: HMAC-SHA2, AES-CTR+HMAC-SHA2 - v2: RSA and all its sins - v3: Libsodium crypto_aead_* - v4: Libsodium crypto_{box,sign}_* > What's the use case for it? Who's asking for it? Specifically who? The only use-case I'm aware of as of this morning is OAuth2 users who currently use JWT for access tokens. https://bshaffer.github.io/oauth2-server-php-docs/overview/jwt-access-tokens/ https://bshaffer.github.io/oauth2-server-php-docs/overview/j...
- unscaled 9y agoI would happily do away with v1 completely. In my unfortunate experience you're still giving developers enough rope to hang themselves with by choosing older ciphers just because they are well-known.
- unscaled 9y agoTo extend on that, I can give list the lessons I learned from actually running a similar scheme internally in production for a while now: 1. Give developers the minimum amount of knobs. If they need to choose between 'auth', 'enc', 'seal' and 'sign' it's still going to be confusing. In my case they can personally come to me and ask "Which version should I use? Which type should I use?", but it's not clear. I'm still undecided whether supporting an unencrypted authenticated token is useful, but 'enc' should ideally be the default, with users going a little bit more out of their way to do anything else. 2. Asymmetrically signed payloads with an expiry are this strange bird that looks like a duck, quacks like a duck but unfortunately _are not a duck_. They're certainly useful, but when I was calling them 'tokens', my users were confused whether they should use them as access tokens. It's great to have a simple and robust encoding format for packaging payloads with an Ed25519 signature, but it's better to clearly call it something other than 'token', or you'll end up with users deciding they should use asymmetric access tokens just because it makes the key more secure. 3. You want to have some mechanism to specify key ID or key version in the wrapper, because this allows you to do automatic key rotation gracefully. You can use the optional (AEAD) payload for that, but that wouldn't be entirely clear to the users how. Let's say you want to rotate the key every week, but your longest token has a TTL of 24 hours: you will need to have a window where you would support two different encryption keys. In other rotation scenarios (e.g. rotating every 24 hours with longest token TTL being 30 days) you can have many more encryption keys supported concurrently. You can iterate and try all possible keys of course, but having key ID/version is much cleaner.
- blattimwind 9y ago> In particular: the whole protocol is versioned, rather than serving as a metaprotocol that negotiates the underlying cryptography. In my view, that's one of the big takeaways from early cryptographic protocols: complex handshake negotiations just won't be secure, so just don't. The other is that crypto code should ideally not contain any parsing at all. e: Well that and the whole debacle on the level of primitives and operation modes of course.
- eadmund 9y agoWe use public-key JWTs so that the verifying servers do not have a copy of the secret key, just the authorisation server's public key. That prevents a compromise of the verifying servers from also compromising the entire system (yes, a compromised verifying server can be made to do anything it's allowed to do — but that's still less than everything).
- davars 9y agoAlso, issuing servers and verifying servers don't even need to be part of the same organization, allowing you to outsource credential management (see Auth0, Firebase Authentication).
- lvh 9y agoYou can do that fine with secret-key cryptography too.
- davars 9y agoBy downloading a shared key over TLS rather than the provider's public key? No difference from the perspective of the token consumer. From the perspective of they token generator, it means rotating per-tenant keys rather than a single keypair.
- lvh 9y agoI addressed this elsewhere (https://news.ycombinator.com/item?id=16072690 https://news.ycombinator.com/item?id=16072690) but to quickly recap: that's not the hard problem, and hardened SAML IdPs that have the option of exploiting this turn out to have per-tenant keys anyway so that they can get cryptographic binding instead of counting on audience restrictions being checked. Additionally, your TLS terminating stack is much better hardened than median in-app crypto code.
- orf 9y agoWe do exactly the same, it's a great feature to have in JWT's.
- cmsd2 9y agoreally? both Azure AD and AWS Cognito use RS256 as the only algorithm supported. perhaps my sample size is small.
- logicuce 9y agoGoogle OAuth 2 tokens are also RS256 JWTs
- lvh 9y agoThe requirements and budget of Google, Amazon and Microsoft are very different from a median start-up. A simple closely related field: OAuth 2 token replay attacks. I auth against A with Facebook, A uses token to impersonate me against B. ISTR Google had basically the same bug. A median startup will not find that bug. Storing a random token in a database? Very likely they won't mess that one up. Also, if you do (let's say your randomness generator is MT as opposed to a CSPRNG), it's easy to fix, because you control the validation endpoint.
- logicuce 9y agoIt is not a bug with Google but instead a problem with "B" as they choose to ignore the "aud" part of the token. You can't say password based authentication is bad because some developers choose to store password in plain text. The blame squarely lies with the developer. People implementing auth without willing to go a little deeper may hurt themselves.