内容锚点

  • 负、检测工具
    • 1、加密套件、协议兼容性、浏览器兼容性
    • 2、重大漏洞检测
  • 零、测试加密套件方法 (nmap)
  • 一、cookie问题
    • 1、httpOnly / Secure
    • 2、Cookies with missing, inconsistent or contradictory properties
  • 二、 Clickjacking 问题
    • 1、X-Frame-Options header
    • 2、CSP frame-ancestors missing
  • 三、TLS/SSL
    • 1、LOGJAM attack
    • 2、Sweet32 attack / Weak Cipher Suites
  • 四、HSTS问题
  • 五、TLS 1.0 enabled
  • 六、iframe问题
    • 1、Insecure Inline Frame
  • 七、apache Log4j 远程漏洞执行问题

负、检测工具

1、加密套件、协议兼容性、浏览器兼容性

1、https://www.ssllabs.com/ssltest/index.html
2、https://myssl.com/
通过域名检测

2、重大漏洞检测

http://0day.websaas.com.cn/

零、测试加密套件方法 (nmap)

安装方式:yum -y install nmap
可以告知你当前密码套件强度

nmap -sV --script ssl-enum-ciphers -p 443 www.example.com

[root@iZj6c2t7x4azg1onsgpzljZ nginxtest]# nmap -sV --script ssl-enum-ciphers -p 443 chatbot.hkpc.orgStarting Nmap 6.40 ( http://nmap.org ) at 2021-07-08 17:13 CST
Nmap scan report for www.example.com (xx.xxx.xx.xxx)
Host is up (0.0012s latency).
PORT    STATE SERVICE  VERSION
443/tcp open  ssl/http Jetty
| ssl-enum-ciphers:
|   SSLv3: No supported ciphers found
|   TLSv1.2:
|     ciphers:
|       TLS_RSA_WITH_3DES_EDE_CBC_SHA - strong
|       TLS_RSA_WITH_AES_128_CBC_SHA - strong
|       TLS_RSA_WITH_AES_128_CBC_SHA256 - strong
|       TLS_RSA_WITH_AES_128_GCM_SHA256 - strong
|       TLS_RSA_WITH_AES_256_CBC_SHA - strong
|       TLS_RSA_WITH_AES_256_CBC_SHA256 - strong
|       TLS_RSA_WITH_AES_256_GCM_SHA384 - strong
|     compressors:
|       NULL
|_  least strength: strong

一、cookie问题

1、httpOnly / Secure

Java 解决方案

let JSESSIONID = document.cookie.match("JSESSIONID");
if(JSESSIONID){console.log(JSESSIONID)let exp = new Date();exp.setTime(exp.getTime() + 7*24*60*60*1000);document.cookie = JSESSIONID[0]+"="+JSESSIONID['input']+";Secure;Path=/;expires="+exp.toGMTString()+";"
}

jetty解决方案

//配置文件 etc/webdefault.xml
// 可以根据注释:<-- Default session configuration -->下来定位<session-config><session-timeout>30</session-timeout><cookie-config><secure>true</secure><http-only>true</http-only></cookie-config>
</session-config>

2、Cookies with missing, inconsistent or contradictory properties

java解决方案

通常建议在拦截器增加

