本文介绍了如何保护ASP.NET或ASP.NET MVC免受相关的域cookie攻击?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!






RFC Snip






此外,请注意,有些反直觉,频道绑定Cookie许多相关的域攻击,即使客户端证书他们绑定具有比Web源更广泛的范围。



想象一下,用户代理创建一个单独的自签名证书,用作所有连接到所有服务器的TLS客户端证书在隐私方面的好主意,但跟随我一起为这个思想实验)。然后,服务器会在其各自的顶级域中设置Cookie,但将其绑定到用户代理的一次性唯一客户端证书。



应用app.heroku.com在我的浏览器上为域.heroku.com设置(渠道绑定)cookie,并且attacker.heroku.com上存在攻击者。我们可能关注的一个攻击是,攻击者通过诱骗我攻击attacker.heroku.com从我的浏览器收获.heroku.com cookie。但是,他们无法实际使用该cookie,因为该cookie与我的浏览器的客户端证书通道绑定,而不是攻击者的客户端证书。



我们可能关心的另一个攻击是,在我的用户代理上,attacker.heroku.com 设置了一个.heroku.com Cookie,以便让我作为自己登录到app.heroku.com。同样,假设攻击者可以获取cookie的唯一方法是从app.heroku.com获取cookie,这意味着他拥有的cookies将被绑定到他的客户端证书,而不是我的客户端证书 - 因此当我的浏览器将它们发送到app.heroku.com时,它们将无效。



TLS-OBC提议,为客户端证书假设更细粒度的范围。然而,这样做的原因纯粹是为了防止跨不相关域的跟踪。即使我们使用粗粒度客户端证书和粗粒度(即域)Cookie,相关域攻击也已减轻。我,至少,发现这有点反直觉,起初,因为其他建议防御它禁止粗粒度的cookie和使用起源cookie。






TLS-OBC需要考虑许多问题;


  1. 某些SSL握手逻辑可能需要稍加修改;请参阅


  2. 与SPDY存在棘手的互动。



The related domain cookie attack (more info) allows machines in the same DNS domain to add additional cookies that will also be sent to other computers in the same domain.

This can cause issues with authentication, or at worst be a component in a confused deputy attack.

Question

How can I protect ASP.NET or ASP.NET MVC from this type of attack?

One possible attack scenario

  1. I log into a "secure" web app
  2. I get the credentials for my account
  3. I trick the user into visiting my site on the same DNS domain
  4. I insert the cookie (of my creds)
  5. the user goes back to your app.
  6. Both cookies (or an overwritten one) is sent to the server
  7. User is doing things under my account

That is a simplified example, but the idea can be ported other style of attacks, Im just picking the scenario that doesn't seem "too bad".

One idea how it can "get bad" is if this was step 1 of a two-step attack. Suppose the user uploaded a bad file that was accessible only in his account; the other user then unwittingly downloads that file, running any executable code that is there.

There are a ton of other scenarios that are possible... rather than list them all here I'm trying to figure out how I can protect my server from this type of attack.

解决方案

Channel Bound Cookies

The following Proposed RFC comes from a Google employee and describes a way for Clients use a self-signed Browser Certificate (thus requiring no confusing "pop-up" for the end user) which can also address the cookie security issue known as "Related Domain Cookies"

What follows below is an extract of http://www.browserauth.net/ , a section of the RFC, some interesting commentary, and some criticism on this extension.

Overview of Channel Bound Cookies

Once the underlying TLS channel uses TLS client authentication (with the TLS-OBC extension), the server can bind its cookies to the TLS channel by associating them with the client's public key, and ensuring that the cookies are only ever used over TLS channels authenticated with that public (client) key.

This means that if such a channel-bound cookie is ever stolen off a client's machine, that cookie won't be able to authenticate an HTTP session to the server from other machines. This includes man-in-the-middle attackers that inject themselves into the connection between client and server, perhaps by tricking users into clicking through certificate-mismatch warnings: such a man-in-the-middle will have to generate its own TLS session with the server, which won't match the channel that the cookie is bound it.

Channel Binding

It's up to the server to decide whether to bind cookies to TLS channels. If the client doesn't support TLS-OBC, or if the cookie it's about to set will be used across different origins, then the server will not channel-bind the cookie. If it does decide to channel-bind the cookie, it should associate the cookie with the client's public key. This is similar to RFC 5929, but instead of the client binding data to the server's public key, in this case the server would be binding data (the cookie) to the client's public key. The server can do this either by simply storing, in a backend database, the fact that a certain HTTP session is expected to be authenticated with a certain client public key, or it can use suitable cryptography to encode in the cookie itself which TLS client public key that cookie is bound to.

In the figure above, the server includes the client's public key into a cryptographically signed datastructure that also includes the authenticated user's id. When the server receives the cookie back from the client, it can verify that it indeed issued the cookie (by checking the signature on the cookie), and verify that the cookie was sent over the correct channel (by matching the TLS client key with the key mentioned in the cookie).

To be continued here.... http://www.browserauth.net/channel-bound-cookies


RFC Snip


Also, note that somewhat counter-intuitively, channel-bound cookies protect against many related-domain attacks even if the client cert that they are bound to has broader scope than a web origin.

Imagine, for a moment, that a user-agent creates a single self-signed certificate that it uses as a TLS client cert for all connections to all servers (not a good idea in terms of privacy, but follow me along for this thought experiment). The servers then set cookies on their respective top-level domains, but channel-bind them to the user-agent's one-and-only client cert.

So, let's say that an app app.heroku.com sets a (channel-bound) cookie on my browser for domain .heroku.com, and that there is an attacker on attacker.heroku.com. One attack we might be concerned about is that the attacker simply harvests the .heroku.com cookie from my browser by luring me to attacker.heroku.com. They won't be able to actually use the cookie, however, because the cookie is channel-bound to my browser's client cert, not to the attacker's client cert.

Another attack we might be concerned about is that attacker.heroku.com sets an .heroku.com cookie on my user agent in order to make me log into app.heroku.com as himself. Again, assuming that the only way the attacker can obtain the cookies is by getting them from app.heroku.com, this means that the cookies he has at his disposal will be channel-bound to his client cert, not to my client cert - thus when my browser sends them to app.heroku.com they won't be valid.

The TLS-OBC proposal, of course, assumes more fine-grained "scopes" for the client certificates. The reason for that, however, is purely to prevent tracking across unrelated domains. Related-domain attacks are already mitigated even if we used coarse-grained client certificates and coarse-grained (i.e., domain) cookies. I, at least, found this a little counter-intuitive at first, since the other proposed defense it to forbid coarse-grained cookies altogether and use origin cookies instead.


There are a number of issues that need to be considered for TLS-OBC; I'll highlight a couple here that I'm aware of.

  1. Some SSL handshake logic may need to be modified slightly; see https://bugzilla.mozilla.org/show_bug.cgi?id=681839 for technical discussion.

  2. There are potential privacy considerations; in particular if the unique client certificate is sent in cleartext before the negotiation of the master secret, a passive network observer may be able to uniquely identify a client machine. The attacker would already have the client's IP address, so this isn't a huge problem if the certificate is regenerated on an IP address change, but that would nullify much of the authentication benefit. A proposal to allow a client certificate to be sent after the master secret negotiation has been made. (can't find the bug right now, sorry)

  3. One proposal how #2 could be addressed is here: http://tools.ietf.org/html/draft-agl-tls-encryptedclientcerts

  4. There are tricky interactions with SPDY. There will be updates on browserauth.net for this.

这篇关于如何保护ASP.NET或ASP.NET MVC免受相关的域cookie攻击?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-06 15:48