記一次網安安全漏洞整改


這里網安使用的掃描軟件是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

HTTP設置cookie時,提供了2個屬性,可以增強cookie的安全性,分別是secure屬性和httpOnly屬性。

secure屬性可防止信息在傳遞的過程中被監聽捕獲后導致信息泄露,如果設置為true,可以限制只有通過https訪問時,才會將瀏覽器保存的cookie傳遞到服務端,如果通過http訪問,不會傳遞cookie。

httpOnly屬性可以防止程序獲取cookie,如果設置為true,通過js等將無法讀取到cookie,能有效的防止XSS攻擊

 

 

 

 解決方法(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關鍵字作為參數傳給服務端。

最后再次掃描,發現沒有任何漏洞提示:

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM