正确处理用户输入

发布于 2024-08-10 12:31:38 字数 193 浏览 3 评论 0原文

因此,我正在设置表单验证、输入、错误消息等......然后意识到我正在收集的许多信息需要在某个时候再次输出。

所以我将我的输入包含在:

Server.HtmlEncode(txtbox.text);

我还应该做什么来确保避免 XSS 类型的攻击?当我将数据写入页面时我也应该做一些事情吗?

So I'm setting up my form validation, inputs, error messages etc... and then realized a lot of the info that I'm collecting will need to be output again at some point.

So I wrapped my inputs in:

Server.HtmlEncode(txtbox.text);

What else should I be doing to ensure that i avoid XSS types of attacks? Should I be be doing something when I write the data to the page as well?

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

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

发布评论

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

评论(2

疯狂的代价 2024-08-17 12:31:38

从安全角度来看,我们的 Web 表单是赤裸裸的,并且 100% 容易受到攻击。我们需要查看数据传递给它们的所有方式并进行适当的测试:

* Form Fields
* URL Query Strings
* Cookies
* Database
* ViewState

MSDN 安全 Web 应用程序设计指南:
http://msdn.microsoft.com/en-us/library/aa302420。 aspx

微软反跨站脚本库:
http://msdn.microsoft.com/en-us/security/aa973814。 aspx

代码分析工具(CAT.NET):
http://www.microsoft.com/downloads/details.aspx microsoft.com/downloads/details.aspx?FamilyId=0178e2ef-9da8-445e-9348-c93f24cc9f9d&displaylang=en

ASP.NET 数据输入验证:
http://www.codersbarn.com/ post/2008/11/01/ASPNET-Data-Input-Validation.aspx

编辑:
即将推出的新 Web 保护库 CTP:
http: //blogs.msdn.com/securitytools/archive/2009/10/17/web-protection-library-ctp-release-coming-soon.aspx

From a security point of view, our Web forms are naked and 100% vulnerable. We need to look at all the ways data is passed to them and test as appropriate:

* Form Fields
* URL Query Strings
* Cookies
* Database
* ViewState

MSDN Design Guidelines for Secure Web Applications:
http://msdn.microsoft.com/en-us/library/aa302420.aspx

Microsoft Anti-Cross Site Scripting Library:
http://msdn.microsoft.com/en-us/security/aa973814.aspx

The Code Analysis Tool (CAT.NET):
http://www.microsoft.com/downloads/details.aspx?FamilyId=0178e2ef-9da8-445e-9348-c93f24cc9f9d&displaylang=en

ASP.NET Data Input Validation:
http://www.codersbarn.com/post/2008/11/01/ASPNET-Data-Input-Validation.aspx:

EDIT:
Coming soon, the new Web Protection Library CTP:
http://blogs.msdn.com/securitytools/archive/2009/10/17/web-protection-library-ctp-release-coming-soon.aspx

栩栩如生 2024-08-17 12:31:38

I suggest to HtmlEncode when you output data to the page, not when you collect it. From Stack Overflow podcast #58:

Don’t HTML encode data that’s stored in your database! Take the good advice of Damien Guard and Joel Spolsky! You can choose to store both representations, but don’t store just the HTML; go with the raw data at the highest level of precision.

Links

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