OAuth2 Security

简介: Right now there are many good “discussions” on OAuth2 security happening.

Right now there are many good “discussions” on OAuth2 security happening. Some are constructive, some rather destructive – and some simply hack one or the other website to prove the point.

In my opinion there are a number of reason OAuth2 has a rather bad reputation right now. In this post I want to focus on the problems, in the next post what we can learn and how IdentityServer (hopefully) mitigates them.

The spec is too relaxed
When you read the spec, you’ll see a lot of “out of scope” or “at the discretion of the implementer” phrases and many “SHOULDs” and “MAYs”. Or in other words, while writing the specs there were too many interests clashing, resulting in too many ways to achieve the same thing. This lead to changing the name from “OAuth2 Protocol” to “OAuth2 Framework”. WS* anyone?

Also the lack of a token type specification lead to many homegrown token formats that were missing one or the other important security features (like audience checking, encapsulated tokens…). Writing your own token format/implementation is hard, try to avoid that!

I think we really need something like a “basic” profile that hits the 80/20 use cases with exact instructions and guidance for the implementer.

OAuth2 looks too easy
Well – what I mean here is, in WS* world we all knew shit’s hard. In the mind of many people OAuth2 is just a bunch of redirects and HTTP posts. easy. job done.

All I can say is, we are still trying to solve the same non-trivial (read: hard) problems, just using different technologies. Just because one knows HTTP does not mean he also knows how to implement security protocols.

Even the big guys like Facebook got it wrong several times – and some are still playing a dangerous game (see redirect URI based attacks later in my reference links).

Lots of attack surface
Every aspect of OAuth2 can be controlled via input parameters (like query strings or the post inputs). If I were the security tester – of course the first thing I’d try is fuzzing them and see what happens. And catastrophical things happened.

Input is still evil, even when it comes via some specified protocol. Things like response types and redirect URI should come from the authorization servers configuration database, not from external input.

Security Theater
Security theater is a “technique” to make you feel secure/safe while actually doing nothing (see here).

While the OAuth2 flows for native/mobile apps have all the best intentions – namely the developer does not need to deal with the user’s password (and thus not store it) etc. – it does not help you to distinguish between good and bad apps.

No one can make sure that this windows with the authorization server UI is really the authorization server, even when it looks exactly like a browser window!

So in other words, the moment you installed an application on your device, you already made a trust decision. OAuth2 cannot safe you here.

That said, IMO developers should use the implicit flow because that’s (even with a little awkward user experience) still better than dealing with credentials yourself. Windows 8 is a very good example of a modern approach to the problem. The WebAuthenticationBroker API that is built right into the operating system allows for an easy way to do OAuth2 style authorization (and OpenID connect style authentication).

OAuth2 in not an authentication protocol
OAuth2 is an authorization protocol – that’s a huge difference. Everybody who confused the two terms has learned the hard way. Don’t follow them.

OpenID Connect specifies how authentication works on top of OAuth2 – just eight more specs to read.

But – Google, Facebook and friends do authentication with OAuth2 – what do you mean? Well they all do it either using some custom extension, or like Google, OpenID Connect and call it OAuth2 sign-in.

Bearer Tokens
Bearer tokens means that there is no binding between the access token and the HTTP request. In other words whoever manages to steal a token from you (e.g. on the wire) can use that token to do requests on your behalf.

All OAuth2 security currently relies solely on SSL/HTTPS to protect access token transmission. This would be OK in a perfect world. In the real world developers and/or infrastructure like to bypass SSL.

I can only speak for developers – NEVER EVER disable SSL certificate validation. NEVER EVER.

Unfortunately when you search for “how to handle SSL validation errors” on the internet, it is more likely to find information on how do disable validation (in any popular programming language) than a real answer to the question. Shame on them.

An alternative to bearer tokens would be MAC tokens. Yes they are a little harder to program against – but not much. We need this alternative – but there is currently no spec.

References
Here’s some further reading material. Many of the above points were inspired by the following articles. I totally recommended reading every single one:

Oh – and last but not least – please read Tim Bray’s post on OAuth2 which I think is a really good and balanced view on the topic.

目录
相关文章
|
18天前
|
安全 Java Spring
Spring Security+jwt实现认证
Spring Security+jwt实现认证
|
3月前
|
安全 NoSQL Java
Spring Security OAuth 令牌生成
【1月更文挑战第17天】之前写了两篇分析 Spring Security OAuth 认证流程的文章,这篇主要来分析一下,`tokenServices.createAccessToken` 方法,具体是怎么生成 Token。
34 2
|
8月前
|
安全 Java 数据库
Spring Security并结合JWT实现用户认证(Authentication) 和用户授权(Authorization)
在Web应用开发中,安全一直是非常重要的一个方面。Spring Security基于Spring 框架,提供了一套Web应用安全性的完整解决方案。
383 0
|
10月前
|
安全 JavaScript 前端开发
详解OAuth2.0
1.概述 OAUTH,Open Authorization,开放授权协议,为用户资源的授权提供了一个安全的、开放而又简易的标准。目的是让第三方对用户的数据只有有限访问权,而无法触及到用户的核心信息。 例如,在第三方网站上使用微信或者QQ作为账号进行登录,就是使用的oauth协议,只返回给第三方诸如用户名、头像等信息,而不会返回给第三方秘密等核心数据。 OAuth最初由Twitter的开发人员提出,后来成为了一个互联网标准,并得到了广泛应用。OAuth2.0是OAuth协议的第二个版本,是一种更加安全、可扩展、功能更加完备的授权协议。目前我们说OAuth一般指的就是OAuth 2.0。
1135 1
BXA
|
11月前
|
存储 安全 Java
Spring Security OAuth2实现单点登录
OAuth2是一种用于访问控制和授权的协议,它允许用户授权第三方应用程序访问他们存储在另一个服务提供商上的资源。OAuth2允许用户“允许”在不共享用户名和密码的情况下访问他们的帐户。
BXA
231 0
|
存储 JSON NoSQL
16、Spring Security Oauth2 JWT(二)
用户身份认证:用户去访问系统资源时系统要求验证用户的身份信息,身份合法方可继续访问。常见的用户身份认证表现形式有:用户名密码登录,指纹打卡等方式。
273 0
16、Spring Security Oauth2 JWT(二)
|
存储 人工智能 安全
16、Spring Security Oauth2 JWT(一)
用户身份认证:用户去访问系统资源时系统要求验证用户的身份信息,身份合法方可继续访问。常见的用户身份认证表现形式有:用户名密码登录,指纹打卡等方式。
219 0
16、Spring Security Oauth2 JWT(一)
|
存储 安全 Java
Spring Security Oauth2整合JWT
Spring Security Oauth2整合JWT
Spring Security Oauth2整合JWT
|
安全 Java Spring
Spring Security Oauth2 整合单点登录简易demo
Spring Security Oauth2 整合单点登录简易demo
Spring Security Oauth2 整合单点登录简易demo
|
Java Spring
五分钟带你玩转oauth2(二十)spring security+oauth2通过EnableOAuth2Sso实现单点登录
五分钟带你玩转oauth2(二十)spring security+oauth2通过EnableOAuth2Sso实现单点登录
225 0
五分钟带你玩转oauth2(二十)spring security+oauth2通过EnableOAuth2Sso实现单点登录