SlideShare a Scribd company logo
1 of 28
Download to read offline
JSON Web Tokens
Luc Engelen
Myself
2006 ‑ 2014: Researcher at TU/e
2014 ‑ 2016: iOS and Java developer at ISAAC
2016 ‑ present: (Mostly) Java developer at Kabisa
Kabisa
Web apps ‑ Hybrid mobile apps
Ruby on Rails ‑ Java ‑ Elixir
Backbone ‑ Marionette ‑ React
Agile ‑ TDD ‑ BDD
Weert ‑ Amsterdam
What's the problem?
nginx
Your device
Postgres
Spring
Spring
Spring
Client
Client
Server
Server
username and password
start session
sessionToken
request with sessionToken
response
request with sessionToken
response
request with sessionToken
error
eyJhbGciOiJIUzUxMiJ9.eyJleHAiOjE0NzYyOTAxNDksInN1YiI6IjEi
fQ.mvJEWu3kxm0WSUKu‑qEVTBmuelM‑2Te‑
VJHEFclVt_uR89ya0hNawkrgftQbAd‑
28lycLX2jXCgOGrA3XRg9Jg
{
"
a
l
g
"
: "
H
S
5
1
2
"
}
{
"
s
u
b
"
: "
1
"
,
"
a
d
m
i
n
"
: f
a
l
s
e
}
H
M
A
C
S
H
A
2
5
6
(
b
a
s
e
6
4
U
r
l
E
n
c
o
d
e
(
h
e
a
d
e
r
) + "
.
" +
b
a
s
e
6
4
U
r
l
E
n
c
o
d
e
(
p
a
y
l
o
a
d
)
,
s
e
c
r
e
t
)
Client
Client
Server
Server
username and password
construct JWT
JWT
request with JWT
check JWT
response
request with JWT
check JWT
response
Where to leave these tokens?
In a cookie?
In a header?
Intermezzo: XSS and CSRF
XSS
Someone is able to have their scripts executed as part of your web
application.
<
% S
t
r
i
n
g e
i
d = r
e
q
u
e
s
t
.
g
e
t
P
a
r
a
m
e
t
e
r
(
"
e
i
d
"
)
; %
>
.
.
.
E
m
p
l
o
y
e
e I
D
: <
%
= e
i
d %
>
Intermezzo: XSS and CSRF
CSRF
Someone else's web application secretly lets its visitors perform
actions with your web application due to cookies still present from
previous visits.
<
f
o
r
m a
c
t
i
o
n
=
"
h
t
t
p
:
/
/
b
a
n
k
.
c
o
m
/
t
r
a
n
s
f
e
r
.
d
o
" m
e
t
h
o
d
=
"
P
O
S
T
"
>
<
i
n
p
u
t t
y
p
e
=
"
h
i
d
d
e
n
" n
a
m
e
=
"
a
c
c
t
" v
a
l
u
e
=
"
M
A
R
I
A
"
/
>
<
i
n
p
u
t t
y
p
e
=
"
h
i
d
d
e
n
" n
a
m
e
=
"
a
m
o
u
n
t
" v
a
l
u
e
=
"
1
0
0
0
0
0
"
/
>
<
i
n
p
u
t t
y
p
e
=
"
s
u
b
m
i
t
" v
a
l
u
e
=
"
V
i
e
w m
y p
i
c
t
u
r
e
s
"
/
>
<
/
f
o
r
m
>
Intermezzo: XSS and CSRF
p
r
i
n
t "
<
h
t
m
l
>
"
p
r
i
n
t "
L
a
t
e
s
t c
o
m
m
e
n
t
:
"
p
r
i
n
t d
a
t
a
b
a
s
e
.
l
a
t
e
s
t
C
o
m
m
e
n
t
p
r
i
n
t "
<
/
h
t
m
l
>
"
Intermezzo: XSS and CSRF
<
i
m
g s
r
c
=
"
h
t
t
p
:
/
/
l
o
c
a
l
h
o
s
t
:
8
0
8
0
/
g
u
i
/
?
a
c
t
i
o
n
=
a
d
d
-
u
r
l
&
s
=
h
t
t
p
:
/
/
e
v
i
l
.
e
x
a
m
p
l
e
.
c
o
m
/
b
a
c
k
d
o
o
r
.
t
o
r
r
e
n
t
"
>
Where to leave these tokens?
In a cookie?
In a header?
Defence against CSRF is straightforward
and durable
1. Check the origin and referer headers
2. Check for some other header you're setting, such as X‑
Requested‑With
See www.owasp.org
What happens when I change my
password?
{
"
a
l
g
"
: "
H
S
5
1
2
"
}
{
"
s
u
b
"
: "
1
"
,
"
a
d
m
i
n
"
: f
a
l
s
e
}
H
M
A
C
S
H
A
2
5
6
(
b
a
s
e
6
4
U
r
l
E
n
c
o
d
e
(
h
e
a
d
e
r
) + "
.
" +
b
a
s
e
6
4
U
r
l
E
n
c
o
d
e
(
p
a
y
l
o
a
d
)
,
s
e
c
r
e
t
)
When should a JWT expire?
As soon as possible, to prevent misuse for long periods
As late as possible, so that users don't have te re‑authenticate
all the time
When should a JWT expire?
Introduce a short‑lived token used for authentication per request
Introduce a long‑lived token used to generate a new short‑lived
token when needed
The long‑lived token is used in combination with a blacklist of
retracted tokens
Should I accept all "valid" JWTs?
No, because "none" is a valid algorithm
The key you use to check the signature should match the
algorithm
See https://auth0.com/blog/critical‑vulnerabilities‑in‑json‑web‑
token‑libraries/
What happens when I delete my
account?
{
"
a
l
g
"
: "
H
S
5
1
2
"
}
{
"
s
u
b
"
: "
1
"
,
"
a
d
m
i
n
"
: f
a
l
s
e
}
H
M
A
C
S
H
A
2
5
6
(
b
a
s
e
6
4
U
r
l
E
n
c
o
d
e
(
h
e
a
d
e
r
) + "
.
" +
b
a
s
e
6
4
U
r
l
E
n
c
o
d
e
(
p
a
y
l
o
a
d
)
,
s
e
c
r
e
t
)
How do I apply this idea to server‑to‑
server communication?
P
O
S
T /
a
p
i
/
s
e
s
s
i
o
n H
T
T
P
/
1
.
1
H
o
s
t
: 5
4
.
1
9
4
.
1
2
6
.
1
6
1
C
o
n
n
e
c
t
i
o
n
: k
e
e
p
-
a
l
i
v
e
C
o
n
t
e
n
t
-
L
e
n
g
t
h
: 3
1
A
c
c
e
p
t
: *
/
*
O
r
i
g
i
n
: h
t
t
p
:
/
/
5
4
.
1
9
4
.
1
2
6
.
1
6
1
X
-
R
e
q
u
e
s
t
e
d
-
W
i
t
h
: X
M
L
H
t
t
p
R
e
q
u
e
s
t
U
s
e
r
-
A
g
e
n
t
: M
o
z
i
l
l
a
/
5
.
0 (
M
a
c
i
n
t
o
s
h
; I
n
t
e
l M
a
c O
S X 1
0
_
1
2
_
0
) A
p
p
C
o
n
t
e
n
t
-
T
y
p
e
: a
p
p
l
i
c
a
t
i
o
n
/
j
s
o
n
R
e
f
e
r
e
r
: h
t
t
p
:
/
/
5
4
.
1
9
4
.
1
2
6
.
1
6
1
/
l
o
g
i
n
A
c
c
e
p
t
-
E
n
c
o
d
i
n
g
: g
z
i
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c
4
4
2
9
8
f
c
1
c
1
4
9
a
f
b
f
4
c
8
9
9
6
f
b
9
2
4
2
7
a
e
4
1
e
4
6
4
9
b
9
3
4
c
a
4
9
5
9
9
1
b
7
8
5
2
b
8
5
See for yourself
https://github.com/ljpengelen

