Spring security中的Xss防护默认开启吗?

Shi*_*lin 5 xss spring-security

我想在我的应用程序中启用 Spring Security XSS 保护。

1)阅读文档和博客,https://spring.io/blog/2013/08/23/spring-security-3-2-0-rc1-highlights-security-headers/表示默认存在XSS

2)并且http://docs.spring.io/spring-security/site/docs/current/reference/html/headers.html表示默认情况下它不存在

3)如果我http.headers().xssProtection()在类中的配置方法中使用扩展WebSecurityConfigurerAdapter:是否会禁用所有其他默认标头?

not*_*est 4

除非您专门包含以下代码来禁用默认值,否则默认值不会被禁用。

http.headers().defaultsDisabled()
Run Code Online (Sandbox Code Playgroud)

注册点1和2,我的理解是博客和文档都有相同的信息。

X-XSS-Protection: 1; mode=block
Run Code Online (Sandbox Code Playgroud)

过滤(过滤掉 XSS 攻击)通常是默认启用的,因此添加标头通常只是确保其启用,并指示浏览器在检测到 XSS 攻击时该怎么做。