没有客户端密码的 OAuth2 – 可能是网络钓鱼? [英] OAuth2 without Client Secret – Possible Phishing?

查看:67
本文介绍了没有客户端密码的 OAuth2 – 可能是网络钓鱼?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一遍又一遍地阅读 OAuth2 规范,但我无法弄清楚一件事.没有客户端密钥的授权代码流(现在推荐用于单页应用程序)是不是非常不安全,因为它很容易被用于网络钓鱼?让我解释一下:

I've been reading the OAuth2 specs over and over, but I can't figure out one thing. Isn't the Authorization Code flow without Client Secret (which is now recommended for single page apps) highly insecure because it can easily be used for phishing? Let me explain:

  1. 客户端将资源所有者重定向到授权服务器,传递重定向 URL 和客户端 ID.
  2. 资源所有者批准请求,授权服务器将他重定向到给定的重定向 URL 并传递授权代码.

现在,实际上,请求授权的客户端是一个网络钓鱼站点,不幸的是,用户无法识别该站点.传递给授权服务器的重定向 URL 指向恶意客户端,而不是合法客户端.客户 ID 是公开信息,因此设置此类站点相当容易.

Now, in reality, the Client that requested the authorization is a phishing site which the user, unfortunately, didn't recognize. The Redirect URL passed to the Authorization Server points to the malicious Client, not to the legitimate one. The Client ID is a public information, so setting up such site is fairly easy.

如果需要客户端密钥会怎样?

What will happen if the Client Secret is required?

  1. 恶意客户端会收到授权码,但它不知道合法的客户端密钥.
  2. 资源服务器将拒绝发送访问令牌,因为未提供有效的客户端密钥.用户信息是安全的.

但是如果资源服务器不需要客户端密钥怎么办?

But what if the Resource Server doesn't require the Client Secret?

  1. 恶意客户端将收到授权码,即使它不知道客户端密钥,也会请求访问令牌.
  2. 资源服务器将接受请求,因为提供了有效的授权代码和客户端 ID,并且不需要客户端密钥.恶意客户端获取Access Token,用户信息被泄露.

我是否遗漏了什么或者这是正确的,并且没有什么可以做来使将 OAuth2 与单页应用程序一起使用更安全?

Am I missing something or is this correct and there's nothing that can be done to make using OAuth2 with single page apps more secure?

推荐答案

资源服务器不需要 client_secret 因为只有有效的客户端才能获得兑换授权码.

The resource server doesn't require a client_secret as only valid clients can obtain an redeem an authorization code.

客户端不仅必须针对 client_id 进行验证,还必须针对注册到客户端的 redirect_uri 进行验证.注册 OAuth 客户端时,您应该需要一个允许与 client_id 一起使用的允许的 redirect_uri 列表.

A client must be validated against not only the client_id but also the redirect_uri that is registered to the client. When registering an OAuth Client you should require a list of permitted redirect_uri's that are permitted for use with the client_id.

因此,如果恶意客户端发出请求,则验证将失败,因为您必须仅在允许 redirect_uri 时重定向.

So if a malicious client made a request it would fail validation as you must only redirect if the redirect_uri is permitted.

这在 OAuth 2.0 RFC 3.1.2.2 节下有详细说明https://tools.ietf.org/html/rfc6749#section-3.1.2.2

This is detailed in the OAuth 2.0 RFC under section 3.1.2.2 https://tools.ietf.org/html/rfc6749#section-3.1.2.2

这篇关于没有客户端密码的 OAuth2 – 可能是网络钓鱼?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