Bug 61572 - Illegal reflective access by org.apache.poi.openxml4j.util.ZipSecureFile in Java 9
Summary: Illegal reflective access by org.apache.poi.openxml4j.util.ZipSecureFile in J...
Status: RESOLVED FIXED
Alias: None
Product: POI
Classification: Unclassified
Component: POI Overall (show other bugs)
Version: 3.16-FINAL
Hardware: PC All
: P2 enhancement (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
: 61991 62034 62050 (view as bug list)
Depends on: 61564 62187
Blocks:
  Show dependency tree
 
Reported: 2017-09-29 00:30 UTC by Luis Filipe Nassif
Modified: 2018-08-13 20:09 UTC (History)
4 users (show)



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Luis Filipe Nassif 2017-09-29 00:30:06 UTC
While testing Tika with java 9 we have hit:

WARNING: Illegal reflective access by org.apache.poi.openxml4j.util.ZipSecureFile$1 (file:/E:/git/iped/target/release/iped-3.13/lib/poi-ooxml-3.16.jar) to field
 java.io.FilterInputStream.in
WARNING: All illegal access operations will be denied in a future release
Comment 1 Nick Burch 2017-09-29 04:41:04 UTC
Are you able to retry with Apache POI 3.17, to see if it has been fixed with some of the more recent Java 9 testing?

If not / if it still happens, what do we need to do with Tika and/or POI to trigger it?
Comment 2 Axel Howind 2017-09-29 12:12:00 UTC
I can confirm that this is still happening in 3.17.final.
Comment 3 PJ Fanning 2017-09-29 16:26:02 UTC
Java 9 is just out and it looks we have a few issues (eg https://bz.apache.org/bugzilla/show_bug.cgi?id=61564)

There is a plan to issue a 3.17.1 patch to fix issues when Java 9 is used.
Comment 4 PJ Fanning 2017-09-29 16:26:54 UTC
Java 9 is just out and it looks we have a few issues (eg https://bz.apache.org/bugzilla/show_bug.cgi?id=61564)

There is a plan to issue a 3.17.1 patch to fix issues when Java 9 is used.
Comment 5 Andreas Beeker 2017-09-29 21:20:20 UTC
Although I would like to fix this for 3.17.1, I think this can't be fixed without changing the java zip implementation. Maybe commons compress could help. I guess the chances are nil to get a modification into the Zip classes ?...
Comment 6 Dominik Stadler 2017-10-01 20:14:00 UTC
It's not caused in the JVM, but by the usage of reflection in ZipSecureFile.addThreshold(). 

I would first investigate and then discuss if there is even a fix necessary. 

We do cover these code-lines in our unit-tests and we do continuous testing of JDK 9 since some time.

Luis, can you state if you followed the steps indicated at http://poi.apache.org/faq.html#faq-N102B0 and specified the given commandline parameters when running your application with Java 9?

Also is the application crashing at that point or is this a mere output to stderr. I think this one is just a warning on stderr and thus does not hinder execution at all currently, right?
Comment 7 Axel Howind 2017-10-02 07:36:28 UTC
Well, I think this should definitely be fixed. It's only a warning message, and I don't expect this to have any other side effects for the time being. But if you look at the discussions that took place during Java 9 development, the message is: we decided last minute to allow this illegal access to give library/software maintainers time to fix their codebase; we will disallow this access by default in the next major release of Java. (that's not citing, it's just what I recall from memory)

So not fixing this is just waiting for failure when the next release comes out.

I had looked into this some days ago. The code causing the issue seems to be some kind of hotfix to prevent DOS attacks by using manipulated files (files that contain zip bombs). To do this, an an InputStream field is read and wrapped via reflective access. There's even already a comment in the code that this will break in Java 9, and an explanation on how it should be fixed.

The code lies on different paths, one of which seems to be relatively easy to fix. I think the other places are somewhat harder to fix. If I had the time, I'd try to produce a fix. Currently, that's not the case. But if noone else steps up, I hope I could do it before Java 10 GA. ;-)
Comment 8 Dominik Stadler 2017-10-02 13:47:11 UTC
Sorry for the confusion, I meant mostly "releasing 3.17.1 may not be necessary/possible", fixing the warning for 4.0.0 if possible is naturally the way to go. 

However we still will support Java 8 as main version for some time, so that is what needs to keep working for now, not Java 9 running perfectly smooth and Java 8 not any longer.
Comment 9 Luis Filipe Nassif 2017-10-02 19:08:35 UTC
Hi Nick, the reflective access to FilterInputStream.in from ZipSecureFile is still present in POI trunk.

Hi Dominik, no, I did not add those command line parameters (--add-opens, --add-modules, so on), although I was aware of them. Part of our app and Tika are libraries, so not always we have control of command line parameters.

And yes, that is just a warning from the jvm and poi works with java 9. But I think that could be improved long term to work in future versions of java.
Comment 10 PJ Fanning 2018-01-23 12:16:47 UTC
*** Bug 62034 has been marked as a duplicate of this bug. ***
Comment 11 PJ Fanning 2018-01-23 12:17:27 UTC
*** Bug 61991 has been marked as a duplicate of this bug. ***
Comment 12 PJ Fanning 2018-01-30 13:39:38 UTC
*** Bug 62050 has been marked as a duplicate of this bug. ***
Comment 13 Andreas Beeker 2018-08-13 20:09:27 UTC
Fixed via #62187