JWTs Suck Revised
JWTs Suck Revised
JWTs Suck Revised
@rdegges
@oktadev
Chief Hacker @ Okta
Randall Degges
Python / Node / Go
What are JWTs?
- JSON data
- Cryptographically signed
- Not encrypted
- Not special
What’s a Cryptographic Signature?
That's a signature!
Dear Sir/Madam,
Randall Degges
What Do JWTs Actually Do?
As identity proof
How JWTs are Most Commonly Used
Definition:
Definition:
Definition:
¯\_(ツ)_/¯
- They’re both cryptographically signed
- They both contain a session identifier (12345)
Definition:
{
"Set-Cookie": "session=signed(12345)"
}
Log me in!
body
NOTE: Required Cookie Flags
website
{
"Cookie": "session=signed(12345)"
I see your cookie header
}
and have parsed it! I know
who you are!
Show me a page!
body
Term: Local Storage
Definition:
JWTs:
Session Cookies:
0 1
JWTs are More Flexible
{
“sessionId”: “12345”, sessionId=12345;
“email”: “r@rdegges.com”, email=r@rdegges.com;
“firstName”: “Randall”, firstName=Randall;
“lastName”: “Degges” lastName=Degges
}
JWTs are More Flexible
{
“userId”: “12345”, userId=12345;
“email”: “r@rdegges.com”, email=r@rdegges.com;
“firstName”: “Randall”, firstName=Randall;
“lastName”: “Degges”, lastName=Degges;
“iat”: “123456789”, Expires=xxxx;
“exp”: “987654321”
}
Score
0 2
JWTs are More Secure
0 3
JWTs Prevent CSRF
DETOUR! What is CSRF?
OK! Transfer received!
Sending 1 million dollars to
bank.com bank.com/transfer
jerk@gmail.com!
● You are still susceptible to ● You are safe from CSRF, but
CSRF have opened yourself up to a
much greater attack vector…
XSS
CSRF is trivial to fix. XSS… Not so much.
Bad News
But… I just won’t use third party JS on my site… So I
can still be secure!
“… In other words, any authentication your application
requires can be bypassed by a user with local privileges to
the machine on which the data is stored. Therefore, it's
recommended not to store any sensitive information in
local storage.”
0 4
JWTs Are Better for Cross Domain
Looks legit. I just logged *I also generated a JWT
you in with a cookie. that lasts for 10 seconds.
0 5
JWTs are More Efficient
~3x larger
0 6
JWTs Are Easy to Revoke
Log me in!
H4x3d!!! J00r
t0k3ns r m1n3!
My name is Randall,
I’m an admin, I have a 1
hour token.
time
Randall, you are a n00b! If I want
to invalidate an individual JWT I
can just use a revocation list!!
OK, OK
Has this token
been revoked?
db
website
Yep!
Show me the
page!
Go die.
Score
0 7
JWTs are Easier to “Scale”
- Can be validated locally without any - Can use different types of session
necessary external DB access caches to speed up access server-side
(including local memory)
Bad - Requires less bandwidth for users
website
db
Show me the Yep!
page!
Show me the db
page! This is xxx.
db
Here’s the page
you requested.
Session Scaling (super advanced)
Who is this guy?
website
us-east us-west eu
This is xxx.
db db db
db db db
db db db
Score
0 8
JWTs Are Secure By Design
Randall is a jerk. Revoke
his admin access!
website website
website
Log me in!
Let me delete
everything!
time
Score
0 9
So how should I use
JWTs then, you jerk?
Rules for Using Tokens
file server
website
website
Ok! I clicked
Reset my password. the link.
Ok! I’ve emailed Ok, your PW
you a link that has has been reset.
a JWT in the URL
which will expire in
30 minutes.
So why are JWTs so popular then?
What else even is
there?!
PASETO! https://paseto.io
JWTs PASETO
@rdegges @oktadev
teespring.com/dontusejwts