More Related Content

Similar to jwt.pdf

You wanna crypto in AEM
You wanna crypto in AEMYou wanna crypto in AEM
You wanna crypto in AEM
Damien Antipa
 
Django Web Application Security
Django Web Application SecurityDjango Web Application Security
Django Web Application Security
levigross
 

Similar to jwt.pdf (20)

State of Akka 2017 - The best is yet to come
State of Akka 2017 - The best is yet to comeState of Akka 2017 - The best is yet to come
State of Akka 2017 - The best is yet to come
 
You wanna crypto in AEM
You wanna crypto in AEMYou wanna crypto in AEM
You wanna crypto in AEM
 
Identity and Access Management - RSA 2017 Security Foundations Seminar
Identity and Access Management - RSA 2017 Security Foundations SeminarIdentity and Access Management - RSA 2017 Security Foundations Seminar
Identity and Access Management - RSA 2017 Security Foundations Seminar
 
Rust Intro @ Roma Rust meetup
Rust Intro @ Roma Rust meetup Rust Intro @ Roma Rust meetup
Rust Intro @ Roma Rust meetup
 
Cqcon2015
Cqcon2015Cqcon2015
Cqcon2015
 
LOGGING FOR FUN, AND PROFIT
LOGGING FOR FUN, AND PROFITLOGGING FOR FUN, AND PROFIT
LOGGING FOR FUN, AND PROFIT
 
Building Secure User Interfaces With JWTs
Building Secure User Interfaces With JWTsBuilding Secure User Interfaces With JWTs
Building Secure User Interfaces With JWTs
 
SREcon Europe 2016 - Full-mesh IPsec network at Hosted Graphite
SREcon Europe 2016 - Full-mesh IPsec network at Hosted GraphiteSREcon Europe 2016 - Full-mesh IPsec network at Hosted Graphite
SREcon Europe 2016 - Full-mesh IPsec network at Hosted Graphite
 
RoadSec 2017 - Trilha AppSec - APIs Authorization
RoadSec 2017 - Trilha AppSec - APIs AuthorizationRoadSec 2017 - Trilha AppSec - APIs Authorization
RoadSec 2017 - Trilha AppSec - APIs Authorization
 
Need for Async: Hot pursuit for scalable applications
Need for Async: Hot pursuit for scalable applicationsNeed for Async: Hot pursuit for scalable applications
Need for Async: Hot pursuit for scalable applications
 
How to develop Alexa Skill Kit based on Serverless Architecture
How to develop Alexa Skill Kit based on Serverless ArchitectureHow to develop Alexa Skill Kit based on Serverless Architecture
How to develop Alexa Skill Kit based on Serverless Architecture
 
"Crypto wallets security. For developers", Julia Potapenko
"Crypto wallets security. For developers", Julia Potapenko"Crypto wallets security. For developers", Julia Potapenko
"Crypto wallets security. For developers", Julia Potapenko
 
Event-driven IO server-side JavaScript environment based on V8 Engine
Event-driven IO server-side JavaScript environment based on V8 EngineEvent-driven IO server-side JavaScript environment based on V8 Engine
Event-driven IO server-side JavaScript environment based on V8 Engine
 
Django Web Application Security
Django Web Application SecurityDjango Web Application Security
Django Web Application Security
 
An introduction to node3
An introduction to node3An introduction to node3
An introduction to node3
 
JWT: jku x5u
JWT: jku x5uJWT: jku x5u
JWT: jku x5u
 
Node.js: CAMTA Presentation
Node.js: CAMTA PresentationNode.js: CAMTA Presentation
Node.js: CAMTA Presentation
 
Microservices 5 things i wish i'd known java with the best 2018
Microservices 5 things i wish i'd known   java with the best 2018Microservices 5 things i wish i'd known   java with the best 2018
Microservices 5 things i wish i'd known java with the best 2018
 
Microservices 5 Things I Wish I'd Known - JFall 2017
Microservices 5 Things I Wish I'd Known - JFall 2017Microservices 5 Things I Wish I'd Known - JFall 2017
Microservices 5 Things I Wish I'd Known - JFall 2017
 
[CLASS 2014] Palestra Técnica - Jonathan Knudsen
[CLASS 2014] Palestra Técnica - Jonathan Knudsen[CLASS 2014] Palestra Técnica - Jonathan Knudsen
[CLASS 2014] Palestra Técnica - Jonathan Knudsen
 

