网站地图    收藏   

主页 > 后端 > 网站安全 >

Fixing XSS: A practical guide for developers - 网站安全 -

来源:自学PHP网    时间:2015-04-17 11:59 作者: 阅读:

[导读] I#39;m happy to announce a new document we just made available: Fixing XSS: a practical guide for developers. If you#39;re currently at the RSA conference, you should ......

I'm happy to announce a new document we just made available: Fixing XSS: a practical guide for developers. If you're currently at the RSA conference, you should come to Coverity's booth (#1759) and either get a hardcopy or a USB stick with this document on it.
 
As the title suggests, this document is a guide for developers on how to handle dynamic data in various locations and common constructs in HTML. We leveraged the data we got from our research for our talk at RSA to come up with some of the most common HTML contexts and nested contexts, and improved the Coverity Security Library to have a solution for all of these cases.
 
Looking at the documentation available for XSS, several things strikes us:
1.    It's often talking about how to exploit an XSS and not how to fix this issue
2.    The HTML contexts information is always lacking precision and often makes the documentation complex to read (we're also guilty of this in some previous blog posts)
3.    The fixes are limited or too restrictive (i.e., not applicable for developers)
That's mostly why we decided to create our own document mostly for developers.
 
The first release of this document contains 13 common HTML constructs, and we plan on adding more to it. We also describe what HTML contexts are and why it's important to think about them when outputting dynamic data in a web page. However, we're also thinking to create a collateral that gives more complete information about HTML contexts and why it matters for XSS.
 
In this document, you can expect to learn what happens when you want to add dynamic data in a HTML context such as HTML snippet inside a JavaScript string such as:
1.  <div id="forMyContent"></div>  
2.  <script>  
3.    var foo = "<h1>${cov:jsStringEscape(cov:htmlEscape(content))}</h1>";  
4.    $("#forMyContent")  
5.    .html(foo);  
6.  </script>  
and why you need to first use an HTML escaper, then a JavaScript string escaper.
 
You'll also see the usage of a newly introduce function asUrl from CSL that helps writing fully dynamic URLs inside an HTML attribute such as:
1.  <a href="${cov:htmlEscape(cov:asURL(content))}">  
2.    Click me  
3.  </a>  
 
The current document uses the Java Expression Language (EL) notation to show the dynamic data (here ${content}), but all functions are also available directly from Java when using CSL.
 
Whether you develop web applications, have developers, or do security review, you should read and share this document. We're also happy to receive any feedback to keep improving this document.
 

自学PHP网专注网站建设学习,PHP程序学习,平面设计学习,以及操作系统学习

京ICP备14009008号-1@版权所有www.zixuephp.com

网站声明:本站所有视频,教程都由网友上传,站长收集和分享给大家学习使用,如由牵扯版权问题请联系站长邮箱904561283@qq.com

添加评论