Vulnerabilities in pkg:maven/org.testng/testng
PACKAGECVE-2022-4065 is a HIGH (CVSS 7.8) path traversal vulnerability (CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')) affecting Testng libraries in the Maven ecosystem. The issue involves testng is vulnerable to path traversal. Remediation is available by upgrading affected packages to version 7.5.1, 7.7.0.
pkg:maven/org.testng/testng
Vulnerability advisories affecting package pkg:maven/org.testng/testng. Select an advisory below to view technical details or fixes.
| Advisory ID | CVE / NVD | Severity | Summary |
|---|---|---|---|
| GHSA-rc2q-x9mf-w3vf | CVE-2022-4065 | HIGH | TestNG is vulnerable to Path Traversal |
CVE-2022-4065 at a Glance
Security Impact
CVSS: 7.8
The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H).
How to Fix CVE-2022-4065
To remediate this vulnerability, upgrade all affected Testng dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>7.5.1</version>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>7.7.0</version>
</dependency>
Run the following command in your project directory to verify that all resolved dependencies use the patched release:
mvn dependency:tree -Dincludes=org.testng
How to Check if You Are Affected
To determine whether your Java application is affected by CVE-2022-4065, inspect your build dependencies using the Maven Dependency Plugin:
mvn dependency:tree -Dincludes=org.testng
Analyze the terminal output to locate any version of Testng in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 7.5.1), your application is affected.
Note: The mvn dependency:tree -Dincludes=org.testng command inspects the resolved dependency graph declared in your project's POM files; it does not perform automated security scanning or inspect runtime dynamic classpaths. Always verify runtime container classpaths and shaded JARs.
Technical Details
Vulnerability Mechanism & Technical Analysis
This vulnerability is classified under CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal'), where the product uses external input to construct a pathname that is intended to identify a file or directory that is located underneath a restricted parent directory, but the product does not properly neutralize special elements within the pathname that can cause the pathname to resolve to a location that is outside of the restricted directory. In Testng, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.
Source Advisory Statement
CVE-2022-4065 Affected Testng Versions
2 component(s)| Product / Package | Ecosystem | Affected Versions | Fixed Version |
|---|---|---|---|
|
org.testng:testng
|
Maven |
≥ 6.13
< 7.5.1
|
7.5.1
|
|
org.testng:testng
|
Maven |
≥ 7.6.0
< 7.7.0
|
7.7.0
|
References
Frequently Asked Questions
What is CVE-2022-4065?
Which Testng versions are affected?
What version fixes CVE-2022-4065?
Is testng affected?
What is the CVSS score of CVE-2022-4065?
What CWE is associated with CVE-2022-4065?
How can I check Maven dependencies for CVE-2022-4065?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"schema_version" : "1.4.0",
"id" : "GHSA-rc2q-x9mf-w3vf",
"modified" : "2023-05-09T17:53:32Z",
"published" : "2022-11-19T21:30:25Z",
"aliases" : [ "CVE-2022-4065" ],
"summary" : "TestNG is vulnerable to Path Traversal",
"details" : "### Impact\n\nAffected 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`.\n\nThe 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.\n\n### Patches\n\nA patch is available in [version 7.7.0](https://github.com/cbeust/testng/releases/tag/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.\n\nA 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.\n\n### Workaround\n\n* Specify which tests to run when invoking TestNG by configuring them on the CLI or in the build tool controlling the run.\n* Do not run tests with untrusted JARs on the classpath, this includes pull requests on open source projects.",
"severity" : [ {
"type" : "CVSS_V3",
"score" : "CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H"
} ],
"affected" : [ {
"package" : {
"ecosystem" : "Maven",
"name" : "org.testng:testng"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "6.13"
}, {
"fixed" : "7.5.1"
} ]
} ]
}, {
"package" : {
"ecosystem" : "Maven",
"name" : "org.testng:testng"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "7.6.0"
}, {
"fixed" : "7.7.0"
} ]
} ]
} ],
"references" : [ {
"type" : "ADVISORY",
"url" : "https://nvd.nist.gov/vuln/detail/CVE-2022-4065"
}, {
"type" : "WEB",
"url" : "https://github.com/cbeust/testng/pull/1596"
}, {
"type" : "WEB",
"url" : "https://github.com/cbeust/testng/pull/2806"
}, {
"type" : "WEB",
"url" : "https://github.com/testng-team/testng/pull/2899"
}, {
"type" : "WEB",
"url" : "https://github.com/cbeust/testng/commit/9150736cd2c123a6a3b60e6193630859f9f0422b"
}, {
"type" : "PACKAGE",
"url" : "https://github.com/cbeust/testng"
}, {
"type" : "WEB",
"url" : "https://github.com/cbeust/testng/releases/tag/7.7.0"
}, {
"type" : "WEB",
"url" : "https://github.com/cbeust/testng/releases/tag/7.7.1"
}, {
"type" : "WEB",
"url" : "https://github.com/testng-team/testng/releases/tag/7.5.1"
}, {
"type" : "WEB",
"url" : "https://vuldb.com/?ctiid.214027"
}, {
"type" : "WEB",
"url" : "https://vuldb.com/?id.214027"
} ],
"database_specific" : {
"cwe_ids" : [ "CWE-22" ],
"severity" : "HIGH",
"github_reviewed" : true,
"github_reviewed_at" : "2022-12-02T22:31:06Z",
"nvd_published_at" : "2022-11-19T19:15:00Z"
}
}