1.ActiveMQ 反序列化漏洞(CVE-2015-5254)

ref:https://www.nanoxika.com/?p=408

Apache ActiveMQ 5.13.0之前5.x版本中存在安全漏洞,该漏洞源于程序没有限制可在代理中序列化的类。远程攻击者可借助特制的序列化的Java Message Service(JMS)ObjectMessage对象利用该漏洞执行任意代码。

漏洞触发条件:通过web管理页面访问消息并触发漏洞这个过程需要管理员权限

漏洞利用过程:

  1. 构造(可以使用ysoserial)可执行命令的序列化对象
  2. 作为一个消息,发送给目标61616端口
  3. 访问web管理页面,读取消息,触发漏洞

参考链接:https://www.blackhat.com/docs/us-16/materials/us-16-Kaiser-Pwning-Your-Java-Messaging-With-Deserialization-Vulnerabilities.pdf

运行漏洞环境:环境运行后,ActiveMQ将监听61616和8161两个端口。其中61616是工作端口,消息在这个端口进行传递;8161是Web管理页面端口。

访问http://your-ip:8161即可看到web管理页面,不过这个漏洞理论上是不需要web的。

 

2.ActiveMQ任意文件写入漏洞(CVE-2016-3088)

ref:https://www.nanoxika.com/?p=412

ActiveMQ的web控制台分三个应用,admin、api和fileserver,其中admin是管理员页面,api是接口,fileserver是储存文件的接口;admin和api都需要登录后才能使用,fileserver无需登录。fileserver是一个RESTful API接口,我们可以通过GET、PUT、DELETE等HTTP请求对其中存储的文件进行读写操作,其设计目的是为了弥补消息队列操作不能传输、存储二进制文件的缺陷,但后来发现:

  1. 其使用率并不高
  2. 文件操作容易出现漏洞

所以,ActiveMQ在5.12.x~5.13.x版本中,已经默认关闭了fileserver这个应用(你可以在conf/jetty.xml中开启之);在5.14.0版本以后,彻底删除了fileserver应用。在测试过程中,可以关注ActiveMQ的版本,避免走弯路。本漏洞出现在fileserver应用中,漏洞原理其实非常简单,就是fileserver支持写入文件(但不解析jsp),同时支持移动文件(MOVE请求)。所以,我们只需要写入一个文件,然后使用MOVE请求将其移动到任意位置,造成任意文件写入漏洞

 

3.Apache Tomcat 远程代码执行漏洞(CVE-2016-8735)

Tomcat中也使用了JmxRemoteLifecycleListener这个监听器,但是Tomcat并没有及时升级,所以导致了这个远程代码执行漏洞。

此漏洞在严重程度上被定义为Important,而非Critical,主要是因为采用此listener的数量并不算大,而且即便此listener被利用,此处JMX端口访问对攻击者而言也相当不寻常。

影响较小:1)Tomcat默认是没有catalina-jmx-remote.jar包;2)要启用JmxRemoteLifecycleListener包,默认情况下是不启用的

受影响版本:

Apache Tomcat 9.0.0.M1 to 9.0.0.M11

Apache Tomcat 8.5.0 to 8.5.6

Apache Tomcat 8.0.0.RC1 to 8.0.38

Apache Tomcat 7.0.0 to 7.0.72

Apache Tomcat 6.0.0 to 6.0.47

4.Apache Tomcat漏洞 之 CVE-2017-12617_漏洞

影响启用了HTTP PUT的系统(通过将默认servlet的“只读”初始化参数设置为“false”,默认不启用!)受到影响。

如果默认servlet的参数只读设置为false,或者配置了默认servlet,则在9.0.1(Beta),8.5.23,8.0.47和7.0.82之前的Tomcat版本在所有操作系统上包含潜在危险的远程代码执行(RCE)

ref:https://yq.aliyun.com/ziliao/293207,http://www.freebuf.com/vuls/150203.html

修改 D:\ProgramFiles\Apache Software Foundation\Tomcat 7.0\conf\web.xml 配置文件,增加 readonly 设置为 false ,一定要记得重启下tomcat服务。

4.Spring Security / MVC Path Matching Inconsistency(CVE-2016-5007,越权): ref:0c0c0f

此漏洞影响的Spring Web和Spring Security使用HttpSecurity.authorizeRequests用于URL访问控制的应用。

风险级别:中

漏洞利用:远程

影响:请求授权绕过.例如将用户user提升为管理员权限。越权

http.authorizeRequests() .antMatchers("/resources/**", "/signup", "/about").permitAll().antMatchers("/admin/**").hasRole("ADMIN")                        

提交user%2f则可以绕过权限控制。主要原因在于security校验时采用了全部匹配,但是spring mvc删除了非法字符,这就变成访问admin了。

也就是校验和实际访问发生了变化。

 

5.CVE-2016-9879 Encoded "/" in path variables,spring security访问绕过

与CVE-2016-5007类似。

影响范围

条件一:SpringSecurity 3.2.0 - 3.2.9,  4.0.x - 4.1.3,  4.2.0

条件二:部署在IBMWebSphereApplication Server 8.5.x 的容器中.tomcat目前不受影响。

CVE-2016-9879 bypass类似这样

Anapplication that uses the followingintercept URL pattern:

  <intercept-urlpattern="/a/b/c"access="PERMISSION_Guest"/>

  <intercept-urlpattern="/a/b/1/c"access="PERMISSION_ADMIN"/>

  to protectURLs such as:/myapp/a/b/c can be exploited by an attacker that uses aURL of the form:/ctx/a/b;%2f1/c

