When I remove a file from a signed jar file its signature still validates. Furthermore when I tamper with a file in the jar file although it cannot validate the signature it still runs via java -jar
.
Steps to reproduce:
- Download an example jar https://docs.oracle.com/javase/tutorialJWS/samples/deployment/dynamictree_webstartJWSProject/DynamicTreeDemo.jar
- see it's signature is valid
jarsigner -verify DynamicTreeDemo.jar
- delete an html file from the jar
- see it's signature is still valid
jarsigner -verify DynamicTreeDemo.jar
- change something in an html in the jar
- see it's signature is not valid anymore
jarsigner -verify DynamicTreeDemo.jar
- however it runs without any problem via
java -jar DynamicTreeDemo.jar
The question is why?
I'd expect it to be invalid at step 4 and would expect a security exception at step 7.