CVE-2022-4065
TestNG is vulnerable to Path Traversal
Description
Impact
Affected by this vulnerability is the function testngXmlExistsInJar of the file testng-core/src/main/java/org/testng/JarFileUtils.java of the component XML File Parser.
The manipulation leads to path traversal only for .xml, .yaml and .yml files by default. The attack implies running an unsafe test JAR. However since that JAR can also contain executable code itself, the path traversal is unlikely to be the main attack.
Patches
A patch is available in version 7.7.0 at commit 9150736cd2c123a6a3b60e6193630859f9f0422b. It is recommended to apply a patch to fix this issue. The patch was pushed into the master branch but no releases have yet been made with the patch included.
A backport of the fix is available in [version 7.5.1]((https://github.com/cbeust/testng/releases/tag/7.5.1) for Java 8 projects.
Workaround
- Specify which tests to run when invoking TestNG by configuring them on the CLI or in the build tool controlling the run.
- Do not run tests with untrusted JARs on the classpath, this includes pull requests on open source projects.
Affected Maven artifacts (1)
| Artifact | Affected versions | Fixed in |
|---|---|---|
| org.testng » testng | >= 6.13, < 7.5.1>= 7.6.0, < 7.7.0 | 7.5.1, 7.7.0 |
Blast radius
49% of the dependent artifacts (3,999) still pull an affected version in their latest release.
| Depth | Dependent versions |
|---|---|
| Direct | 33,049 |
| 2 hops | 38,797 |
| 3 hops | 113,474 |
| 4 hops | 56,021 |
| 5 hops | 42,594 |
| 6 hops | 22,899 |
Most used dependents
- org.codehaus.groovy » groovy-all5,349 usages
- org.seleniumhq.selenium » selenium-java2,089 usages
- com.typesafe.play » play-test1,902 usages
- org.apache.cxf » cxf-rt-frontend-jaxws1,379 usages
- org.scalatestplus.play » scalatestplus-play1,286 usages
- org.apache.cxf » cxf-rt-transports-http1,281 usages
- org.apache.cxf » cxf-rt-frontend-jaxrs1,257 usages
- org.codehaus.mojo » jaxb2-maven-plugin882 usages
- org.apache.cxf » cxf-codegen-plugin811 usages
- com.typesafe.play » play-netty-server627 usages
- org.apache.cxf » cxf-rt-rs-client515 usages
- org.apache.cxf » cxf-rt-transports-http-jetty513 usages
- org.apache.cxf » cxf-core503 usages
- org.apereo.cas » cas-server-core-util-api492 usages
- org.asynchttpclient » async-http-client487 usages
Computed from the dependency graph of build 20261124.0621 (compile and runtime scopes, nearest version wins). Exclusions and dependency management in consuming projects are not applied, so dependents are potentially affected. When several artifacts are affected, a dependent version that pulls more than one of them is counted once per artifact.
References
- Advisoryhttps://nvd.nist.gov/vuln/detail/CVE-2022-4065
- Webhttps://github.com/cbeust/testng/pull/1596
- Webhttps://github.com/cbeust/testng/pull/2806
- Webhttps://github.com/testng-team/testng/pull/2899
- Webhttps://github.com/cbeust/testng/commit/9150736cd2c123a6a3b60e6193630859f9f0422b
- Packagehttps://github.com/cbeust/testng
- Webhttps://github.com/cbeust/testng/releases/tag/7.7.0
- Webhttps://github.com/cbeust/testng/releases/tag/7.7.1
- Webhttps://github.com/testng-team/testng/releases/tag/7.5.1
- Webhttps://vuldb.com/?ctiid.214027
- Webhttps://vuldb.com/?id.214027