低权限的攻击者提交/ctx/a/b;%2f1/c,SpringSecurity认为/a/b/c则认为权限符合规则的,但是实际经过Spring MVC框架过滤掉;和解码之后最终的地址变成了/a/b/1/c达到了未授权访问的目的。

Users of Apache Tomcat (all current versions) are not affected by this vulnerability since Tomcat follows the guidance previously provided by the Servlet Expert group and strips path parameters from the value returned by getContextPath(), getServletPath() and getPathInfo() [1].

 

6.CVE-2016-2173 Remote Code Execution in Spring AMQP: ref:0c0c0f

消息系统各大公司常见基础框架之一,之前在black hat usa 2016,code white团队的@matthias_kaiser介绍了主流消息系统的反序列化漏洞。

受影响的漏洞版本:

Apache ActiveMQ 5.12.0 and earlier

HornetQ 2.4.0 and earlier

Oracle OpenMQ 5.1 and earlier

IBM Websphere MQ 8.0.0.4 and earlier

Oracle Weblogic 12c and earlier

Pivotal RabbitMQ JMS client 1.4.6 and earlier

IBM MessageSight MessageSight V1.2 JMSClient and earlier

SwiftMQ JMS client 9.7.3 and earlier

Apache ActiveMQ Artemis client 1.2.0 and earlier

Apache Qpid JMS client 0.9.0 and earlier

Amazon SQS Java Messaging Library 1.0.0 and earlier

Spring AMQP简介:Spring AMQP 是基于 Spring 框架的 AMQP 消息解决方案,提供模板化的发送和接收消息的抽象层,提供基于消息驱动的 POJO。同时有 Java 和 .NET 的版本。

Java漏洞版本:  <spring.amqp.version>1.5.4.RELEASE</spring.amqp.version>

 

7.Jackson enableDefaultTyping 方法反序列化代码执行漏洞(CVE-2017-7525)

Jackson是一个开源的Java序列化与反序列化工具,可以将java对象序列化为xml或json格式的字符串,或者反序列化回对应的对象,由于其使用简单,速度较快,且不依靠除JDK外的其他库,被众多用户所使用。Jackson官方已经发布补丁修复了该开源组件。

由于Jackson在处理反序列的时候需要支持多态,所以在反序列的时候通过指定特定的类来达到实现多态的目的。这个特性默认是不开启的

使用条件:

  • Jackson Version 2.7.* < 2.7.10,Jackson Version 2.8.* < 2.8.9
  • web应用必须应用jackson来反序列化json数据。也即必须有用户恶意的输入
  • 必须开启多态(默认不开启)

1)jackson序列化:All data binding starts with a com.fasterxml.jackson.databind.ObjectMapper instance, so let's construct one:

ObjectMapper mapper = new ObjectMapper(); // create once, reuse,利用objectMapper来序列化

The default instance is fine for our use -- we will learn later on how to configure mapper instance if necessary. Usage is simple:

MyValue value = mapper.readValue(new File("data.json"), MyValue.class);
value = mapper.readValue(new URL("http://some.com/api/entry.json"), MyValue.class);
value = mapper.readValue("{\"name\":\"Bob\", \"age\":13}", MyValue.class);

2)反序列化And if we want to write JSON, we do the reverse

mapper.writeValue(new File("result.json"), myResultObject);最终调用newinstance
byte[] jsonBytes = mapper.writeValueAsBytes(myResultObject);
String jsonString = mapper.writeValueAsString(myResultObject);

3)Jackson多态类型绑定

为了让Jackson支持多态,Jackson官方提供了几种方式,下面介绍两种常用方式(https://github.com/FasterXML/jackson-docs/wiki/JacksonPolymorphicDeserialization

第一种:全局Default Typing机制,启用代码如下:

objectMapper.enableDefaultTyping(); // default to using DefaultTyping.OBJECT_AND_NON_CONCRETE
objectMapper.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL);
这是一个全局开关,打开之后,在持久化存储数据时会存储准确的类型信息。

第二种:为相应的class添加@JsonTypeInfo注解

public ObjectMapper enableDefaultTyping(DefaultTyping dti) {
    return enableDefaultTyping(dti, JsonTypeInfo.As.WRAPPER_ARRAY);
}

通过阅读源码也能发现,全局Default Typing机制也是通过JsonTypeInfo来实现的。下面来看一个简单的示例:

@JsonTypeInfo(use = JsonTypeInfo.Id.CLASS, include = JsonTypeInfo.As.WRAPPER_ARRAY)
class Animal { }  在超类Animal上加上一段@JsonTypeInfo,所有Animal的子类反序列化都可以准确的对于子类型

这段注解什么意思呢?JsonTypeInfo.Id.CLASS是指序列化或者反序列时都是全名称,如org.codehaus.jackson.sample.Animal,JsonTypeInfo.As.WRAPPER_ARRAY 意为使用数组表示,如

[
    "com.fasterxml.beans.EmployeeImpl",
    {
       ... // actual instance data without any metadata properties
    }
]则在反序列化时,告诉ObjectMapper将该json字符串转化为EmployeeImpl对象。而该字符串对象类型用户可控。

ref:https://www.seebug.org/vuldb/ssvid-92962。漏洞简单利用
https://paper.seebug.org/473/
http://www.cnblogs.com/hoojo/archive/2011/04/22/2024628.html:jackson用法
 
posted on 2018-10-08 17:23  studyskill  阅读(7464)  评论(0编辑  收藏  举报