asp.net中基本表单身份验证的安全性如何?
假设我们有一个只有两页的简单站点:login.aspx和secret.aspx。站点仅使用ASP.net表单身份验证和login.aspx上的ASP.net登录服务器控件来保护。详情如下:
- 该站点被配置为使用SqlMembershipProvider
- 该网站拒绝所有匿名用户
- Cookies被禁用
关于安全性,显然有很多事情要考虑,但是我对.net框架随附的零代码开箱即用体验更感兴趣。
如果出于这个问题的考虑,唯一的攻击点是login.aspx中的用户名/密码文本框,黑客是否可以注入代码以允许他们访问我们的secret.aspx页面?
Microsoft提供的开箱即用零代码体验的安全性如何?
解决方案
据我所知,密码将以纯文本形式发送(但经过编码)。因此,最重要的事情是在登录屏幕上使用HTTPS协议。
其他设置对我来说似乎是安全的。
如果通过成员资格提供程序正确配置,则将具有足够的安全级别。除此之外,可以通过规范攻击来访问该页面,但这与一般安全性有关。我做了一个有关使用安全企业应用程序块的演示。我们可能需要阅读这些内容,并在站点上实施安全性时进行研究,并且要注意常见的安全威胁。假设我们使用的是开放共享网络,那么任何站点都不会100%无法黑客攻击,而总的安全性将是由军队将其锁定在24/7全天候安全锁定的未插拔服务器上(基于橙皮书的DoD" A"级安全性) )。但是,成员资格提供程序的即用型功能(如果配置正确)将提供大量的安全性。
编辑:是的,如果要保护用户名/密码不受数据包嗅探器和网络监视器的影响,我同意提出的另一条评论,即至少在登录屏幕上指定了HTTPS。
我们仍然有一些未说明的变量:
- 成员资格提供程序使用的数据存储的安全性(在本例中为Sql Server数据库)。
- 同一IIS中托管的其他站点的安全性
- 托管站点所涉及的机器或者托管站点的同一网络上的计算机的一般网络安全性
- 托管站点的机器的物理安全性
- 我们是否在使用适当的措施来加密身份验证流量? (HTTPS / SSL)
并非所有这些问题都是特定于MS的,但是值得一提,因为如果不加以解决,它们中的任何一个都可以轻易地超过我们所要求的问题。但是,就问题而言,我认为它们没有任何问题。
在那种情况下,我很确定表单身份验证可以完成应做的事情。我认为目前没有任何活跃的漏洞利用。
如本博文所示,Asp.Net支持无cookie会话。代替会话cookie,它使用URL中的标识符来跟踪用户。
我不确定这有多安全,但是我认为这是安全的,因为暴力破解身份字符串很困难。
看起来它几乎可以立即使用,但是,当重定向用户并希望保持会话状态时,必须包含会话ID。该博客文章显示了如何执行此操作,以及网络上的许多其他文章。
使用.NET基本表单身份验证使用的HTTP基本身份验证,为了查看secret.aspx页,浏览器必须发送用户名和密码的Base64编码串联。
除非我们使用SSL,否则有权扫描服务器和浏览器之间的网络的任何人都可以读取此信息。他们可以解码用户名和密码。他们将来可以重播用户名和密码,以访问secret.aspx页面。
也就是说,除非我们使用SSL,否则其他人也可以使用secret.aspx扫描其他人的整个会话,因此实际上,他们也可以访问页面的内容。
好吧,尝试一下幕后花絮:
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.
因此,安全性(即开即用)的强度将取决于我们所使用的密码保护格式策略:
- 如果我们使用明文,显然可以更轻松地入侵系统。
- 另一方面,使用"加密"时,安全性将取决于对计算机的物理访问(或者至少对machine.config)。
- 使用哈希密码(默认值)将确保安全,取决于:a)RNGCryptoServiceProvider类的哈希策略的已知逆转,以及b)访问数据库以破坏随机生成的盐。
我不知道是否可以在默认的基于哈希的系统中使用某种形式的彩虹表破解。
有关更多详细信息,请查看此链接:
http://msdn.microsoft.com/en-us/library/aa478949.aspx
这是Microsoft撰写的有关该主题的两篇好文章:
如何:保护ASP.NET 2.0中的表单身份验证
INFO:通过使用安全套接字层(SSL)帮助保护表单身份验证
URL上的Cookies不够安全,它存在很多不同的问题(尤其是引荐来源泄漏)和HTTPS使用情况。