[go: nahoru, domu]

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[core] JDK 11.0.20+9 breaks jadx decompilation functionality #1962

Closed
zt64 opened this issue Jul 27, 2023 · 6 comments
Closed

[core] JDK 11.0.20+9 breaks jadx decompilation functionality #1962

zt64 opened this issue Jul 27, 2023 · 6 comments
Labels
bug Core Issues in jadx-core module

Comments

@zt64
Copy link
Contributor
zt64 commented Jul 27, 2023

Describe error
JDK has recently updated and has changed how the ZipFile class functions. JDK-8302483 breaks decompilation. Downgrading the installed JDK to versions older than 11.0.20 do indeed result in the error going away.

java.lang.RuntimeException: Failed to process zip file: /home/nick/Documents/SM-S908U_NA_12/apk/atfwd.apk
        at jadx.api.plugins.utils.ZipSecurity.visitZipEntries(ZipSecurity.java:115)
        at jadx.api.plugins.utils.ZipSecurity.readZipEntries(ZipSecurity.java:121)
        at jadx.plugins.input.dex.DexFileLoader.collectDexFromZip(DexFileLoader.java:90)
        at jadx.plugins.input.dex.DexFileLoader.load(DexFileLoader.java:73)
        at jadx.plugins.input.dex.DexFileLoader.loadDexFromFile(DexFileLoader.java:50)
        at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197)
        at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197)
        at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1625)
        at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509)
        at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499)
        at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:921)
        at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
        at java.base/java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:682)
        at jadx.plugins.input.dex.DexFileLoader.collectDexFiles(DexFileLoader.java:45)
        at jadx.plugins.input.dex.DexInputPlugin.loadFiles(DexInputPlugin.java:37)
        at jadx.plugins.input.dex.DexInputPlugin.loadFiles(DexInputPlugin.java:33)
        at jadx.api.JadxDecompiler.loadInputFiles(JadxDecompiler.java:128)
        at jadx.api.JadxDecompiler.load(JadxDecompiler.java:112)
        at jadx.cli.JadxCLI.processAndSave(JadxCLI.java:48)
        at jadx.cli.JadxCLI.execute(JadxCLI.java:36)
        at jadx.cli.JadxCLI.main(JadxCLI.java:20)
Caused by: java.util.zip.ZipException: Invalid CEN header (invalid zip64 extra data field size)
        at java.base/java.util.zip.ZipFile$Source.zerror(ZipFile.java:1750)
        at java.base/java.util.zip.ZipFile$Source.checkExtraFields(ZipFile.java:1276)
        at java.base/java.util.zip.ZipFile$Source.checkAndAddEntry(ZipFile.java:1219)
        at java.base/java.util.zip.ZipFile$Source.initCEN(ZipFile.java:1689)
        at java.base/java.util.zip.ZipFile$Source.<init>(ZipFile.java:1464)
        at java.base/java.util.zip.ZipFile$Source.get(ZipFile.java:1427)
        at java.base/java.util.zip.ZipFile$CleanableResource.<init>(ZipFile.java:723)
        at java.base/java.util.zip.ZipFile.<init>(ZipFile.java:250)
        at java.base/java.util.zip.ZipFile.<init>(ZipFile.java:179)
        at java.base/java.util.zip.ZipFile.<init>(ZipFile.java:193)
        at jadx.api.plugins.utils.ZipSecurity.visitZipEntries(ZipSecurity.java:97)
        ... 20 common frames omitted
ERROR - Failed to process zip file: /home/nick/Documents/SM-S908U_NA_12/apk/atfwd.apk
java.lang.RuntimeException: Failed to process zip file: /home/nick/Documents/SM-S908U_NA_12/apk/atfwd.apk
        at jadx.api.plugins.utils.ZipSecurity.visitZipEntries(ZipSecurity.java:115)
        at jadx.api.plugins.utils.ZipSecurity.readZipEntries(ZipSecurity.java:121)
        at jadx.plugins.input.java.JavaInputLoader.collectFromZip(JavaInputLoader.java:91)
        at jadx.plugins.input.java.JavaInputLoader.loadReader(JavaInputLoader.java:71)
        at jadx.plugins.input.java.JavaInputLoader.loadFromFile(JavaInputLoader.java:50)
        at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197)
        at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197)
        at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1625)
        at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509)
        at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499)
        at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:921)
        at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
        at java.base/java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:682)
        at jadx.plugins.input.java.JavaInputLoader.collectFiles(JavaInputLoader.java:37)
        at jadx.plugins.input.java.JavaInputPlugin.loadClassFiles(JavaInputPlugin.java:36)
        at jadx.plugins.input.java.JavaInputPlugin.loadFiles(JavaInputPlugin.java:32)
        at jadx.api.JadxDecompiler.loadInputFiles(JadxDecompiler.java:128)
        at jadx.api.JadxDecompiler.load(JadxDecompiler.java:112)
        at jadx.cli.JadxCLI.processAndSave(JadxCLI.java:48)
        at jadx.cli.JadxCLI.execute(JadxCLI.java:36)
        at jadx.cli.JadxCLI.main(JadxCLI.java:20)
