# CVE-2022-4065: cbeust testng XML File Parser JarFileUtils.java testngXmlExistsInJar path traversal

> A path traversal vulnerability in TestNG allows remote attackers to read arbitrary files via crafted JAR files.

- **Severity:** Medium 5.5 (`CVSS:3.1/AV:N/AC:L/PR:L/UI:R/S:U/C:L/I:L/A:L`)
- **Exploited in the wild:** Not known
- **Login needed:** Any signed-in user
- **Attackable:** Over the internet
- **Victim action needed:** A user has to click or open something
- **Fix available:** Yes
- **Published:** 19 Nov 2022
- **Updated:** 3 Aug 2024
- **Also known as:** GHSA-rc2q-x9mf-w3vf, MGASA-2023-0220, OESA-2024-1072, SUSE-SU-2023:1690-1, SUSE-SU-2024:2568-1, UBUNTU-CVE-2022-4065, openSUSE-SU-2024:12533-1

## What is CVE-2022-4065?

CVE-2022-4065 is a medium-severity path traversal vulnerability in cbeust testng, published on 19 Nov 2022. Any signed-in user can exploit it over the network, and only if a user opens a file or follows a link.

### Official description

A vulnerability was found in cbeust testng 7.5.0/7.6.0/7.6.1/7.7.0. It has been declared as critical. 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. The attack can be launched remotely. Upgrading to version 7.5.1 and 7.7.1 is able to address this issue. The patch is named 9150736cd2c123a6a3b60e6193630859f9f0422b. It is recommended to upgrade the affected component. The associated identifier of this vulnerability is VDB-214027.

Weakness: CWE-22 (Improper Limitation of a Pathname to a Restricted Directory)

## Which versions are affected by CVE-2022-4065?

4 open source packages ship an affected version, including org.testng:testng. It affects 1 product.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `org.testng:testng` | Maven | From 6.13 | 7.5.1 |
| `org.testng:testng` | Maven | From 6.13 | 7.5.1 |
| `org.testng:testng` | Maven | From 7.6.0 | 7.7.0 |
| `org.testng:testng` | Maven | From 7.6.0 | 7.7.0 |
| `testng` | SUSE:Enterprise Storage 7 | All versions | 7.4.0-150200.3.7.1 |
| `snakeyaml` | SUSE:Enterprise Storage 7.1 | All versions | 2.2-150200.3.15.1 |
| `testng` | SUSE:Enterprise Storage 7.1 | All versions | 7.10.1-150200.3.10.1 |
| `testng` | SUSE:Enterprise Storage 7.1 | All versions | 7.4.0-150200.3.7.1 |
| `snakeyaml` | SUSE:Linux Enterprise High Performance Computing 15 SP2-LTSS | All versions | 2.2-150200.3.15.1 |
| `testng` | SUSE:Linux Enterprise High Performance Computing 15 SP2-LTSS | All versions | 7.10.1-150200.3.10.1 |
| `testng` | SUSE:Linux Enterprise High Performance Computing 15 SP2-LTSS | All versions | 7.4.0-150200.3.7.1 |
| `testng` | SUSE:Linux Enterprise High Performance Computing 15 SP3-ESPOS | All versions | 7.4.0-150200.3.7.1 |
| `snakeyaml` | SUSE:Linux Enterprise High Performance Computing 15 SP3-LTSS | All versions | 2.2-150200.3.15.1 |
| `testng` | SUSE:Linux Enterprise High Performance Computing 15 SP3-LTSS | All versions | 7.10.1-150200.3.10.1 |
| `testng` | SUSE:Linux Enterprise High Performance Computing 15 SP3-LTSS | All versions | 7.4.0-150200.3.7.1 |
| `snakeyaml` | SUSE:Linux Enterprise High Performance Computing 15 SP4-ESPOS | All versions | 2.2-150200.3.15.1 |
| `testng` | SUSE:Linux Enterprise High Performance Computing 15 SP4-ESPOS | All versions | 7.10.1-150200.3.10.1 |
| `snakeyaml` | SUSE:Linux Enterprise High Performance Computing 15 SP4-LTSS | All versions | 2.2-150200.3.15.1 |
| `testng` | SUSE:Linux Enterprise High Performance Computing 15 SP4-LTSS | All versions | 7.10.1-150200.3.10.1 |
| `testng` | SUSE:Linux Enterprise Module for Development Tools 15 SP4 | All versions | 7.4.0-150200.3.7.1 |
| `snakeyaml` | SUSE:Linux Enterprise Module for Development Tools 15 SP5 | All versions | 2.2-150200.3.15.1 |
| `testng` | SUSE:Linux Enterprise Module for Development Tools 15 SP5 | All versions | 7.10.1-150200.3.10.1 |
| `snakeyaml` | SUSE:Linux Enterprise Module for Development Tools 15 SP6 | All versions | 2.2-150200.3.15.1 |
| `testng` | SUSE:Linux Enterprise Module for Development Tools 15 SP6 | All versions | 7.10.1-150200.3.10.1 |
| `mockito` | SUSE:Linux Enterprise Module for Package Hub 15 SP6 | All versions | 5.11.0-150200.3.7.1 |
| `testng` | SUSE:Linux Enterprise Real Time 15 SP3 | All versions | 7.4.0-150200.3.7.1 |
| `snakeyaml` | SUSE:Linux Enterprise Server 15 SP2-LTSS | All versions | 2.2-150200.3.15.1 |
| `testng` | SUSE:Linux Enterprise Server 15 SP2-LTSS | All versions | 7.10.1-150200.3.10.1 |
| `testng` | SUSE:Linux Enterprise Server 15 SP2-LTSS | All versions | 7.4.0-150200.3.7.1 |
| `snakeyaml` | SUSE:Linux Enterprise Server 15 SP3-LTSS | All versions | 2.2-150200.3.15.1 |
| `testng` | SUSE:Linux Enterprise Server 15 SP3-LTSS | All versions | 7.10.1-150200.3.10.1 |
| `testng` | SUSE:Linux Enterprise Server 15 SP3-LTSS | All versions | 7.4.0-150200.3.7.1 |
| `snakeyaml` | SUSE:Linux Enterprise Server 15 SP4-LTSS | All versions | 2.2-150200.3.15.1 |
| `testng` | SUSE:Linux Enterprise Server 15 SP4-LTSS | All versions | 7.10.1-150200.3.10.1 |
| `snakeyaml` | SUSE:Linux Enterprise Server for SAP Applications 15 SP2 | All versions | 2.2-150200.3.15.1 |
| `testng` | SUSE:Linux Enterprise Server for SAP Applications 15 SP2 | All versions | 7.10.1-150200.3.10.1 |
| `testng` | SUSE:Linux Enterprise Server for SAP Applications 15 SP2 | All versions | 7.4.0-150200.3.7.1 |
| `snakeyaml` | SUSE:Linux Enterprise Server for SAP Applications 15 SP3 | All versions | 2.2-150200.3.15.1 |
| `testng` | SUSE:Linux Enterprise Server for SAP Applications 15 SP3 | All versions | 7.10.1-150200.3.10.1 |
| `testng` | SUSE:Linux Enterprise Server for SAP Applications 15 SP3 | All versions | 7.4.0-150200.3.7.1 |

Products: Testng Project Testng.

## How do I fix CVE-2022-4065?

Upgrade org.testng:testng to a fixed version for your release line: 7.5.1 or 7.7.0.

## Is CVE-2022-4065 being exploited?

There is no known exploitation of CVE-2022-4065 in the wild and no public exploit code.

Public exploit code:

- https://github.com/shoucheng3/testng-team__testng_CVE-2022-4065_7-5 (github_poc): https://github.com/shoucheng3/testng-team__testng_CVE-2022-4065_7-5

## Fix prompt for AI coding agents

```text
Check this codebase for CVE-2022-4065 and fix it if it is affected.

What it is: CVE-2022-4065 is a medium-severity path traversal vulnerability in cbeust testng, published on 19 Nov 2022. Any signed-in user can exploit it over the network, and only if a user opens a file or follows a link.
Exploitation: There is no known exploitation of CVE-2022-4065 in the wild and no public exploit code.

Affected packages and fixed versions:
- org.testng:testng (Maven): affected from 6.13; fixed in 7.5.1
- org.testng:testng (Maven): affected from 6.13; fixed in 7.5.1
- org.testng:testng (Maven): affected from 7.6.0; fixed in 7.7.0
- org.testng:testng (Maven): affected from 7.6.0; fixed in 7.7.0

Task:
1. Search the dependency manifests and lockfiles (for example package.json, package-lock.json, requirements.txt, poetry.lock, uv.lock, pom.xml, build.gradle, go.mod, Cargo.lock, Gemfile.lock) and any Dockerfiles for the affected packages, including transitive dependencies.
2. If an affected version is in use, upgrade it to the fixed version for its release line with the project's package manager, so the lockfile is regenerated. Prefer the smallest upgrade that fixes it.
3. If there is no fix, or the upgrade would break the build, do not guess: explain the risk and the safest workaround instead.
4. Run the tests and summarise what changed and why.
5. If nothing in the project is affected, say so and change nothing.

Reference: https://insights.sbomify.com/CVE-2022-4065/ (Markdown: https://insights.sbomify.com/CVE-2022-4065/index.md)
```

## Sources

- CVE record: https://www.cve.org/CVERecord?id=CVE-2022-4065
- NVD: https://nvd.nist.gov/vuln/detail/CVE-2022-4065
- OSV: https://osv.dev/vulnerability/CVE-2022-4065

---
From sbomify Insights: https://insights.sbomify.com/CVE-2022-4065/
Summaries are generated and may contain mistakes; the official description above is the record.