Recently uploaded

SURVEY I created for uni project research
SURVEY I created for uni project researchSURVEY I created for uni project research
SURVEY I created for uni project research
CaitlinCummins3
 
Personalisation of Education by AI and Big Data - Lourdes Guàrdia
Personalisation of Education by AI and Big Data - Lourdes GuàrdiaPersonalisation of Education by AI and Big Data - Lourdes Guàrdia
Personalisation of Education by AI and Big Data - Lourdes Guàrdia
EADTU
 
QUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lesson
QUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lessonQUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lesson
QUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lesson
httgc7rh9c
 
Contoh Aksi Nyata Refleksi Diri ( NUR ).pdf
Contoh Aksi Nyata Refleksi Diri ( NUR ).pdfContoh Aksi Nyata Refleksi Diri ( NUR ).pdf
Contoh Aksi Nyata Refleksi Diri ( NUR ).pdf
cupulin
 
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
EADTU
 
Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPSSpellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
AnaAcapella
 

Recently uploaded (20)

SURVEY I created for uni project research
SURVEY I created for uni project researchSURVEY I created for uni project research
SURVEY I created for uni project research
 
Personalisation of Education by AI and Big Data - Lourdes Guàrdia
Personalisation of Education by AI and Big Data - Lourdes GuàrdiaPersonalisation of Education by AI and Big Data - Lourdes Guàrdia
Personalisation of Education by AI and Big Data - Lourdes Guàrdia
 
QUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lesson
QUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lessonQUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lesson
QUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lesson
 
How to Manage Website in Odoo 17 Studio App.pptx
How to Manage Website in Odoo 17 Studio App.pptxHow to Manage Website in Odoo 17 Studio App.pptx
How to Manage Website in Odoo 17 Studio App.pptx
 
UChicago CMSC 23320 - The Best Commit Messages of 2024
UChicago CMSC 23320 - The Best Commit Messages of 2024UChicago CMSC 23320 - The Best Commit Messages of 2024
UChicago CMSC 23320 - The Best Commit Messages of 2024
 
e-Sealing at EADTU by Kamakshi Rajagopal
e-Sealing at EADTU by Kamakshi Rajagopale-Sealing at EADTU by Kamakshi Rajagopal
e-Sealing at EADTU by Kamakshi Rajagopal
 
Model Attribute _rec_name in the Odoo 17
Model Attribute _rec_name in the Odoo 17Model Attribute _rec_name in the Odoo 17
Model Attribute _rec_name in the Odoo 17
 
Contoh Aksi Nyata Refleksi Diri ( NUR ).pdf
Contoh Aksi Nyata Refleksi Diri ( NUR ).pdfContoh Aksi Nyata Refleksi Diri ( NUR ).pdf
Contoh Aksi Nyata Refleksi Diri ( NUR ).pdf
 
Pharmaceutical Biotechnology VI semester.pdf
Pharmaceutical Biotechnology VI semester.pdfPharmaceutical Biotechnology VI semester.pdf
Pharmaceutical Biotechnology VI semester.pdf
 
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdfFICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
 
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
 
diagnosting testing bsc 2nd sem.pptx....
diagnosting testing bsc 2nd sem.pptx....diagnosting testing bsc 2nd sem.pptx....
diagnosting testing bsc 2nd sem.pptx....
 
8 Tips for Effective Working Capital Management
8 Tips for Effective Working Capital Management8 Tips for Effective Working Capital Management
8 Tips for Effective Working Capital Management
 
Andreas Schleicher presents at the launch of What does child empowerment mean...
Andreas Schleicher presents at the launch of What does child empowerment mean...Andreas Schleicher presents at the launch of What does child empowerment mean...
Andreas Schleicher presents at the launch of What does child empowerment mean...
 
OSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & SystemsOSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & Systems
 
Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPSSpellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
 
dusjagr & nano talk on open tools for agriculture research and learning
dusjagr & nano talk on open tools for agriculture research and learningdusjagr & nano talk on open tools for agriculture research and learning
dusjagr & nano talk on open tools for agriculture research and learning
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - English
 
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
 

jwt.pdf