Goal Reached Thanks to every supporter — we hit 100%!

Goal: 1000 CNY · Raised: 1000 CNY

100.0%

CVE-2022-25842 PoC — one-java-agent 路径遍历漏洞

Source
Associated Vulnerability
Title:one-java-agent 路径遍历漏洞 (CVE-2022-25842)
Description:one-java-agent是提供插件化支持,统一管理众多的Java Agent。 com.alibaba.oneagent:one-java-agent-plugin 所有版本存在安全漏洞,攻击者利用该漏洞可以覆盖可执行文件并远程调用它们,或者等待系统或用户调用它们,从而在受害者的机器上实现远程命令执行。
Readme
# one-java-agent
![JavaCI](https://github.com/alibaba/one-java-agent/workflows/JavaCI/badge.svg)
[![maven](https://img.shields.io/maven-central/v/com.alibaba/one-java-agent.svg)](https://search.maven.org/search?q=g:com.alibaba%20AND%20a:one-java-agent*)
![license](https://img.shields.io/github/license/alibaba/one-java-agent.svg)
[![Average time to resolve an issue](http://isitmaintained.com/badge/resolution/alibaba/one-java-agent.svg)](http://isitmaintained.com/project/alibaba/one-java-agent "Average time to resolve an issue")
[![Percentage of issues still open](http://isitmaintained.com/badge/open/alibaba/one-java-agent.svg)](http://isitmaintained.com/project/alibaba/one-java-agent "Percentage of issues still open")

## 目标

1. 提供插件化支持,统一管理众多的Java Agent
2. 插件支持install/unstall,需要插件方实现接口
3. 支持传统的java agent,即已经开发好的java agent


## 插件系统

插件如果希望感知生命周期,可以实现 `PluginActivator`接口:

```java
public interface PluginActivator {
    // 让插件本身判断是否要启动
    boolean enabled(PluginContext context);

    public void init(PluginContext context) throws Exception;

    /**
     * Before calling this method, the {@link PluginState} is
     * {@link PluginState#STARTING}, after calling, the {@link PluginState} is
     * {@link PluginState#ACTIVE}
     *
     * @param context
     */
    public void start(PluginContext context) throws Exception;

    /**
     * Before calling this method, the {@link PluginState} is
     * {@link PluginState#STOPPING}, after calling, the {@link PluginState} is
     * {@link PluginState#RESOLVED}
     *
     * @param context
     */
    public void stop(PluginContext context) throws Exception;
}
```



## 传统的java agent

插件目录下面放一个`plugin.properties`,并且放上原生的agent jar文件。

例如:

```
type=traditional
name=demo-agent
version=1.0.0
agentJarPath=demo-agent.jar
```

则 one java agent会启动这个`demo-agent`。


## 编译开发

* 本项目依赖 bytekit: https://github.com/alibaba/bytekit ,可能需要先`mvn clean install` bytekit
* 执行测试: `mvn clean package -DskipTests && mvn test`
* `mvn clean package -P local -DskipTests`会打包后安装最新到本地 `~/oneoneagent` 目录下
File Snapshot

[4.0K] /data/pocs/a3e647e2f7c7093753949b233de74fc67af30c0c ├── [4.0K] demo-agent │   ├── [5.0K] pom.xml │   └── [4.0K] src │   └── [4.0K] main │   ├── [4.0K] assembly │   │   └── [1.3K] assembly.xml │   ├── [4.0K] java │   │   └── [4.0K] com │   │   └── [4.0K] test │   │   └── [ 475] DemoAgent.java │   └── [ 90] plugin.properties ├── [4.0K] demo-plugin │   ├── [3.9K] pom.xml │   └── [4.0K] src │   └── [4.0K] main │   ├── [4.0K] assembly │   │   └── [1.2K] assembly.xml │   ├── [4.0K] java │   │   └── [4.0K] com │   │   └── [4.0K] activator │   │   └── [4.0K] test │   │   └── [ 802] DemoActivator.java │   └── [ 126] plugin.properties ├── [4.0K] dubbo-test-instrument │   ├── [1.6K] pom.xml │   └── [4.0K] src │   └── [4.0K] main │   ├── [4.0K] java │   │   └── [4.0K] org │   │   └── [4.0K] apache │   │   └── [4.0K] dubbo │   │   ├── [4.0K] monitor │   │   │   └── [4.0K] support │   │   │   └── [1.6K] MonitorFilter.java │   │   └── [4.0K] rpc │   │   └── [4.0K] test │   │   └── [ 871] Invoker.java │   └── [4.0K] resources │   └── [ 91] instrument.properties ├── [4.0K] dubbo-test-plugin │   ├── [4.1K] pom.xml │   └── [4.0K] src │   └── [4.0K] main │   ├── [4.0K] assembly │   │   └── [1.4K] assembly.xml │   ├── [4.0K] java │   │   └── [4.0K] com │   │   └── [4.0K] test │   │   └── [4.0K] dubbo │   │   └── [ 841] DubboDemoActivator.java │   └── [ 139] plugin.properties ├── [ 11K] LICENSE.txt ├── [9.8K] mvnw ├── [6.5K] mvnw.cmd ├── [4.0K] one-java-agent │   ├── [ 11K] pom.xml │   └── [4.0K] src │   ├── [4.0K] main │   │   ├── [4.0K] java │   │   │   └── [4.0K] com │   │   │   └── [4.0K] alibaba │   │   │   └── [4.0K] oneagent │   │   │   ├── [8.9K] AgentImpl.java │   │   │   ├── [ 465] Agent.java │   │   │   ├── [ 948] AgentSpyImpl.java │   │   │   ├── [ 945] BootstrapAgent.java │   │   │   ├── [4.0K] inst │   │   │   │   └── [ 642] ClassLoader_Instrument.java │   │   │   ├── [2.4K] NopAgent.java │   │   │   └── [4.0K] utils │   │   │   └── [2.0K] InstrumentationUtils.java │   │   └── [4.0K] resources │   │   └── [2.0K] oneagent-logback.xml │   └── [4.0K] test │   └── [4.0K] java │   └── [4.0K] com │   └── [4.0K] alibaba │   └── [4.0K] oneagent │   ├── [1.1K] AgentArgsUtils.java │   ├── [3.7K] BootstrapAgentNewProcessTest.java │   ├── [1006] BootstrapAgentTest.java │   ├── [1.4K] JavaVersionUtils.java │   ├── [3.9K] ProcessUtils.java │   └── [ 236] TTT.java ├── [4.0K] one-java-agent-plugin │   ├── [1.9K] pom.xml │   └── [4.0K] src │   ├── [4.0K] main │   │   ├── [4.0K] java │   │   │   └── [4.0K] com │   │   │   └── [4.0K] alibaba │   │   │   └── [4.0K] oneagent │   │   │   ├── [4.0K] env │   │   │   │   ├── [7.9K] AbstractPropertyResolver.java │   │   │   │   ├── [4.4K] ConfigurablePropertyResolver.java │   │   │   │   ├── [2.6K] ConversionService.java │   │   │   │   ├── [4.0K] convert │   │   │   │   │   ├── [1.6K] ConfigurableConversionService.java │   │   │   │   │   ├── [1.4K] Converter.java │   │   │   │   │   ├── [1.3K] ConvertiblePair.java │   │   │   │   │   ├── [4.0K] DefaultConversionService.java │   │   │   │   │   ├── [ 972] ObjectToStringConverter.java │   │   │   │   │   ├── [ 983] StringToArrayConverter.java │   │   │   │   │   ├── [1.6K] StringToBooleanConverter.java │   │   │   │   │   ├── [ 328] StringToEnumConverter.java │   │   │   │   │   ├── [ 514] StringToInetAddressConverter.java │   │   │   │   │   ├── [ 255] StringToIntegerConverter.java │   │   │   │   │   └── [ 241] StringToLongConverter.java │   │   │   │   ├── [3.0K] EnumerablePropertySource.java │   │   │   │   ├── [ 94] Environment.java │   │   │   │   ├── [1.4K] MapPropertySource.java │   │   │   │   ├── [1.9K] MissingRequiredPropertiesException.java │   │   │   │   ├── [ 11K] MutablePropertySources.java │   │   │   │   ├── [4.3K] OneagentEnvironment.java │   │   │   │   ├── [ 79] package-info.java │   │   │   │   ├── [1.8K] PropertiesPropertySource.java │   │   │   │   ├── [ 10K] PropertyPlaceholderHelper.java │   │   │   │   ├── [4.5K] PropertyResolver.java │   │   │   │   ├── [ 11K] PropertySource.java │   │   │   │   ├── [1.4K] PropertySources.java │   │   │   │   ├── [4.7K] PropertySourcesPropertyResolver.java │   │   │   │   ├── [3.5K] ReadOnlySystemAttributesMap.java │   │   │   │   ├── [5.4K] SystemEnvironmentPropertySource.java │   │   │   │   └── [4.4K] SystemPropertyUtils.java │   │   │   ├── [4.0K] plugin │   │   │   │   ├── [4.0K] config │   │   │   │   │   ├── [1.7K] AbstractPluginConfig.java │   │   │   │   │   ├── [5.2K] PluginConfigImpl.java │   │   │   │   │   ├── [ 442] PluginConfig.java │   │   │   │   │   └── [1.7K] TraditionalPluginConfigImpl.java │   │   │   │   ├── [7.7K] OneAgentPlugin.java │   │   │   │   ├── [1.1K] PlguinClassLoader.java │   │   │   │   ├── [ 796] PluginActivator.java │   │   │   │   ├── [ 385] PluginConstants.java │   │   │   │   ├── [1.1K] PluginContextImpl.java │   │   │   │   ├── [ 375] PluginContext.java │   │   │   │   ├── [ 444] PluginException.java │   │   │   │   ├── [ 434] Plugin.java │   │   │   │   ├── [ 14K] PluginManagerImpl.java │   │   │   │   ├── [ 782] PluginManager.java │   │   │   │   ├── [ 347] PluginState.java │   │   │   │   ├── [4.0K] properties │   │   │   │   │   ├── [ 372] Config.java │   │   │   │   │   ├── [ 346] NestedConfig.java │   │   │   │   │   └── [8.3K] PropertiesInjectUtils.java │   │   │   │   └── [4.3K] TraditionalPlugin.java │   │   │   ├── [4.0K] service │   │   │   │   ├── [ 308] ClassLoaderHandler.java │   │   │   │   ├── [2.1K] ClassLoaderHandlerManagerImpl.java │   │   │   │   ├── [ 341] ClassLoaderHandlerManager.java │   │   │   │   ├── [ 213] Component.java │   │   │   │   ├── [3.5K] ComponentManagerImpl.java │   │   │   │   ├── [ 280] ComponentManager.java │   │   │   │   ├── [1.8K] OneAgentClassFileTransformer.java │   │   │   │   ├── [3.9K] TransformerManagerImpl.java │   │   │   │   └── [ 718] TransformerManager.java │   │   │   └── [4.0K] utils │   │   │   ├── [7.3K] AnsiLog.java │   │   │   ├── [8.8K] FeatureCodec.java │   │   │   ├── [3.9K] IOUtils.java │   │   │   ├── [ 571] JarUtils.java │   │   │   ├── [ 28K] ObjectUtils.java │   │   │   ├── [3.1K] OSUtils.java │   │   │   ├── [ 283] PlatformEnum.java │   │   │   ├── [ 740] PropertiesUtils.java │   │   │   └── [ 22K] StringUtils.java │   │   └── [4.0K] resources │   │   └── [4.0K] META-INF │   │   └── [4.0K] services │   │   └── [ 110] com.alibaba.oneagent.service.Component │   └── [4.0K] test │   └── [4.0K] java │   └── [4.0K] com │   └── [4.0K] alibaba │   └── [4.0K] oneagent │   ├── [4.0K] plugin │   │   └── [4.0K] config │   │   └── [1.6K] PluginConfigImplTest.java │   ├── [4.0K] service │   │   └── [ 710] ComponentManagerImplTest.java │   └── [4.0K] utils │   └── [ 712] FeatureCodecTest.java ├── [4.0K] one-java-agent-spy │   ├── [1.1K] pom.xml │   └── [4.0K] src │   └── [4.0K] main │   └── [4.0K] java │   └── [4.0K] java │   └── [4.0K] oneagent │   ├── [ 348] AgentSpyBridge.java │   ├── [ 297] AgentSpy.java │   └── [ 271] NopAgentSpy.java ├── [7.0K] pom.xml └── [2.3K] README.md 82 directories, 112 files
Shenlong Bot has cached this for you
Remarks
    1. It is advised to access via the original source first.
    2. If the original source is unavailable, please email f.jinxu#gmail.com for a local snapshot (replace # with @).
    3. Shenlong has snapshotted the POC code for you. To support long-term maintenance, please consider donating. Thank you for your support.