这里网安使用的扫描软件是Acunetix,总共扫描出1个中等漏洞,2个低等漏洞,3个提示。
1.Medium,Vulnerable Javascript library 易受攻击的javascript库
解决,升级到最新版本即可。
2.Low OPTIONS method is enabled 允许options类型请求方式
解决方法:禁用不安全的http请求方式(SpringBoot)
import org.apache.catalina.Context;
import org.apache.tomcat.util.descriptor.web.SecurityCollection;
import org.apache.tomcat.util.descriptor.web.SecurityConstraint;
import org.springframework.boot.context.embedded.EmbeddedServletContainerFactory;
import org.springframework.boot.context.embedded.tomcat.TomcatContextCustomizer;
import org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
/**
* @Author: SimonHu
* @Date: 2019/9/27 15:36
* @Description:过滤不安全http方法
*/
@Configuration
public class CustomCORSConfiguration {
@Bean
public EmbeddedServletContainerFactory servletContainer() {
TomcatEmbeddedServletContainerFactory tomcatServletContainerFactory = new TomcatEmbeddedServletContainerFactory();
tomcatServletContainerFactory.addContextCustomizers(new TomcatContextCustomizer(){
@Override
public void customize(Context context) {
SecurityConstraint constraint = new SecurityConstraint();
SecurityCollection collection = new SecurityCollection();
//http方法
collection.addMethod("PUT");
collection.addMethod("DELETE");
collection.addMethod("HEAD");
collection.addMethod("OPTIONS");
collection.addMethod("TRACE");
//url匹配表达式
collection.addPattern("/*");
constraint.addCollection(collection);
constraint.setAuthConstraint(true);
context.addConstraint(constraint );
//设置使用httpOnly
context.setUseHttpOnly(true);
}
});
return tomcatServletContainerFactory;
}
}
Low Cookie(s) without Secure flag set 没有设置安全标志的Cookie
解决方法(SpringBoot):
server:
port:
contextPath: /
session:
cookie:
http-only: true
secure: true
3.Informational Possible username or password disclosure 存在用户名和密码泄露的可能
Acunetix在扫码时会用正则匹配password,pwd等关键字来查看你js脚本中是否含有这些关键字。
解决办法:
var Twd = this.loginTwd;
var code=this.code;
var showCode = this.showCode;
var param ={'loginName':loginName,'Twd':Twd,'code':code,'showCode':showCode};
this.$http.post([[@{/user/login}]], param,{emulateJSON: true}).then(function (response) {
密码类型避免使用password,pwd关键字作为参数传给服务端。
最后再次扫描,发现没有任何漏洞提示: