recentevolutionsinthe oauth 2.0 and openid … · 2020-06-19 · consulting services on security,...

35
https://Pragmatic Web Security .com DR. PHILIPPE DE R YCK RECENT EVOLUTIONS IN THE OA UTH 2.0 AND OPENID CONNECT LANDSCAPE

Upload: others

Post on 06-Jul-2020

7 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: RECENTEVOLUTIONSINTHE OAUTH 2.0 AND OPENID … · 2020-06-19 · Consulting services on security, Oauth2.0, ... User authentication Read & write data OpenID Connect OAuth 2.0 @PhilippeDeRyck

https://Pragmatic Web Security.com

DR. PHILIPPE DE RYCK

RECENT EVOLUTIONS IN THE OAUTH 2.0 AND OPENID CONNECT LANDSCAPE

Page 2: RECENTEVOLUTIONSINTHE OAUTH 2.0 AND OPENID … · 2020-06-19 · Consulting services on security, Oauth2.0, ... User authentication Read & write data OpenID Connect OAuth 2.0 @PhilippeDeRyck

@PhilippeDeRyck 2

Pragmatic Web Security

High-quality security training for developers and managers

- Deep understanding of the web security landscape

- Google Developer Expert (not employed by Google)

DR. PHILIPPE DE RYCK

Custom courses covering web security, API security, Angular security, …

- Course curator of the SecAppDev course (https://secappdev.org)

@PHILIPPEDERYCKHTTPS://PRAGMATICWEBSECURITY.COM

Consulting services on security, Oauth 2.0, OpenID Connect, …

Page 3: RECENTEVOLUTIONSINTHE OAUTH 2.0 AND OPENID … · 2020-06-19 · Consulting services on security, Oauth2.0, ... User authentication Read & write data OpenID Connect OAuth 2.0 @PhilippeDeRyck

@PhilippeDeRyck 3

User authentication

Read & write data

Page 4: RECENTEVOLUTIONSINTHE OAUTH 2.0 AND OPENID … · 2020-06-19 · Consulting services on security, Oauth2.0, ... User authentication Read & write data OpenID Connect OAuth 2.0 @PhilippeDeRyck

@PhilippeDeRyck 4

User authentication

Read & write data

Page 5: RECENTEVOLUTIONSINTHE OAUTH 2.0 AND OPENID … · 2020-06-19 · Consulting services on security, Oauth2.0, ... User authentication Read & write data OpenID Connect OAuth 2.0 @PhilippeDeRyck

@PhilippeDeRyck 5

User authentication

Read & write data

Page 6: RECENTEVOLUTIONSINTHE OAUTH 2.0 AND OPENID … · 2020-06-19 · Consulting services on security, Oauth2.0, ... User authentication Read & write data OpenID Connect OAuth 2.0 @PhilippeDeRyck

@PhilippeDeRyck 6

User authentication

Read & write data

OpenID Connect

OAuth 2.0

Page 7: RECENTEVOLUTIONSINTHE OAUTH 2.0 AND OPENID … · 2020-06-19 · Consulting services on security, Oauth2.0, ... User authentication Read & write data OpenID Connect OAuth 2.0 @PhilippeDeRyck

@PhilippeDeRyck 7

User authentication

Read & write data

OpenID Connect

OAuth 2.0

Read data

OAuth 2.0

Page 8: RECENTEVOLUTIONSINTHE OAUTH 2.0 AND OPENID … · 2020-06-19 · Consulting services on security, Oauth2.0, ... User authentication Read & write data OpenID Connect OAuth 2.0 @PhilippeDeRyck

@PhilippeDeRyck 8

User authentication

Read & write data

Results in an identity token and access token

Uses an access token

Read data

Uses an access token

Page 9: RECENTEVOLUTIONSINTHE OAUTH 2.0 AND OPENID … · 2020-06-19 · Consulting services on security, Oauth2.0, ... User authentication Read & write data OpenID Connect OAuth 2.0 @PhilippeDeRyck

@PhilippeDeRyck 9

OAUTH 2.0 AND OPENID CONNECT

OpenID Connect provides user authentication

OAuth 2.0 allows a client to access resources on behalf of the user

Modern applications use a combination of both protocols

Page 10: RECENTEVOLUTIONSINTHE OAUTH 2.0 AND OPENID … · 2020-06-19 · Consulting services on security, Oauth2.0, ... User authentication Read & write data OpenID Connect OAuth 2.0 @PhilippeDeRyck

@PhilippeDeRyck

THE OIDC HYBRID FLOW

10

5 Request client authorization

3 Authenticate yourself

4 Login credentials

6 Authorize client

1 Request access

8 Authorization codeand identity token

7Redirect with authorization code and identity token

2Redirect for authentication

11 Access token / refresh token10Authorization codewith client credentials

12 Access resource

13 Protected resource9Authenticate user with identity token

Page 11: RECENTEVOLUTIONSINTHE OAUTH 2.0 AND OPENID … · 2020-06-19 · Consulting services on security, Oauth2.0, ... User authentication Read & write data OpenID Connect OAuth 2.0 @PhilippeDeRyck

@PhilippeDeRyck

THE REFRESH TOKEN FLOW

11

2 Access token & refresh token1Refresh tokenwith client credentials

3 Access resource

4 Protected resource

Page 12: RECENTEVOLUTIONSINTHE OAUTH 2.0 AND OPENID … · 2020-06-19 · Consulting services on security, Oauth2.0, ... User authentication Read & write data OpenID Connect OAuth 2.0 @PhilippeDeRyck

@PhilippeDeRyck

THE OIDC HYBRID FLOW

• Clients are backend applications running in a "secure" environment

• The hybrid flow returns an identity token, access token and refresh token• Identity tokens are issued through the frontchannel, along with an authorization code• The authorization code can be exchanged for an access token and refresh token• Using the authorization code requires client authentication

• Refresh tokens allow the client to obtain a new access token• Using a refresh token requires client authentication

12

Page 13: RECENTEVOLUTIONSINTHE OAUTH 2.0 AND OPENID … · 2020-06-19 · Consulting services on security, Oauth2.0, ... User authentication Read & write data OpenID Connect OAuth 2.0 @PhilippeDeRyck

“ “The hackers were able to steal some of our Facebook

and Twitter access tokens from our users.13

Page 14: RECENTEVOLUTIONSINTHE OAUTH 2.0 AND OPENID … · 2020-06-19 · Consulting services on security, Oauth2.0, ... User authentication Read & write data OpenID Connect OAuth 2.0 @PhilippeDeRyck

@PhilippeDeRyck

THE DANGER OF BEARER TOKENS

14

5 Request client authorization

3 Authenticate yourself

4 Login credentials

6 Authorize client

1 Request access

8 Authorization codeand identity token

7Redirect with authorization code and identity token

2Redirect for authentication

11 Access token / refresh token10Authorization codewith client credentials

12 Access resource

13 Protected resource9Authenticate user with identity token

Access tokens are bearer tokens, allowing immediate

abuse upon theft

Page 15: RECENTEVOLUTIONSINTHE OAUTH 2.0 AND OPENID … · 2020-06-19 · Consulting services on security, Oauth2.0, ... User authentication Read & write data OpenID Connect OAuth 2.0 @PhilippeDeRyck

@PhilippeDeRyck

BINDING TOKENS TO TLS CERTIFICATES

15

5 Request client authorization

3 Authenticate yourself

4 Login credentials

6 Authorize client

1 Request access

8 Authorization codeand identity token

7Redirect with authorization code and identity token

2Redirect for authentication

11 Access token bound to the TLS certificate / refresh token10Authorization code

with mTLS

12 Access resourcewith mTLS

13 Protected resource9Authenticate user with identity token

Page 16: RECENTEVOLUTIONSINTHE OAUTH 2.0 AND OPENID … · 2020-06-19 · Consulting services on security, Oauth2.0, ... User authentication Read & write data OpenID Connect OAuth 2.0 @PhilippeDeRyck

@PhilippeDeRyck 16

{

"sub": "[email protected]","aud": "https://api.example.com","azp": "RandomClientID","iss": "https://authorizationserver.example.com/","exp": 1419356238,"iat": 1419350238,"scope": "read write","jti": "405b4d4e-8501-4e1a-a138-ed8455cd1d47","cnf":{"x5t#S256": "bwcK0esc3ACC3DB2Y5_lESsXE8o9ltc05O89jdN-dg2"

}}

Page 17: RECENTEVOLUTIONSINTHE OAUTH 2.0 AND OPENID … · 2020-06-19 · Consulting services on security, Oauth2.0, ... User authentication Read & write data OpenID Connect OAuth 2.0 @PhilippeDeRyck

@PhilippeDeRyck 17

PROOF-OF-POSSESSION FOR ACCESS TOKENS

Many confidential clients still rely on bearer access tokens

The confidential client can authenticate with a TLS certificate

The TLS certificate can be used to enable token binding

Page 18: RECENTEVOLUTIONSINTHE OAUTH 2.0 AND OPENID … · 2020-06-19 · Consulting services on security, Oauth2.0, ... User authentication Read & write data OpenID Connect OAuth 2.0 @PhilippeDeRyck

@PhilippeDeRyck

THE OIDC HYBRID FLOW

18

5 Request client authorization

3 Authenticate yourself

4 Login credentials

6 Authorize client

1 Request access

8 Authorization codeand identity token

7Redirect with authorization code and identity token

2Redirect for authentication

11 Access token / refresh token10Authorization codewith client credentials

12 Access resource

13 Protected resource9Authenticate user with identity token

Mobile applications cannot handle client credentials in a

secure way

Page 19: RECENTEVOLUTIONSINTHE OAUTH 2.0 AND OPENID … · 2020-06-19 · Consulting services on security, Oauth2.0, ... User authentication Read & write data OpenID Connect OAuth 2.0 @PhilippeDeRyck

@PhilippeDeRyck

THE OIDC HYBRID FLOW

19

5 Request client authorization

3 Authenticate yourself

4 Login credentials

6 Authorize client

1 Request access

8 Authorization codeand identity token

7Redirect with authorization code and identity token

2Redirect for authentication

11 Access token / refresh token10Authorization codewithout client credentials

12 Access resource

13 Protected resource9Authenticate user with identity token

Malicious applications can intercept the authorization

code and exchange it

Page 20: RECENTEVOLUTIONSINTHE OAUTH 2.0 AND OPENID … · 2020-06-19 · Consulting services on security, Oauth2.0, ... User authentication Read & write data OpenID Connect OAuth 2.0 @PhilippeDeRyck

@PhilippeDeRyck

THE OIDC HYBRID FLOW WITH PKCE

20

7 Request client authorization

5 Authenticate yourself

6 Login credentials

8 Authorize client

2 Request access

10 Authorization codeand identity token

9Redirect with authorization code and identity token

3Redirect for authentication

14 Access token / refresh token12Authorization codewith code verifier

15 Access resource

16 Protected resource

1 Generate code verifier

4 Store code challenge

13 Match code challenge to verifier

11Authenticate user with identity token

Page 21: RECENTEVOLUTIONSINTHE OAUTH 2.0 AND OPENID … · 2020-06-19 · Consulting services on security, Oauth2.0, ... User authentication Read & write data OpenID Connect OAuth 2.0 @PhilippeDeRyck

@PhilippeDeRyck

THE OIDC HYBRID FLOW WITH PKCE

• Mobile applications are public clients• The lack of client authentication exposes the authorization code to attacks

• The Proof-Key-for-Code-Exchange addition keeps the authorization code secure• PKCE essentially acts as a one-time password for each individual client• Prevents the abuse of a stolen authorization code

• Mobile applications can use refresh tokens if they store them securely• Refresh tokens do not require authentication, so are bearer tokens• Only good place to store is in the OS's secure application storage

21

Page 22: RECENTEVOLUTIONSINTHE OAUTH 2.0 AND OPENID … · 2020-06-19 · Consulting services on security, Oauth2.0, ... User authentication Read & write data OpenID Connect OAuth 2.0 @PhilippeDeRyck

@PhilippeDeRyck

THE DANGER OF BEARER TOKENS

22

7 Request client authorization

5 Authenticate yourself

6 Login credentials

8 Authorize client

2 Request access

10 Authorization codeand identity token

9Redirect with authorization code and identity token

3Redirect for authentication

14 Access token / refresh token12Authorization codewith code verifier

15 Access resource

16 Protected resource

1 Generate code verifier

4 Store code challenge

13 Match code challenge to verifier

11Authenticate user with identity token

Access and refresh tokens are bearer tokens, allowing

immediate abuse upon theft

Page 23: RECENTEVOLUTIONSINTHE OAUTH 2.0 AND OPENID … · 2020-06-19 · Consulting services on security, Oauth2.0, ... User authentication Read & write data OpenID Connect OAuth 2.0 @PhilippeDeRyck

@PhilippeDeRyck

BINDING TOKENS TO TLS CERTIFICATES ON PUBLIC CLIENTS

23

7 Request client authorization

5 Authenticate yourself

6 Login credentials

8 Authorize client

2 Request access

10 Authorization codeand identity token

9Redirect with authorization code and identity token

3Redirect for authentication

14 mTLS-bound access token & refresh token12Authorization codewith code verifier & mTLS

15 Access resourcewith mTLS

16 Protected resource

4 Store code challenge

13 Match code challenge to verifier

11Authenticate user with identity token

1 Generate code verifier

Page 24: RECENTEVOLUTIONSINTHE OAUTH 2.0 AND OPENID … · 2020-06-19 · Consulting services on security, Oauth2.0, ... User authentication Read & write data OpenID Connect OAuth 2.0 @PhilippeDeRyck

@PhilippeDeRyck 24

PROOF-OF-POSSESSION IN MOBILE CLIENTS

Each client instance generates its own certificate

The client uses the self-signed certificate during TLS connections

The authorization server ties the tokens to the client certificate

Page 25: RECENTEVOLUTIONSINTHE OAUTH 2.0 AND OPENID … · 2020-06-19 · Consulting services on security, Oauth2.0, ... User authentication Read & write data OpenID Connect OAuth 2.0 @PhilippeDeRyck

@PhilippeDeRyck

THE OIDC IMPLICIT FLOW

25

5 Request client authorization

3 Authenticate yourself

4 Login credentials

6 Authorize client

1 Request access

8 access tokenand identity token

7Redirect with access token and identity token

2Redirect for authentication

10 Access resource

11 Protected resource9Authenticate user with identity token

Page 26: RECENTEVOLUTIONSINTHE OAUTH 2.0 AND OPENID … · 2020-06-19 · Consulting services on security, Oauth2.0, ... User authentication Read & write data OpenID Connect OAuth 2.0 @PhilippeDeRyck

@PhilippeDeRyck

THE OIDC IMPLICIT FLOW

26

5 Request client authorization

3 Authenticate yourself

4 Login credentials

6 Authorize client

1 Request access

8 access tokenand identity token

7Redirect with access token and identity token

2Redirect for authentication

10 Access resource

11 Protected resource9Authenticate user with identity token

Access token in URL and browser history

Page 27: RECENTEVOLUTIONSINTHE OAUTH 2.0 AND OPENID … · 2020-06-19 · Consulting services on security, Oauth2.0, ... User authentication Read & write data OpenID Connect OAuth 2.0 @PhilippeDeRyck

@PhilippeDeRyck

THE OIDC HYBRID FLOW WITH PKCE

27

7 Request client authorization

5 Authenticate yourself

6 Login credentials

8 Authorize client

2 Request access

10 Authorization codeand identity token

9Redirect with authorization code and identity token

3Redirect for authentication

13 Access token12Authorization codewith code verifier

15 Access resource

16 Protected resource11Authenticate user with identity token

1 Generate code verifier

4 Store code challenge

14 Match code challenge to verifier

Page 28: RECENTEVOLUTIONSINTHE OAUTH 2.0 AND OPENID … · 2020-06-19 · Consulting services on security, Oauth2.0, ... User authentication Read & write data OpenID Connect OAuth 2.0 @PhilippeDeRyck

@PhilippeDeRyck

THE OIDC HYBRID FLOW WITH PKCE

28

7 Request client authorization

5 Authenticate yourself

6 Login credentials

8 Authorize client

2 Request access

10 Authorization codeand identity token

9Redirect with authorization code and identity token

3Redirect for authentication

13 Access token12Authorization codewith code verifier

15 Access resource

16 Protected resource11Authenticate user with identity token

1 Generate code verifier

4 Store code challenge

14 Match code challenge to verifier

Web applications cannot store a refresh token in a

secure location

Re-running the flow allows the re-use of the user's

session

Page 29: RECENTEVOLUTIONSINTHE OAUTH 2.0 AND OPENID … · 2020-06-19 · Consulting services on security, Oauth2.0, ... User authentication Read & write data OpenID Connect OAuth 2.0 @PhilippeDeRyck

@PhilippeDeRyck

THE OIDC HYBRID FLOW WITH PKCE

29

7 Request client authorization

5 Authenticate yourself

6 Login credentials

8 Authorize client

2 Request access

10 Authorization codeand identity token

9Redirect with authorization code and identity token

3Redirect for authentication

13 Access token / refresh token12Authorization codewith code verifier

15 Access resource

16 Protected resource11Authenticate user with identity token

1 Generate code verifier

4 Store code challenge

14 Match code challenge to verifier

Refresh token lifetime is linked to the session expiration lifetimes, making it short-lived

Page 30: RECENTEVOLUTIONSINTHE OAUTH 2.0 AND OPENID … · 2020-06-19 · Consulting services on security, Oauth2.0, ... User authentication Read & write data OpenID Connect OAuth 2.0 @PhilippeDeRyck

@PhilippeDeRyck

THE OIDC HYBRID FLOW WITH PKCE

30

7 Request client authorization

5 Authenticate yourself

6 Login credentials

8 Authorize client

2 Request access

10 Authorization codeand identity token

9Redirect with authorization code and identity token

3Redirect for authentication

13 Access token / refresh token12Authorization codewith code verifier

15 Access resource

16 Protected resource11Authenticate user with identity token

1 Generate code verifier

4 Store code challenge

14 Match code challenge to verifier

mTLS in browsers is hard, making low-level proof-of-

possession challenging.

Page 31: RECENTEVOLUTIONSINTHE OAUTH 2.0 AND OPENID … · 2020-06-19 · Consulting services on security, Oauth2.0, ... User authentication Read & write data OpenID Connect OAuth 2.0 @PhilippeDeRyck

@PhilippeDeRyck 31

WEB SECURITY IS HARD

The Hybrid flow with PKCE is recommended (Implicit flow is still OK)

Refresh tokens cannot be used, unless they are short-lived

PoP tokens for web applications require application-level code

Page 32: RECENTEVOLUTIONSINTHE OAUTH 2.0 AND OPENID … · 2020-06-19 · Consulting services on security, Oauth2.0, ... User authentication Read & write data OpenID Connect OAuth 2.0 @PhilippeDeRyck

@PhilippeDeRyck

REFERENCES

Proof Key for Code Exchange by OAuth Public Clientshttps://tools.ietf.org/html/rfc7636

OAuth 2.0 Security Best Current Practicehttps://tools.ietf.org/html/draft-ietf-oauth-security-topics-13

OAuth 2.0 Mutual-TLS Client Authentication and Certificate-Bound Access Tokenshttps://tools.ietf.org/html/draft-ietf-oauth-mtls-17

OAuth 2.0 Demonstration of Proof-of-Possession at the Application Layerhttps://tools.ietf.org/html/draft-fett-oauth-dpop-00

32

Page 33: RECENTEVOLUTIONSINTHE OAUTH 2.0 AND OPENID … · 2020-06-19 · Consulting services on security, Oauth2.0, ... User authentication Read & write data OpenID Connect OAuth 2.0 @PhilippeDeRyck

@PhilippeDeRyck 33https://cheatsheets.pragmaticwebsecurity.com/

FREE SECURITY CHEAT SHEETS FOR MODERN APPLICATIONS

Page 34: RECENTEVOLUTIONSINTHE OAUTH 2.0 AND OPENID … · 2020-06-19 · Consulting services on security, Oauth2.0, ... User authentication Read & write data OpenID Connect OAuth 2.0 @PhilippeDeRyck

@PhilippeDeRyck 34

March 9th – 13th, 2020Leuven, Belgium

A yearly initiative from the SecAppDev.org non-profit, since 2005

A week-long course on Secure Application Development

Taught by experts from around the world

38 in-depth lectures and 3 one-day workshops

https://secappdev.org

Page 35: RECENTEVOLUTIONSINTHE OAUTH 2.0 AND OPENID … · 2020-06-19 · Consulting services on security, Oauth2.0, ... User authentication Read & write data OpenID Connect OAuth 2.0 @PhilippeDeRyck

@PhilippeDeRyck

THANK YOU!

Follow me on Twitter to stay up to date on web security best practices