Java 中的跨站点脚本漏洞
Cross Site scripting vulnerabilty in java
我已经浏览了几个在线参考资料来防止XSS,并且能够在显示用户控制的输入时使用JSTL标签/fn:escapeXml() EL函数来解决与JSP相关的问题。
虽然我无法弄清楚以下代码段如何导致 XSS 漏洞
导致 XSS 漏洞的代码行:
if(div == null)
out.println("'twindow.scroll(0, "+value+");");
else
out.println("'tdocument.getElementById('"+div+"').scrollTop = "+value+";");
完整的代码块:
out.println("<SCRIPT type='"text/javascript'">");
out.println("function scrollAfterLoad()");
out.println("{");
//out.println("'talert('scrollAfterLoad('+y+')');");
// If the id of a DIV is specified, we will scroll that DIV, otherwise we scroll
// the entire window
if(div == null)
out.println("'twindow.scroll(0, "+value+");");
else
out.println("'tdocument.getElementById('"+div+"').scrollTop = "+value+";");
out.println("'tbodyDiv = document.getElementById('"body'");");
out.println("'tif(bodyDiv != null)");
out.println("'t'tsetTimeout('bodyDiv.style.visibility = '"visible'";', 0);");
out.println("}");
这里的"div"和"value"是字符串变量,上面的代码段在TagHandler类中
您可以使用企业安全 API,如下所示:
ESAPI.encoder().encodeForJavaScript("dynamic value");
请参阅此内容:https://www.owasp.org/index.php/Category:OWASP_Enterprise_Security_API
相关文章:
- 当包含另一个asp文件时,是否也包含所有引用的样式和脚本页面
- 借助asp.net验证或java脚本对多个文本进行验证
- chrome扩展:尽管运行了at:documentidle,js脚本还是过早启动
- Java脚本时间添加
- 不显示带有本地json文件数据的谷歌地图脚本
- JQuery添加元素需要在我的js之前再次添加JQuery脚本
- 从远程脚本获取用户IP
- 如何根据时间运行不同的脚本
- 如何将字符串值从php页面发送到java脚本页面
- 使用谷歌应用程序脚本将服务器端数据表返回到客户端
- 可以设置“;文件名"发生错误时显示的内联脚本标记的
- 当脚本由system.js加载时,如何要求('electron')
- HTML标记在脚本标记中工作
- 是否可以控制获取哪些Google地图脚本(JavaScript API)
- 使用谷歌应用程序脚本从工作表中获取值并将其显示在文本框中
- 显示时间的脚本
- Java 中的跨站点脚本漏洞
- 脚本文件夹存在漏洞
- ColdFusion MX User-Agent跨站脚本漏洞
- 安全扫描显示JS脚本文件中的漏洞