# GHSA-hvp5-5x4f-33fq: JADX file override vulnerability

> A malicious APK can overwrite files in the output directory during decompilation due to improper handling of style resource filenames.

- **Severity:** Not scored
- **Exploited in the wild:** Not known
- **Login needed:** Not needed
- **Attackable:** Local or same network only
- **Victim action needed:** A user has to click or open something
- **Fix available:** Yes
- **Published:** 22 Apr 2024

## What is GHSA-hvp5-5x4f-33fq?

GHSA-hvp5-5x4f-33fq is a path traversal vulnerability in io.github.skylot:jadx-core, published on 22 Apr 2024. It can only be exploited from the same machine or local network, and only if a user opens a file or follows a link.

### Official description

### Summary
when jadx parses a resource file, there is an escape problem with the style file, which can overwrite other files in the directory when saving the decompile result.

Although I don't think this vulnerability realizes path traversal in the true sense of the word , I reported it anyway

### Details

I see that getResAlias does something with the filename.

```java
private String getResAlias(int resRef, String origKeyName, @Nullable FieldNode constField) {
```

but type style will return the original filename directly.

![img](https://quan9i.oss-cn-beijing.aliyuncs.com/img/202401232212491.jpeg)
so our goal is to take a malicious file that was originally of type raw, modify its type to style, trick jadx into

#### step1

create an android project using androidstudio and create a raw folder with the name attack_file_sayhiiiiiiiiiiiii, it doesn't matter what the content is!

![img](https://quan9i.oss-cn-beijing.aliyuncs.com/img/202401232212073.jpg)
generate an initial APK

#### step2 

extract this initial APK using ZIP software to get resources.arsc

![img](https://quan9i.oss-cn-beijing.aliyuncs.com/img/202401232212841.jpg)
drop resources.arsc into 010editor

#### step3

search for the previous filename attack_file_sayhiiiiiiiiiiiii , two will appear here, we choose the second one

![img](https://quan9i.oss-cn-beijing.aliyuncs.com/img/202401232213527.jpg)
let's change the name of the file here. I'll change it to ../../_file_sayhiiiiiiiiiiiii

note that you can only overwrite files in the folder where the decompile was saved.

![img](https://quan9i.oss-cn-beijing.aliyuncs.com/img/202401232213343.jpg)
#### step4 
change the type of this file to style

![img](https://quan9i.oss-cn-beijing.aliyuncs.com/img/202401232213183.jpg)
modified to 0E

![img](https://quan9i.oss-cn-beijing.aliyuncs.com/img/202401232213484.jpg)
#### step5 

After saving, re-compress the whole folder into a zip, then change the extension to APK.

open it with JADX and you can see that it has been changed to a style type.

![img](https://quan9i.oss-cn-beijing.aliyuncs.com/img/202401232213864.jpg)
click save all

![img](https://quan9i.oss-cn-beijing.aliyuncs.com/img/202401232213119.jpg)
you can see the file escaping.

![img](https://quan9i.oss-cn-beijing.aliyuncs.com/img/202401232213746.jpg)
so we can also construct a  

![img](https://quan9i.oss-cn-beijing.aliyuncs.com/img/202401232213497.jpg)
so the classes.dex file is also replaced here

![img](https://quan9i.oss-cn-beijing.aliyuncs.com/img/202401232213075.jpg)

### PoC
the details above have been written

### Impact
latest version

## Which versions are affected by GHSA-hvp5-5x4f-33fq?

2 open source packages ship an affected version, including io.github.skylot:jadx-core.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `io.github.skylot:jadx-core` | Maven | All versions | 1.5.0 |
| `io.github.skylot:jadx-core` | Maven | All versions | 1.5.0 |

## How do I fix GHSA-hvp5-5x4f-33fq?

Upgrade io.github.skylot:jadx-core to 1.5.0 or later.

## Is GHSA-hvp5-5x4f-33fq being exploited?

There is no known exploitation of GHSA-hvp5-5x4f-33fq in the wild and no public exploit code.

## Fix prompt for AI coding agents

```text
Check this codebase for GHSA-hvp5-5x4f-33fq and fix it if it is affected.

What it is: GHSA-hvp5-5x4f-33fq is a path traversal vulnerability in io.github.skylot:jadx-core, published on 22 Apr 2024. It can only be exploited from the same machine or local network, and only if a user opens a file or follows a link.
Exploitation: There is no known exploitation of GHSA-hvp5-5x4f-33fq in the wild and no public exploit code.

Affected packages and fixed versions:
- io.github.skylot:jadx-core (Maven): affected all versions; fixed in 1.5.0
- io.github.skylot:jadx-core (Maven): affected all versions; fixed in 1.5.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/GHSA-hvp5-5x4f-33fq/ (Markdown: https://insights.sbomify.com/GHSA-hvp5-5x4f-33fq/index.md)
```

## Sources

- OSV: https://osv.dev/vulnerability/GHSA-hvp5-5x4f-33fq

---
From sbomify Insights: https://insights.sbomify.com/GHSA-hvp5-5x4f-33fq/
Summaries are generated and may contain mistakes; the official description above is the record.