public class HttpLeakInterceptor implements HandlerInterceptor {
...@Overridepublic void postHandle(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Object o, ModelAndView modelAndView) throws Exception {Cookie[] cookies = httpServletRequest.getCookies();if (cookies != null) {Cookie cookie = cookies[0];if (cookie != null) {// serlvet 2.5 不支持在 Cookie 上直接设置 HttpOnly 属性.String value = cookie.getValue();StringBuilder builder = new StringBuilder();builder.append("JSESSIONID=" + value + "; ");builder.append("Secure; ");builder.append("SameSite=strict; "); //主要是这段builder.append("HttpOnly; ");builder.append("path=/; ");Calendar calendar = Calendar.getInstance();calendar.add(Calendar.HOUR, 1);Date date = calendar.getTime();Locale locale = Locale.CHINA;SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy HH:mm:ss", locale);builder.append("Expires=" + sdf.format(date));httpServletResponse.setHeader("Set-Cookie", builder.toString());}}}
...
}

jetty 解决方案(9.4.22+版本)
严格模式:__SAME_SITE_STRICT__
不使用:__SAME_SITE_NONE__
lax模式:__SAME_SITE_LAX__

//配置文件 etc/webdefault.xml
// 可以根据注释:<-- Default session configuration -->下来定位
<session-config><cookie-config><comment>__SAME_SITE_NONE__</comment></cookie-config>
</session-config>

二、 Clickjacking 问题

参考网站:https://developer.mozilla.org/zh-CN/docs/Web/HTTP/Headers/Content-Security-Policy

1、X-Frame-Options header

1、DENY
表示该页面不允许在frame中展示,即便是在相同域名的页面中嵌套也不允许。
2、SAMEORIGIN
表示该页面可以在相同域名页面的frame中展示。
3、ALLOW-FROM uri
表示该页面可以在指定来源的frame中展示。

java 解决方案

//基于过滤器处理
//例如:我需要允许的网站:http://www.coffeeandice.cn
...
package cn.coffeeandice.filters
...
@Component
public class LeakFilter implements Filter {...@Overridepublic void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {HttpServletResponse resp = (HttpServletResponse) response;resp.addHeader("X-Frame-Options", "ALLOW-FROM http://www.coffeeandice.cn");chain.doFilter(request, resp);}...
}

若非springboot项目,还需要搭配web.xml配置过滤器

   <!-- clickJacking -->    <filter>        <filter-name>LeakFilter</filter-name>        <filter-class>cn.coffeeandice.filters.LeakFilter</filter-class>    </filter>    <filter-mapping>        <filter-name>LeakFilter</filter-name>        <url-pattern>/*</url-pattern>    </filter-mapping>

ngingx解决方案

//设:所需允许的网站为 https://www.coffeeandice.cn
add_header X-Frame-Options  "ALLOW-FROM https://www.coffeeandice.cn";

2、CSP frame-ancestors missing

nginx解决方案

通常我们可以通过配置 Content-Security-Policy处理

可以多个数据源,中间只需要空格分隔即可

Content-Security-Policy: frame-ancestors <source> <source>;

通常两个策略:

self: 设置一相信的域名,可以利用通配符 *

add_header Content-Security-Policy "frame-ancestors 'self' https://www.coffeeandice.cn";

none: 当该指令设置为none时,其作用类似于X-Frame-Options: DENY

add_header Content-Security-Policy "frame-ancestors 'none'";

三、TLS/SSL

1、LOGJAM attack

参考网站: https://weakdh.org/
总体建议是需要提升DHKey的长度,建议提升为2048

(Part A)jdk参数设置

jdk参数 -Djdk.tls.ephemeralDHKeySize = 2048
方式一: 直接设置jdk参数
方式二:设置jetty的启动参数

(Part B)jetty-ssl.xml文件配置

通常目录结构为{Jetty_Home}/etc/
前提条件:在start.ini中开启了这个模块配置 /etc/jetty.xml

<Configure id="sslContextFactory" class="org.eclipse.jetty.util.ssl.SslContextFactory">
...
<Set name="ExcludeCipherSuites"><Array type="String">...
<!-- Disable cipher suites with Diffie-Hellman key exchange to prevent Logjam attack and avoid the ssl_error_weak_server_ephemeral_dh_key error in recent browsers --><Item>SSL_DHE_RSA_WITH_3DES_EDE_CBC_SHA</Item><Item>SSL_DHE_DSS_WITH_3DES_EDE_CBC_SHA</Item><Item>TLS_DHE_RSA_WITH_AES_256_CBC_SHA256</Item><Item>TLS_DHE_DSS_WITH_AES_256_CBC_SHA256</Item><Item>TLS_DHE_RSA_WITH_AES_256_CBC_SHA</Item><Item>TLS_DHE_DSS_WITH_AES_256_CBC_SHA</Item><Item>TLS_DHE_RSA_WITH_AES_128_CBC_SHA256</Item><Item>TLS_DHE_DSS_WITH_AES_128_CBC_SHA256</Item><Item>TLS_DHE_RSA_WITH_AES_128_CBC_SHA</Item><Item>TLS_DHE_DSS_WITH_AES_128_CBC_SHA</Item>...<Array type="String">
</Set>
...

2、Sweet32 attack / Weak Cipher Suites

其实两个问题都是围绕 TLS_RSA_WITH_3DES_EDE_CBC_SHA 这个加密套件处理
Sweet32 attack :主要是围绕 64位加密不安全的情况出现
Weak Cipher Suites:主要是这个加密套件强度不够,建议关闭

阿里雲SLB解決方案
负载均衡 SLB/配置监听 大于图示选项即可

jetty解决方案

<Configure id="sslContextFactory" class="org.eclipse.jetty.util.ssl.SslContextFactory">
...
<Set name="ExcludeCipherSuites"><Array type="String">...
<!-- Disable cipher suites with Diffie-Hellman key exchange to prevent Logjam attack and avoid the ssl_error_weak_server_ephemeral_dh_key error in recent browsers --><Item>TLS_RSA_WITH_3DES_EDE_CBC_SHA</Item>...<Array type="String">
</Set>
...

nginx 解决方案

nginx编译时需要考虑到openSSl版本问题
参考网站: https://www.openssl.org/news/secadv/20160922.txt
OpenSSL 1.0.2 users should upgrade to 1.0.2i
OpenSSL 1.0.1 users should upgrade to 1.0.1u

   理论上nginx默认是: ssl_ciphers HIGH:!aNULL:!MD5;只需要在后加上一个!3DES 即可ssl_ciphers  AES128+EECDH:AES128+EDH:!aNULL:!3DES;

四、HSTS问题

具体而言就是 HTTP Strict Transport Security (HSTS) not implemented

jetty解决方案

方式一:变更jetty-rewrite.xml

//在start.ini修改以下两个参数为rewrite
//#Module: rewrite
//--module=rewrite
//直接放置<configuration></configuration> 节点内在jetty-rewrite.xml添加
<Ref refid="Rewrite"><Call name="addRule"><Arg><New class="org.eclipse.jetty.rewrite.handler.HeaderPatternRule"><Set name="pattern">*</Set><Set name="name">Strict-Transport-Security</Set><Set name="value">max-age=31536000;includeSubDomains</Set></New></Arg></Call>
</Ref>

方式二: 变更 jetty-ssl.xml

通常为9.4+ version

初始默认值:

  <New id="sslHttpConfig" class="org.eclipse.jetty.server.HttpConfiguration"><Arg><Ref refid="httpConfig"/></Arg><Call name="addCustomizer"><Arg><New class="org.eclipse.jetty.server.SecureRequestCustomizer"><Arg name="sniRequired" type="boolean"><Property name="jetty.ssl.sniRequired" default="false"/></Arg><Arg name="sniHostCheck" type="boolean"><Property name="jetty.ssl.sniHostCheck" default="true"/></Arg><Arg name="stsMaxAgeSeconds" type="int"><Property name="jetty.ssl.stsMaxAgeSeconds" default="-1"/></Arg><Arg name="stsIncludeSubdomains" type="boolean"><Property name="jetty.ssl.stsIncludeSubdomains" default="false"/></Arg></New></Arg></Call></New>

适配解决HSTS值:

主要是:
stsMaxAgeSecondsstsIncludeSubdomains属性

  <New id="sslHttpConfig" class="org.eclipse.jetty.server.HttpConfiguration"><Arg><Ref refid="httpConfig"/></Arg><Call name="addCustomizer"><Arg><New class="org.eclipse.jetty.server.SecureRequestCustomizer"><Arg name="sniRequired" type="boolean"><Property name="jetty.ssl.sniRequired" default="false"/></Arg><Arg name="sniHostCheck" type="boolean"><Property name="jetty.ssl.sniHostCheck" default="true"/></Arg><Arg name="stsMaxAgeSeconds" type="int"><Property name="jetty.ssl.stsMaxAgeSeconds" default="31536000"/></Arg><Arg name="stsIncludeSubdomains" type="boolean"><Property name="jetty.ssl.stsIncludeSubdomains" default="true"/></Arg></New></Arg></Call></New>

nginx解决方案

add_header Strict-Transport-Security "max-age=63072000; includeSubdomains; preload";

五、TLS 1.0 enabled

阿里雲SLB解決方案
负载均衡 SLB/配置监听 大于图示选项即可

java解决方案

 理论上需要TLS1.1也需要禁用,内部通常有内容,往上添加即可路径: {JAVA_HOME}/jre/lib/security/java.securityjdk.tls.disabledAlgorithms=TLSv1, TLSv1.1

nginx 解决方案

ssl_protocols TLSv1.2;

六、iframe问题

1、Insecure Inline Frame

主要是因为缺少sandbox属性,引入了外部资源

参数名称 参数说明
allow-forms 允许进行提交表单
allow-scripts 运行执行脚本
allow-modals 允许提示框,即允许执行window.alert()等会产生弹出提示框方法
allow-same-origin 允许同域请求,比如ajax,storage
allow-top-navigation 允许iframe能够主导window.top进行页面跳转
allow-popups 允许iframe中弹出新窗口,比如,window.open,target="_blank"
allow-popups-to-escape-sandbox 允许弹出窗口不受沙箱的限制 ,针对谷歌和Edge拦截附件弹出网站奇效
allow-pointer-lock 在iframe中可以锁定鼠标,主要和鼠标锁定有关
allow-downloads 允许点击后下载文件 (83版本后新增)
allow-top-navigation 允许嵌入的网页对顶级窗口进行导航
allow-top-navigation-by-user-activation 允许嵌入的网页对顶级窗口进行导航,但必须由用户激活。
allow-downloads-without-user-activation 允许在没有征求用户同意的情况下下载文件
allow-storage-access-by-user-activation 允许在用户激动的情况下,嵌入的网页通过 Storage Access API 访问父窗口的储存

建议例子:

sandbox=‘allow-forms allow-popups allow-same-origin allow-scripts allow-downloads’

七、apache Log4j 远程漏洞执行问题

实际上是属于v2版本的漏洞问题:
受影响版本为v2系列,Apache Log4j 2.x <= 2.15.0-rc2
参考漏洞链接:
国家漏洞共享平台:https://www.cnvd.org.cn/webinfo/show/7116
LunaSec:https://www.lunasec.io/docs/blog/log4j-zero-day

建议临时处置方式:

1)添加jvm启动参数-Dlog4j2.formatMsgNoLookups=true;
2)在应用classpath下添加log4j2.component.properties配置文件,文件内容为log4j2.formatMsgNoLookups=true;
3)JDK使用11.0.1、8u191、7u201、6u211及以上的高版本;
4)部署使用第三方防火墙产品进行安全防护。

web常见漏洞修复方法相关推荐

  1. Web常见漏洞修复建议

    一.SQL注入修复建议 1.过滤危险字符,例如:采用正则表达式匹配union.sleep.and.select.load_file等关键字,如果匹配到则终止运行. 2.使用预编译语句,使用PDO需要注 ...

  2. 禁用sslv3协议linux,SSLv3协议漏洞修复方法

    SSL3.0被曝出存在协议漏洞:"通过此漏洞可以窃取客户端与server端使用SSLv3加密通信的明文内容,危害严重",目前官方暂无升级修复补丁和攻击利用方式公布. 最佳建议:&q ...

  3. java中xxe漏洞修复方法

    java中禁止外部实体引用的设置方法不止一种,这样就导致有些开发者修复的时候采用的错误的方法 之所以写这篇文章是有原因的!最早是有朋友在群里发了如下一个pdf, 而当时已经是2019年1月末了,应该不 ...

  4. CentOS bug修复指令集(阿里云漏洞修复方法)

    阿里云服务器经常会提示有漏洞,如 RHSA-2018:0423: kernel security, bug fix, and enhancement update (Moderate),如何修复呢?可 ...

  5. mysql 漏洞如何修复_Mysql漏洞修复方法思路及注意事项

    [系统环境] 系统环境:Red Hat Enterprise Linux Server release 5.4 (Tikanga)+  5.7.16 MySQL Community Server (G ...

  6. intel服务器修复两个漏洞,英特尔处理器漏洞怎么修复 Intelcpu漏洞修复方法

    英特尔处理器漏洞怎么修复?这一次由Intel服务器CPU产品诱发的安全事故现在规模正式扩大,不少玩家朋友们都非常担忧,下面我们就来分享一下Intelcpu漏洞修复方法一览,希望对各位有所参考和帮助. ...

  7. Tomcat漏洞修复方法【补丁下载及安装详细流程】

    目录 访问tomcat的官网漏洞补丁网址 会看到各个版本的tomcat的漏洞修复记录及方法 例如 搜索CVE-2016-6797漏洞的补丁 点击revision后的序列号 进入补丁修复界面,进来之后, ...

  8. SMB Signing not required漏洞修复方法

    漏洞名称:SMB Signing not required 远端SMB服务器上未启用签名. 未经身份验证的远程攻击者可以利用这一点对SMB服务器进行中间人攻击. nessus scan结果如下: De ...

  9. SSL 3.0 安全漏洞修复方法

    SSL 3.0 安全漏洞修复方法 V2EX 谷歌今天披露了一个存在于 SSL 3.0 版本当中的安全漏洞,详细信息请访问: https://www.openssl.org/~bodo/ssl-pood ...

  10. web常见错误解决方法

    web常见错误解决方法 Http状态码: 分类 分类描述 1** 信息,服务器收到请求,需要请求者继续执行操作 2** 成功,操作被成功接收并处理 3** 重定向,需要进一步的操作以完成请求 4** ...

最新文章

  1. MinGW 仿 linux 开发环境
  2. 使用SVCUtil.exe生成客户端代理类和配置文件
  3. 特征图大小_新手向快速了解图神经网络
  4. 超融合和服务器关系_关于超融合一体机,联想有话说
  5. layui上传图片,前端直接拷代码,后端……
  6. Python编程从入门到实践~操作列表
  7. Cyclone IV FPGA 器件笔记
  8. 值得拥有的手绘风格画图工具
  9. Javascript之in操作符的用法
  10. 使用poi解析word转html,并处理word中图片
  11. 卡农,用敬仰和泪水思念着你~~~~~
  12. aws eks 配置nginx tls 和 nginx ingress controller
  13. 视频分析(三):背景减法
  14. copa-pi测试软件,COPA-DATA SCADA/HMI自动化软件中的先锋——zenOn 6.20
  15. Autodesk所有产品的卸载、安装解决方案(3dsmax、cad等)
  16. 新高考3+1+2模式(4选2)全走班自动排课系统7.0(正式版)
  17. 中科软测试面试题2019_中科软寿险事业部软件测试面试题
  18. inpaint 9.1新版3秒去除一切图片中的无关元素
  19. 高德地图 AMap.PlaceSearch
  20. Linux--守护进程

热门文章

  1. 手机网页版微信分享以及微信授权
  2. VtigerCRM 点击拨号和来电弹屏 PBX Manager Module
  3. win10一些快捷键及更新
  4. 100兆宽带下载速度为什么没有100兆/秒
  5. LazyAn-cocos插件开发实战
  6. Matplotlib系列(一):快速绘图入门
  7. 2021-09-09md
  8. 利用CRISPR基因编辑高效靶向诱变玉米农作物/植物核糖蛋白复合物的研究
  9. 项目研发阶段性总结模板
  10. 闹钟android 代码,android 闹钟app源码(Alarm)