Caused by: java.util.zip.ZipException: Invalid CEN header (invalid zip64 extra data field size)
        at java.base/java.util.zip.ZipFile$Source.zerror(ZipFile.java:1750)
        at java.base/java.util.zip.ZipFile$Source.checkExtraFields(ZipFile.java:1276)
        at java.base/java.util.zip.ZipFile$Source.checkAndAddEntry(ZipFile.java:1219)
        at java.base/java.util.zip.ZipFile$Source.initCEN(ZipFile.java:1689)
        at java.base/java.util.zip.ZipFile$Source.<init>(ZipFile.java:1464)
        at java.base/java.util.zip.ZipFile$Source.get(ZipFile.java:1427)
        at java.base/java.util.zip.ZipFile$CleanableResource.<init>(ZipFile.java:723)
        at java.base/java.util.zip.ZipFile.<init>(ZipFile.java:250)
        at java.base/java.util.zip.ZipFile.<init>(ZipFile.java:179)
        at java.base/java.util.zip.ZipFile.<init>(ZipFile.java:193)
        at jadx.api.plugins.utils.ZipSecurity.visitZipEntries(ZipSecurity.java:97)
        ... 20 common frames omitted
ERROR - Process error:
java.lang.RuntimeException: Failed to process zip file: /home/nick/Documents/SM-S908U_NA_12/apk/atfwd.apk
        at jadx.api.plugins.utils.ZipSecurity.visitZipEntries(ZipSecurity.java:115)
        at jadx.api.ResourcesLoader.loadFile(ResourcesLoader.java:144)
        at jadx.api.ResourcesLoader.load(ResourcesLoader.java:46)
        at jadx.api.JadxDecompiler.getResources(JadxDecompiler.java:402)
        at jadx.api.JadxDecompiler.load(JadxDecompiler.java:117)
        at jadx.cli.JadxCLI.processAndSave(JadxCLI.java:48)
        at jadx.cli.JadxCLI.execute(JadxCLI.java:36)
        at jadx.cli.JadxCLI.main(JadxCLI.java:20)
Caused by: java.util.zip.ZipException: Invalid CEN header (invalid zip64 extra data field size)
        at java.base/java.util.zip.ZipFile$Source.zerror(ZipFile.java:1750)
        at java.base/java.util.zip.ZipFile$Source.checkExtraFields(ZipFile.java:1276)
        at java.base/java.util.zip.ZipFile$Source.checkAndAddEntry(ZipFile.java:1219)
        at java.base/java.util.zip.ZipFile$Source.initCEN(ZipFile.java:1689)
        at java.base/java.util.zip.ZipFile$Source.<init>(ZipFile.java:1464)
        at java.base/java.util.zip.ZipFile$Source.get(ZipFile.java:1427)
        at java.base/java.util.zip.ZipFile$CleanableResource.<init>(ZipFile.java:723)
        at java.base/java.util.zip.ZipFile.<init>(ZipFile.java:250)
        at java.base/java.util.zip.ZipFile.<init>(ZipFile.java:179)
        at java.base/java.util.zip.ZipFile.<init>(ZipFile.java:193)
        at jadx.api.plugins.utils.ZipSecurity.visitZipEntries(ZipSecurity.java:97)
        ... 7 common frames omitted
@zt64 zt64 added bug Core Issues in jadx-core module labels Jul 27, 2023
@jpstotz jpstotz changed the title [core] JDK 11.0.20 breaks jadx decompilation functionality [core] JDK 11.0.20+9 breaks jadx decompilation functionality Jul 27, 2023
@jpstotz
Copy link
Collaborator
jpstotz commented Jul 27, 2023

Thanks for reporting. Based on the page you have linked it should be sufficient to set the system property jdk.util.zip.disableZip64ExtraFieldValidation to true at start-up of jadx and jadx-gui.

According to the discussion in the apktools issue tracker about this JDK change:
See also iBotPeaches/Apktool#3174 (comment)

Edit: a good test APK which causes this problem is https://github.com/iBotPeaches/Apktool/blob/master/brut.apktool/apktool-lib/src/test/resources/aapt1/shared_libraries/library.apk

@jpstotz
Copy link
Collaborator
jpstotz commented Jul 27, 2023

I just made some tests and realized that calling System.setProperty("jdk.util.zip.disableZip64ExtraFieldValidation", "true"); at run-time has no effect:

This property is only read when java.util.zip.ZipFile is read. As the system class loader uses ZipFile to load the JAR files form class path the jdk.util.zip.disableZip64ExtraFieldValidation property is already before the first user class is executed. Therefore trying to set this property using System.setProperty is useless no matter how and where you add it.

The only way to set this property is directly when starting the java run-time. In the end this means we have to change the start script and the Launch4j generated executable.

@skylot
Copy link
Owner
skylot commented Jul 28, 2023

@jpstotz I commit fix for run scripts as you suggested, so this should resolve the issue. Thanks for help! 👍

@skylot skylot closed this as completed Jul 28, 2023
@jpstotz
Copy link
Collaborator
jpstotz commented Jul 29, 2023

@Sklot I am currently in contact with Lance Andersen from Oracle, the author of JDK-8302483. I have provided him several APK files which cause the Invalid CEN header (invalid zip64 extra data field size). Not sure what will be the outcome of this, but the situation can only get better...

@iBotPeaches
Copy link

@jpstotz - Thank you for doing that. I was attempting that myself but struggled to make contact and provide samples.

@eirbjo
Copy link
eirbjo commented Aug 14, 2023

For reference, the following OpenJDK PR seems to provide a solution to the problems mentioned in this issue:

openjdk/jdk#15273

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Core Issues in jadx-core module
Projects
None yet
Development

No branches or pull requests

5 participants