【发布时间】:2018-03-05 06:22:52
【问题描述】:
我不确定如何修复 Jsp 示例中 scriptlet 标记的跨站点脚本(持久性)
"/> 我还附上了一个包含 scriptlet 示例的图像,我不确定如何修复这些示例,请通过证明一些修复来帮助我修复enter image description here
【问题讨论】:
标签: javascript java jsp xss
我不确定如何修复 Jsp 示例中 scriptlet 标记的跨站点脚本(持久性)
"/> 我还附上了一个包含 scriptlet 示例的图像,我不确定如何修复这些示例,请通过证明一些修复来帮助我修复enter image description here
【问题讨论】:
标签: javascript java jsp xss
您可以通过框架配置进行控制。在 Spring Security Framework 中使用以下代码(https://docs.spring.io/spring-security/site/docs/current/reference/html/headers.html#headers-xss-protection):
一些浏览器内置了过滤反射 XSS 攻击的支持。这绝不是万无一失的,但确实有助于 XSS 保护。
过滤通常默认启用,因此添加标头通常只是确保启用它并指示浏览器在检测到 XSS 攻击时执行什么操作。例如,过滤器可能会尝试以侵入性最小的方式更改内容以仍然呈现所有内容。有时,这种类型的替换本身可能成为 XSS 漏洞。相反,最好阻止内容而不是尝试修复它。为此,我们可以添加以下标题:
X-XSS-Protection: 1; mode=block
默认情况下包含此标头。但是,如果我们愿意,我们可以自定义它。例如:
<http>
<!-- ... -->
<headers>
<xss-protection block="false"/>
</headers>
</http>
同样,您可以在 Java 配置中自定义 XSS 保护:
@EnableWebSecurity
public class WebSecurityConfig extends
WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {
http
// ...
.headers()
.xssProtection()
.block(false);
}
}
【讨论】: