Skip to content

JADX file override vulnerability

Low severity GitHub Reviewed Published Apr 22, 2024 in skylot/jadx • Updated Apr 22, 2024

Package

maven io.github.skylot:jadx-core (Maven)

Affected versions

< 1.5.0

Patched versions

1.5.0

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.

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

but type style will return the original filename directly.

img
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
generate an initial APK

step2

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

img
drop resources.arsc into 010editor

step3

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

img
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

step4

change the type of this file to style

img
modified to 0E

img

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
click save all

img
you can see the file escaping.

img
so we can also construct a

img
so the classes.dex file is also replaced here

img

PoC

the details above have been written

Impact

latest version

References

@skylot skylot published to skylot/jadx Apr 22, 2024
Published to the GitHub Advisory Database Apr 22, 2024
Reviewed Apr 22, 2024
Last updated Apr 22, 2024

Severity

Low

CVSS overall score

This score calculates overall vulnerability severity from 0 to 10 and is based on the Common Vulnerability Scoring System (CVSS).
/ 10

CVSS v3 base metrics

Attack vector
Local
Attack complexity
Low
Privileges required
Low
User interaction
None
Scope
Unchanged
Confidentiality
None
Integrity
Low
Availability
None

CVSS v3 base metrics

Attack vector: More severe the more the remote (logically and physically) an attacker can be in order to exploit the vulnerability.
Attack complexity: More severe for the least complex attacks.
Privileges required: More severe if no privileges are required.
User interaction: More severe when no user interaction is required.
Scope: More severe when a scope change occurs, e.g. one vulnerable component impacts resources in components beyond its security scope.
Confidentiality: More severe when loss of data confidentiality is highest, measuring the level of data access available to an unauthorized user.
Integrity: More severe when loss of data integrity is the highest, measuring the consequence of data modification possible by an unauthorized user.
Availability: More severe when the loss of impacted component availability is highest.
CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:N/I:L/A:N

Weaknesses

CVE ID

No known CVE

GHSA ID

GHSA-hvp5-5x4f-33fq

Source code

Credits

Loading Checking history
See something to contribute? Suggest improvements for this vulnerability.