ASP.NET安全性最佳做法 [英] ASP.NET Security Best Practices

查看:115
本文介绍了ASP.NET安全性最佳做法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

什么是其他ASP.NET安全最佳做法?

What are others ASP.NET Security Best Practices?

目前发现这里列出:


  • 始终生成新的加密密钥,每当你正在申请生产。管理员密码

  • Always generate new encryption keys and admin passwords whenever you are moving an application to production.

千万不要密码直接或者以加密的形式存储。始终存储单向哈希密码。

Never store passwords directly or in encrypted form. Always stored one way hashed passwords.

始终将连接字符串和使用受保护配置提供(RSA或DPAPI)它配置部分进行加密。见<一href=\"http://msdn.microsoft.com/en-us/library/ms998372.aspx#pagpractices0001_conhowtoencryptsensitivedatainmachineconfigandwebconfig\"相对=nofollow>例如这里

Always store connection strings in tag of Web.config and encrypt it in configuration section by using protected configuration providers (RSA or DPAPI). See example here

与最小特权使用用户ID连接到SQL Server,或者您正在使用的数据库。例如,如果你只是执行来自应用程序的某个模块的存储过程,那么你必须创建一个有权限只执行一个用户ID。

Use user ID with least-privilege to connect to SQL server or the database you are using. E.g if you are only executing stored procedures from a certain module of application then you must create a user ID which has permissions to execute only.

使用 的PrincipalPermission如果要使用网页上的基于角色的安全性。

Use PrincipalPermission if you want to use role-base security on pages.

[PrincipalPermission(SecurityAction.Demand, Role="Admin")]  
public class AdminOnlyPage : BasePageClass  
{  
  // ...  
}


  • 始终使用参数prevent SQL注入在SQL查询。


    1. 考虑您的IIS服务器上安装URLScan以防止SQL注入。
      此外,对于防止XSS攻击。您可以使用MSFT的AntiXSS库,而不是建EN code输出,而不是建在HtmlEn code中发现的HttpServerUtility。

    始终开启的customErrors保持web配置让你的错误/异常私人

  • Always keep on customErrors in web config to make you errors/exceptions private

    &LT;的customErrors模式=ON的defaultRedirect =MyErrorPage.htm/&GT;

    <customErrors mode="On" defaultRedirect="MyErrorPage.htm" />

    在Web应用程序中,总是验证用户输入的HTML标记或任何脚本。

    In web applications, always validate the user's inputs for html tags or any scripts.

    从不存储敏感信息,像饼干的密码。

    Never store sensitive information, like passwords in cookies.

    推荐答案

    我发现微软的开发公路code 是一个有用的安全检查表。

    I found Microsoft's Developer Highway Code to be a useful security checklist.

    这篇关于ASP.NET安全性最佳做法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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