ASP.NET 中的基本表单身份验证有多安全?

发布于 2024-07-07 05:24:51 字数 383 浏览 5 评论 0原文

想象一下,您有一个只有 2 个页面的简单网站:login.aspx 和 Secret.aspx。 仅使用 ASP.net 表单身份验证和 login.aspx 上的 ASP.net 登录服务器控件来保护您的站点。 详细信息如下:

  • 站点配置为使用 SqlMembershipProvider
  • 站点拒绝所有匿名用户
  • Cookie 被禁用

显然,关于安全性需要考虑很多事情,但我更感兴趣的是 .网框架。

对于这个问题,如果唯一的攻击点是 login.aspx 中的用户名/密码文本框,那么黑客是否可以注入代码来允许他们访问我们的 Secret.aspx 页面?

Microsoft 提供的零代码开箱即用体验有多安全?

Imagine that you have a simple site with only 2 pages: login.aspx and secret.aspx. Your site is secured using nothing but ASP.net forms authentication and an ASP.net Login server control on login.aspx. The details are as follows:

  • The site is configured to use the SqlMembershipProvider
  • The site denies all anonymous users
  • Cookies are disabled

The are obviously many things to consider regarding security but I am more interested in the zero code out of box experience that comes with the .net framework.

If, for the sake of this question, the only attack points are the username/password textboxes in login.aspx, can a hacker inject code that will allow them to gain access to our secret.aspx page?

How secure is the zero code out-of-box experience that Microsoft provides?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(8

能否归途做我良人 2024-07-14 05:24:51

您仍然有一些未考虑到的变量:

  • 会员资格提供商使用的数据存储(在本例中为 Sql Server 数据库)的安全性。
  • 同一 IIS 中托管的其他站点的安全性 托管
  • 该站点所涉及的计算机的一般网络安全性,或托管该站点的同一网络上的计算机
  • 的安全性 托管该站点的计算机的物理安全性
  • 您是否使用适当的措施来加密身份验证流量? (HTTPS/SSL)

并非所有这些问题都是 MS 特有的,但它们值得一提,因为如果不加以处理,其中任何一个问题都可能很容易超过您所询问的问题。 但是,出于您提出问题的目的,我假设它们没有任何问题。

在这种情况下,我很确定表单身份验证会完成它应该做的事情。 我认为目前没有任何活跃的漏洞利用。

You still have some variables that aren't accounted for:

  • Security into the data store used by your membership provider (in this case, the Sql Server database).
  • security of other sites hosted in the same IIS
  • general network security of the machines involved in hosting the site, or on the same network where the site is hosted
  • physical security of the machines hosting the site
  • Are you using appropriate measures to encrypt authentication traffic? (HTTPS/SSL)

Not all of those issues are MS specific, but they're worth mentioning because any of them could easily outweigh the issue you're asking about, if not taken care of. But, for the purpose of your question I'll assume there aren't any problems with them.

In that case, I'm pretty sure the forms authentication does what it's supposed to do. I don't think there's any currently active exploit out there.

酒与心事 2024-07-14 05:24:51

据我所知,密码将以纯文本形式发送(但经过编码)。 因此,最重要的是在登录屏幕上使用 HTTPS 协议。

其他设置对我来说似乎是安全的。

As far as I know password will be sent as plain text (but encoded). So the most important thing to do is to use HTTPS protocol on login screens.

The other setting seems to be secure for me.

指尖凝香 2024-07-14 05:24:51

通过 HTTP 基本身份验证(即 .NET 基本表单身份验证所使用的身份验证),为了查看 Secret.aspx 页面,浏览器必须发送用户名和密码的 Base64 编码串联。

除非您使用 SSL,否则任何有权扫描服务器和浏览器之间网络的人都可以读取此信息。 他们可以解码用户名和密码。 他们可以在将来重播用户名和密码来访问 Secret.aspx 页面。

也就是说,除非您使用 SSL,否则某人还可以使用 Secret.aspx 扫描其他人的整个会话,因此实际上,他们也可以访问该页面的内容。

With HTTP Basic Authentication, which is what the .NET basic forms authentication is using, in order to view the secret.aspx page, the browser must send a Base64 encoded concatenation of the username and password.

Unless you utilize SSL, anyone who has access to scan the network between the server and the browser can read this information. They can decode the username and password. They can replay the username and password in the future to gain access to the secret.aspx page.

That said, unless you use SSL, someone can also scan the whole session of someone else using secret.aspx, so in effect, they would have access to the content of the page as well.

负佳期 2024-07-14 05:24:51

好吧,尝试看看幕后:

密码保护

存储用户名的应用程序,
密码和其他身份验证
数据库中的信息不应该
以明文形式存储密码,以免
数据库被盗或被破坏。 到
为此,SqlMembershipProvider
支持三种存储格式
(“编码”)密码和
密码答案。 提供者的
PasswordFormat 属性,即
从密码格式初始化
配置属性,决定
使用哪种格式:

  • MembershipPasswordFormat.Clear,存储密码和密码
    以明文形式回答。
  • MembershipPasswordFormat.Hashed(默认值),用于存储加盐的
    从密码生成的哈希值和
    密码答案。 盐是随机的
    .NET 生成的 128 位值
    框架的 RNGCryptoServiceProvider
    班级。 每个密码/密码答案
    这双鞋充满了这种独特的价值,
    盐储存在
    aspnet_Membership表的PasswordSalt
    场地。 散列的结果
    密码和盐存储在
    密码字段。 同样,结果
    散列密码答案和
    salt 存储在PasswordAnswer 中
    领域。
  • MembershipPasswordFormat.Encrypted,
    它存储加密的密码和
    密码答案。
    SqlMembershipProvider 加密
    密码和密码答案使用
    对称加密/解密
    中指定的密钥
    配置部分的decryptionKey
    属性和加密
    中指定的算法
    配置部分的
    解密属性。
    SqlMembershipProvider 抛出一个
    如果要求加密则例外
    密码和密码答案,如果
    解密密钥设置为自动生成。
    这会阻止会员数据库
    包含加密的密码和
    密码答案失效
    如果移动到另一台服务器或另一台
    应用程序。

因此,您的安全强度(开箱即用)将取决于您使用的密码保护格式策略:

  • 如果您使用明文,则显然更容易侵入您的系统。
  • 另一方面,使用加密,安全性将取决于对您的计算机(或至少 machine.config)的物理访问。
  • 使用哈希密码(默认)将保证安全性,具体取决于:a) RNGCryptoServiceProvider 类的哈希策略的已知逆转,以及 b) 访问数据库以破坏随机生成的盐。

我不知道是否可以使用某种彩虹表破解默认的哈希基系统。

欲了解更多详细信息,请查看此链接:
http://msdn.microsoft.com/en-us/library/aa478949。 ASPX

Well, try and look behind the scenes:

Password Protection

Applications that store user names,
passwords, and other authentication
information in a database should never
store passwords in plaintext, lest the
database be stolen or compromised. To
that end, SqlMembershipProvider
supports three storage formats
("encodings") for passwords and
password answers. The provider's
PasswordFormat property, which is
initialized from the passwordFormat
configuration attribute, determines
which format is used:

  • MembershipPasswordFormat.Clear, which stores passwords and password
    answers in plaintext.
  • MembershipPasswordFormat.Hashed (the default), which stores salted
    hashes generated from passwords and
    password answers. The salt is a random
    128-bit value generated by the .NET
    Framework's RNGCryptoServiceProvider
    class. Each password/password answer
    pair is salted with this unique value,
    and the salt is stored in the
    aspnet_Membership table's PasswordSalt
    field. The result of hashing the
    password and the salt is stored in the
    Password field. Similarly, the result
    of hashing the password answer and the
    salt is stored in the PasswordAnswer
    field.
  • MembershipPasswordFormat.Encrypted,
    which stores encrypted passwords and
    password answers.
    SqlMembershipProvider encrypts
    passwords and password answers using
    the symmetric encryption/decryption
    key specified in the
    configuration section's decryptionKey
    attribute, and the encryption
    algorithm specified in the
    configuration section's
    decryption attribute.
    SqlMembershipProvider throws an
    exception if it is asked to encrypt
    passwords and password answers, and if
    decryptionKey is set to Autogenerate.
    This prevents a membership database
    containing encrypted passwords and
    password answers from becoming invalid
    if moved to another server or another
    application.

So the strength of your security (out of the box) will depend on which password protection format strategy you are using:

  • If you use clear text, it is obviously easier to hack into your system.
  • Using Encrypted on the other hand, security will depend on physical access to your machine (or at least, machine.config).
  • Using Hashed passwords (the default) will guarantee security depending on: a) known reversals of the hashing strategy of RNGCryptoServiceProvider class and b) access to the database to compromise the randomly generated salt.

I do not know if it is possible to use some sort of rainbow table hack into the default Hash-base system.

For more details, check out this link:
http://msdn.microsoft.com/en-us/library/aa478949.aspx

在巴黎塔顶看东京樱花 2024-07-14 05:24:51

如果通过会员提供商正确配置,您将拥有足够的安全级别。 除此之外,对该页面的访问可能可以通过规范攻击进行访问,但这与您的总体安全有关。 我演示了如何使用安全企业应用程序块。 您可能需要阅读这些内容,并在站点上实施安全性时进行研究,并了解常见的安全威胁。 没有一个网站是 100% 不可破解的,因为您处于开放的共享网络上,并且总体安全性将是一台未插电的服务器锁定在由军方 24/7 全天候守卫的保险箱中(大约是国防部“A”级安全性,基于橙皮书) )。 但是,会员资格提供者的开箱即用功能(如果配置正确)将提供良好的安全性。

编辑:是的,我同意其他评论,如果您想保护用户名/密码免受数据包嗅探器和网络监视器的侵害,至少在登录屏幕上使用 HTTPS 是给定的。

If configured correctly through the membership provider, you will have a adequate level of security. Outside of that, access to that page might be accessible through cannonical attacks, but that has to do with your general security. I gave a presentation on using the Security Enterprise Application Blocks. You might want to read up on those and look into that when implementing security on your site, and just be aware of common security threats. No site will ever be 100% unhackable, given that you are on an open shared network and total security would be an unplugged server locked in a safe guarded 24/7 by the military (around DoD "A" level security, based of Orange book). But the out of the box functionality of the Membership Providers (when configured correctly) will offer a good amount of security.

Edit: Yeah, I agree with the other comment that was made, HTTPS on at least the log in screens is a given, if you want to protect the username/passwords from packet sniffers and network monitors.

贩梦商人 2024-07-14 05:24:51

Asp.Net 支持 cookieless 会话,如此博客文章所示。 它使用 url 中的标识符来跟踪用户,而不是会话 cookie。

我不确定这有多安全,但我认为它是安全的,因为很难暴力破解身份字符串。

它看起来或多或少是开箱即用的,但是当重定向用户并想要维护会话状态时,您必须包含会话 ID。 该博客文章以及网络上的许多其他文章展示了如何做到这一点。

Asp.Net supports cookieless sessions, as this blog post shows. Instead of a session cookie, it uses an identifier in the url to track users.

I am not sure how secure this is, but I would think it is a secure as the difficulty to brute force the identity string.

It looks like it works more or less out of the box, however when redirecting a user and wanting to maintain session state you must include the session id. The blog post shows how to do that, as well as many other articles on the web.

别再吹冷风 2024-07-14 05:24:51

URL 上的 Cookie 不够安全,它存在很多不同的问题(尤其是引用者泄漏,如果有的话)以及 HTTPS 的使用。

Cookies over URL is not secure enough, there are so many different problems with it (especially referrer leakage if you've got any) and usage of HTTPS.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文