Modern Web Auth Blueprint
Transcript
Made automatically from the video's sound, so it may contain mistakes. Click a line to play from there.
Welcome to this explainer. Look, we're skipping the basic hotel key card analogies today. We are getting absolutely straight into the cryptography, the protocol flaws, and the mathematical proofs that actually secure modern web identity.
If you're the one architecting authentication flows, consider this your blueprint. Here's our agenda for today. One, bulletproof credential storage. Two, stateful sessions versus stateless JWTs.
Three, preventing JWT attack vectors. Four, securing OAuth and OIDC. And finally, five, the WebAuth and pass key paradigm. Let's get into it.
Section 1. Bulletproof Credential Storage, securing the foundation. Right. You absolutely have to establish a hard boundary between your salts and your peppers.
You probably already know that CSPRNG salts are generated per credential and sit right there in your database to defeat pre-computed rainbow tables. But peppers, they operate on a totally different plane. An HMAC Pepper is a secret cryptographic key that must live completely out of database in a secure vault or HSM.
It is literally your ultimate defense in depth. Even if an attacker dumps your entire database, they cannot crack those hashes without that vault-stored pepper. Now, for password hashing, the OWASP standard is Argonne 2 ID.
But you can't just plug it in blindly and walk away. You've got to tune it to maximise the attacker's cost. You need to configure at least 19 MBytes of memory, a minimum of two iterations, and one degree of parallelism.
Why? Because this specific setup guarantees memory hard resistance. It means any attacker trying to crack these hashes offline using massive, highly parallelized GPU clusters is going to hit a catastrophic memory bottleneck.
It stops them in their tracks. You've got to mitigate its silent 72-byte input truncation. Imagine a user pastes a beautifully secure 100-byte passphrase, and Bcrypt just silently lops off everything after byte 72.
Terrifying, isn't it? Some folks try to fix this by pre-hashing the password with SHAR256, but beware, original BCrypt expects a null-terminated string, so if your raw prehash happens to contain a null byte, the hash truncates early, absolutely destroying your security.
If you really must pre-hash, encode the output, using something like base64, so you don't fall into this fatal trap. Section 2. Stateful sessions versus stateless JWTs.
Remembering the user. Whenever you're storing state, you are making a massive architectural trade-off. With stateful server sessions, your server holds a lookup identifier and a secret verifier.
That grants you the incredible power of instant revocation and super straightforward privilege change rotation. Now contrast this with stateless JSON web tokens. With JWTs, you're packing all the user claims into a cryptographically signed payload that is stored entirely on the client.
Sure, it scales beautifully, but it totally inverts your security model. You are trading central state for distributed cryptographic trust, which, as we all know, creates massive revocation headaches down the line. If you do go down the stateful sessions route, this exact underscore underscore host prefixed cookie configuration is non-negotiable.
Literally, don't skip this. Slapping that underscore underscore host prefix on there instructs the browser to flat out reject the cookie if it doesn't meet strict criteria. It forces the secure attribute, so it's HTTPS only, mandates a path of forward slash, and entirely forbids the domain attribute.
This absolutely kills subdomain forgery and HTTPS downgrade attacks. Then you add HTTP only to block JavaScript exfiltration via XSS, and same site equals strict to mathematically neuter cross-site request forgery. Honestly, this is the gold standard.
But say we move to stateless JWTs. We immediately hit a massive architectural question. Where on earth do you securely store it on the client? The obvious answer for a lot of devs is the HTML5 web storage API, specifically local storage.
But that exposes you to the lethal danger of XSS token theft. You see, local storage is accessible to literally any JavaScript executing in that origin. A single malicious script can siphon every single JWT right out of local storage.
To actually secure a JWT on the client, you often end up wrapping it in an HTTP only cookie anyway, or building a back-end for front-end pattern, which, ironically enough, just brings us right back towards a stateful architecture. Section 3.
Preventing JWT attack vectors. Securing the payload. Because you're distributing trust with JWTs, you have to aggressively harden your parsers against some pretty catastrophic flaws.
First up, the notorious alg none attack, where your parser blindly accepts an unsigned token simply because the header claims no algorithm was used. The fix, explicit algorithm whitelisting. Next is RSA to HMAC key confusion.
This is where an attacker cheekily changes the header to HS256, forcing your server to verify an HMAC signature using its own public RSA key. You block this by explicitly typing your keys. And finally, you've got to mitigate server-side request forgery and unauthorized access through rigorous, strict validation of your audience, issuer, and key IDs.
Furthermore, since we know stateless tokens are notoriously a nightmare to revoke, we really can't rely on flawed custom deny lists. Instead, we have to look at highly scalable solutions like token status lists. Here's how it works.
When the server passes the token, it instantly checks a highly compressed, aggregated token status list to kill compromise sessions on the spot. It gives you that absolutely crucial kill switch, while still letting you keep most of the performance benefits of going state bush.
Section 4. Securing OAuth and OIDC, federated and delegated access. When we scale out to the modern OAuth 2.0 authorization code flow, the absolute critical addition is PKCE, proof key for code exchange.
The client kicks off the flow with a cryptographic hash of a secret, known as the Code Challenge. Then later, when it's time to exchange the code for tokens, the client hands over the original secret verifier.
This mathematically proves that the client requesting the token is exactly the same one that initiated the flow, which completely neutralizes interception attacks. It's brilliant. Now, you must never confuse these two concepts.
OpenID Connect gives us the ID token. Think of this as your proof of authentication. Its one and only job is to tell the client application exactly who the user is. On the flip side, OAuth gives us the access token.
This is a key used strictly to grant scoped authorization to your back-end APIs. So, to be crystal clear, you do not use an access token to log a user in, and you absolutely never send an ID token to an API as a bearer token. And this distinction is exactly why the legacy implicit flow was heavily deprecated in RFC 9700.
In the implicit flow, access tokens were dangerously hurled back to the browser in URL fragments. That meant they leaked absolutely everywhere, into browser history, into server logs, you name it.
It completely lacked the cryptographic binding of PKCE, and when you combined dynamic registration flaws with open redirect, attackers could easily siphon off tokens. Today we don't mess around. We strictly enforce the authorization code flow with sender constrained tokens.
Section 5. The WebAuth PassKey Paradigm. The passwordless cryptographic future. The absolute brilliance of this is that the private key physically never leaves the secure enclave of the device.
The server only ever receives the public key and a signature over a challenge. It's incredibly secure. And this right here delivers the final death blow to phishing. The hardware authenticator inherently and automatically binds the challenge signature to the exact TLS origin, the relying party ID of your application.
So if a user gets tricked into visiting a malicious proxy site, the authenticator signs the challenge for the attacker's domain, not yours. Your server will take one look at that signature and reject it. Credential phishing literally becomes mathematically impossible.
So as we wrap up this explainer, I want you to take a hard look at your own architecture. The roadmap is crystal clear, from mathematically hardened storage to precise session state, through hardened OAuth flows, and finally landing on phishing resistant passwordless standards.
The tools are all there. But every single day you rely on legacy paradigms, your architecture's essentially a ticking time bomb. So the question is: how quickly are you going to build the future of your identity stack?