You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by "Richard Liang (JIRA)" <ji...@apache.org> on 2006/03/17 05:33:53 UTC

[jira] Created: (HARMONY-204) java.util.jar.JarFile should throw Security Exception when getInputStream from a jar file in which the content of main attributes in manifest has been tampered

java.util.jar.JarFile should throw Security Exception when getInputStream from a jar file in which the content of main attributes in manifest has been tampered
---------------------------------------------------------------------------------------------------------------------------------------------------------------

         Key: HARMONY-204
         URL: http://issues.apache.org/jira/browse/HARMONY-204
     Project: Harmony
        Type: Bug
  Components: Classlib  
    Reporter: Richard Liang


According to the new feature in JAR File Specification for java 5.0, .SF signature file which verifies the manifest has a new algorithm-Digest-Manifest-Main-Attributes entry which verifies the main attributes of the manifest. If the main attributes are tampered, harmony will not throw security exception while RI 5.0 will.

The followging test case will demonstrate this issue.

public void test_JarFile_Modified_Manifest_EntryAttributes()
			throws IOException {
		JarFile jarFile = null;
              String path = URLDecoder.decode(this.getClass().getResource(".").getPath(),
				"UTF-8");              
		String fileName = path + "/Modified_Manifest_EntryAttributes.jar";
		jarFile = new JarFile(fileName, true);
		JarEntry jarEntry = jarFile.getJarEntry("META-INF/MANIFEST.MF");
		try {
			jarFile.getInputStream(jarEntry);
			fail("should throw Security Excetpion");
		} catch (SecurityException e) {
			// desired
		}		
	}


-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


[jira] Resolved: (HARMONY-204) java.util.jar.JarFile should throw Security Exception when getInputStream from a jar file in which the content of main attributes in manifest has been tampered

Posted by "George Harley (JIRA)" <ji...@apache.org>.
     [ http://issues.apache.org/jira/browse/HARMONY-204?page=all ]
     
George Harley resolved HARMONY-204:
-----------------------------------

    Resolution: Fixed

Hi Richard, 

Updated patch fixes the exceptions seen yesterday, thanks. New tests pass against both the latest Harmony and the 5.0 RI.  

Changes committed in SVN revision 391283. Please could you verify that these have been applied as expected. 

Many thanks, 
George

> java.util.jar.JarFile should throw Security Exception when getInputStream from a jar file in which the content of main attributes in manifest has been tampered
> ---------------------------------------------------------------------------------------------------------------------------------------------------------------
>
>          Key: HARMONY-204
>          URL: http://issues.apache.org/jira/browse/HARMONY-204
>      Project: Harmony
>         Type: Bug

>   Components: Classlib
>     Reporter: Richard Liang
>     Assignee: George Harley
>  Attachments: Modified_Manifest_MainAttributes.jar, harmony204.updated.zip, harmony204.zip
>
> According to the new feature in JAR File Specification for java 5.0, .SF signature file which verifies the manifest has a new algorithm-Digest-Manifest-Main-Attributes entry which verifies the main attributes of the manifest. If the main attributes are tampered, harmony will not throw security exception while RI 5.0 will.
> The followging test case will demonstrate this issue.
> public void test_JarFile_Modified_Manifest_EntryAttributes()
> 			throws IOException {
> 		JarFile jarFile = null;
>               String path = URLDecoder.decode(this.getClass().getResource(".").getPath(),
> 				"UTF-8");              
> 		String fileName = path + "/Modified_Manifest_EntryAttributes.jar";
> 		jarFile = new JarFile(fileName, true);
> 		JarEntry jarEntry = jarFile.getJarEntry("META-INF/MANIFEST.MF");
> 		try {
> 			jarFile.getInputStream(jarEntry);
> 			fail("should throw Security Excetpion");
> 		} catch (SecurityException e) {
> 			// desired
> 		}		
> 	}

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


[jira] Closed: (HARMONY-204) java.util.jar.JarFile should throw Security Exception when getInputStream from a jar file in which the content of main attributes in manifest has been tampered

Posted by "George Harley (JIRA)" <ji...@apache.org>.
     [ http://issues.apache.org/jira/browse/HARMONY-204?page=all ]
     
George Harley closed HARMONY-204:
---------------------------------


Verified by Richard. 

> java.util.jar.JarFile should throw Security Exception when getInputStream from a jar file in which the content of main attributes in manifest has been tampered
> ---------------------------------------------------------------------------------------------------------------------------------------------------------------
>
>          Key: HARMONY-204
>          URL: http://issues.apache.org/jira/browse/HARMONY-204
>      Project: Harmony
>         Type: Bug

>   Components: Classlib
>     Reporter: Richard Liang
>     Assignee: George Harley
>  Attachments: Modified_Manifest_MainAttributes.jar, harmony204.updated.zip, harmony204.zip
>
> According to the new feature in JAR File Specification for java 5.0, .SF signature file which verifies the manifest has a new algorithm-Digest-Manifest-Main-Attributes entry which verifies the main attributes of the manifest. If the main attributes are tampered, harmony will not throw security exception while RI 5.0 will.
> The followging test case will demonstrate this issue.
> public void test_JarFile_Modified_Manifest_EntryAttributes()
> 			throws IOException {
> 		JarFile jarFile = null;
>               String path = URLDecoder.decode(this.getClass().getResource(".").getPath(),
> 				"UTF-8");              
> 		String fileName = path + "/Modified_Manifest_EntryAttributes.jar";
> 		jarFile = new JarFile(fileName, true);
> 		JarEntry jarEntry = jarFile.getJarEntry("META-INF/MANIFEST.MF");
> 		try {
> 			jarFile.getInputStream(jarEntry);
> 			fail("should throw Security Excetpion");
> 		} catch (SecurityException e) {
> 			// desired
> 		}		
> 	}

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


[jira] Updated: (HARMONY-204) java.util.jar.JarFile should throw Security Exception when getInputStream from a jar file in which the content of main attributes in manifest has been tampered

Posted by "Richard Liang (JIRA)" <ji...@apache.org>.
     [ http://issues.apache.org/jira/browse/HARMONY-204?page=all ]

Richard Liang updated HARMONY-204:
----------------------------------

    Attachment: harmony204.zip

Hello Tim,

Here is the patch (test case and implementation) for this issue. 
Please unzip harmony204.zip to modules/archive/ and execute the shell script 01.harmony204.sh.

Thanks a lot.

> java.util.jar.JarFile should throw Security Exception when getInputStream from a jar file in which the content of main attributes in manifest has been tampered
> ---------------------------------------------------------------------------------------------------------------------------------------------------------------
>
>          Key: HARMONY-204
>          URL: http://issues.apache.org/jira/browse/HARMONY-204
>      Project: Harmony
>         Type: Bug
>   Components: Classlib
>     Reporter: Richard Liang
>  Attachments: Modified_Manifest_MainAttributes.jar, harmony204.zip
>
> According to the new feature in JAR File Specification for java 5.0, .SF signature file which verifies the manifest has a new algorithm-Digest-Manifest-Main-Attributes entry which verifies the main attributes of the manifest. If the main attributes are tampered, harmony will not throw security exception while RI 5.0 will.
> The followging test case will demonstrate this issue.
> public void test_JarFile_Modified_Manifest_EntryAttributes()
> 			throws IOException {
> 		JarFile jarFile = null;
>               String path = URLDecoder.decode(this.getClass().getResource(".").getPath(),
> 				"UTF-8");              
> 		String fileName = path + "/Modified_Manifest_EntryAttributes.jar";
> 		jarFile = new JarFile(fileName, true);
> 		JarEntry jarEntry = jarFile.getJarEntry("META-INF/MANIFEST.MF");
> 		try {
> 			jarFile.getInputStream(jarEntry);
> 			fail("should throw Security Excetpion");
> 		} catch (SecurityException e) {
> 			// desired
> 		}		
> 	}

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


[jira] Commented: (HARMONY-204) java.util.jar.JarFile should throw Security Exception when getInputStream from a jar file in which the content of main attributes in manifest has been tampered

Posted by "Richard Liang (JIRA)" <ji...@apache.org>.
    [ http://issues.apache.org/jira/browse/HARMONY-204?page=comments#action_12370784 ] 

Richard Liang commented on HARMONY-204:
---------------------------------------

I will try to attach the patch for implementation and full test cases soon.

> java.util.jar.JarFile should throw Security Exception when getInputStream from a jar file in which the content of main attributes in manifest has been tampered
> ---------------------------------------------------------------------------------------------------------------------------------------------------------------
>
>          Key: HARMONY-204
>          URL: http://issues.apache.org/jira/browse/HARMONY-204
>      Project: Harmony
>         Type: Bug
>   Components: Classlib
>     Reporter: Richard Liang
>  Attachments: Modified_Manifest_MainAttributes.jar
>
> According to the new feature in JAR File Specification for java 5.0, .SF signature file which verifies the manifest has a new algorithm-Digest-Manifest-Main-Attributes entry which verifies the main attributes of the manifest. If the main attributes are tampered, harmony will not throw security exception while RI 5.0 will.
> The followging test case will demonstrate this issue.
> public void test_JarFile_Modified_Manifest_EntryAttributes()
> 			throws IOException {
> 		JarFile jarFile = null;
>               String path = URLDecoder.decode(this.getClass().getResource(".").getPath(),
> 				"UTF-8");              
> 		String fileName = path + "/Modified_Manifest_EntryAttributes.jar";
> 		jarFile = new JarFile(fileName, true);
> 		JarEntry jarEntry = jarFile.getJarEntry("META-INF/MANIFEST.MF");
> 		try {
> 			jarFile.getInputStream(jarEntry);
> 			fail("should throw Security Excetpion");
> 		} catch (SecurityException e) {
> 			// desired
> 		}		
> 	}

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


[jira] Updated: (HARMONY-204) java.util.jar.JarFile should throw Security Exception when getInputStream from a jar file in which the content of main attributes in manifest has been tampered

Posted by "Richard Liang (JIRA)" <ji...@apache.org>.
     [ http://issues.apache.org/jira/browse/HARMONY-204?page=all ]

Richard Liang updated HARMONY-204:
----------------------------------

    Attachment: Modified_Manifest_MainAttributes.jar

Here is the test data file which must be put in the same location of the class file of the test case.

> java.util.jar.JarFile should throw Security Exception when getInputStream from a jar file in which the content of main attributes in manifest has been tampered
> ---------------------------------------------------------------------------------------------------------------------------------------------------------------
>
>          Key: HARMONY-204
>          URL: http://issues.apache.org/jira/browse/HARMONY-204
>      Project: Harmony
>         Type: Bug
>   Components: Classlib
>     Reporter: Richard Liang
>  Attachments: Modified_Manifest_MainAttributes.jar
>
> According to the new feature in JAR File Specification for java 5.0, .SF signature file which verifies the manifest has a new algorithm-Digest-Manifest-Main-Attributes entry which verifies the main attributes of the manifest. If the main attributes are tampered, harmony will not throw security exception while RI 5.0 will.
> The followging test case will demonstrate this issue.
> public void test_JarFile_Modified_Manifest_EntryAttributes()
> 			throws IOException {
> 		JarFile jarFile = null;
>               String path = URLDecoder.decode(this.getClass().getResource(".").getPath(),
> 				"UTF-8");              
> 		String fileName = path + "/Modified_Manifest_EntryAttributes.jar";
> 		jarFile = new JarFile(fileName, true);
> 		JarEntry jarEntry = jarFile.getJarEntry("META-INF/MANIFEST.MF");
> 		try {
> 			jarFile.getInputStream(jarEntry);
> 			fail("should throw Security Excetpion");
> 		} catch (SecurityException e) {
> 			// desired
> 		}		
> 	}

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


[jira] Commented: (HARMONY-204) java.util.jar.JarFile should throw Security Exception when getInputStream from a jar file in which the content of main attributes in manifest has been tampered

Posted by "George Harley (JIRA)" <ji...@apache.org>.
    [ http://issues.apache.org/jira/browse/HARMONY-204?page=comments#action_12373027 ] 

George Harley commented on HARMONY-204:
---------------------------------------

Hi Richard, 

I've added the new test cases and resources in my local sandbox but see two errors when I run the tests. 

(a) test_JarFile_InsertEntry_in_Manifest_Jar
java.lang.SecurityException: Inserted_Entry_Manifest.jar failed verification of META-INF/TESTROOT.SF
	at java.util.jar.JarVerifier.verifyCertificate(JarVerifier.java:323)
	at java.util.jar.JarVerifier.readCertificates(JarVerifier.java:247)
	at java.util.jar.JarFile.getInputStream(JarFile.java:329)
	at tests.api.java.util.jar.JarFileTest.test_JarFile_InsertEntry_in_Manifest_Jar(JarFileTest.java:432)
	at java.lang.reflect.AccessibleObject.invokeV(AccessibleObject.java:211)
	at tests.util.SomeTests.basicRun(SomeTests.java:104)
	at junit.extensions.TestSetup$1.protect(TestSetup.java:19)
	at junit.extensions.TestSetup.run(TestSetup.java:23)


(b) test_Inserted_Entry_Manifest_with_DigestCode
java.lang.SecurityException: Inserted_Entry_Manifest_with_DigestCode.jar failed verification of META-INF/TESTROOT.SF
	at java.util.jar.JarVerifier.verifyCertificate(JarVerifier.java:323)
	at java.util.jar.JarVerifier.readCertificates(JarVerifier.java:247)
	at java.util.jar.JarFile.getInputStream(JarFile.java:329)
	at tests.api.java.util.jar.JarFileTest.test_Inserted_Entry_Manifest_with_DigestCode(JarFileTest.java:453)
	at java.lang.reflect.AccessibleObject.invokeV(AccessibleObject.java:211)
	at tests.util.SomeTests.basicRun(SomeTests.java:104)
	at junit.extensions.TestSetup$1.protect(TestSetup.java:19)
	at junit.extensions.TestSetup.run(TestSetup.java:23)


Can you please investigate ? I will look into this further tomorrow but alas I am out of time today. 

Best regards, 
George



> java.util.jar.JarFile should throw Security Exception when getInputStream from a jar file in which the content of main attributes in manifest has been tampered
> ---------------------------------------------------------------------------------------------------------------------------------------------------------------
>
>          Key: HARMONY-204
>          URL: http://issues.apache.org/jira/browse/HARMONY-204
>      Project: Harmony
>         Type: Bug

>   Components: Classlib
>     Reporter: Richard Liang
>  Attachments: Modified_Manifest_MainAttributes.jar, harmony204.zip
>
> According to the new feature in JAR File Specification for java 5.0, .SF signature file which verifies the manifest has a new algorithm-Digest-Manifest-Main-Attributes entry which verifies the main attributes of the manifest. If the main attributes are tampered, harmony will not throw security exception while RI 5.0 will.
> The followging test case will demonstrate this issue.
> public void test_JarFile_Modified_Manifest_EntryAttributes()
> 			throws IOException {
> 		JarFile jarFile = null;
>               String path = URLDecoder.decode(this.getClass().getResource(".").getPath(),
> 				"UTF-8");              
> 		String fileName = path + "/Modified_Manifest_EntryAttributes.jar";
> 		jarFile = new JarFile(fileName, true);
> 		JarEntry jarEntry = jarFile.getJarEntry("META-INF/MANIFEST.MF");
> 		try {
> 			jarFile.getInputStream(jarEntry);
> 			fail("should throw Security Excetpion");
> 		} catch (SecurityException e) {
> 			// desired
> 		}		
> 	}

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


[jira] Assigned: (HARMONY-204) java.util.jar.JarFile should throw Security Exception when getInputStream from a jar file in which the content of main attributes in manifest has been tampered

Posted by "George Harley (JIRA)" <ji...@apache.org>.
     [ http://issues.apache.org/jira/browse/HARMONY-204?page=all ]

George Harley reassigned HARMONY-204:
-------------------------------------

    Assign To: George Harley

> java.util.jar.JarFile should throw Security Exception when getInputStream from a jar file in which the content of main attributes in manifest has been tampered
> ---------------------------------------------------------------------------------------------------------------------------------------------------------------
>
>          Key: HARMONY-204
>          URL: http://issues.apache.org/jira/browse/HARMONY-204
>      Project: Harmony
>         Type: Bug

>   Components: Classlib
>     Reporter: Richard Liang
>     Assignee: George Harley
>  Attachments: Modified_Manifest_MainAttributes.jar, harmony204.zip
>
> According to the new feature in JAR File Specification for java 5.0, .SF signature file which verifies the manifest has a new algorithm-Digest-Manifest-Main-Attributes entry which verifies the main attributes of the manifest. If the main attributes are tampered, harmony will not throw security exception while RI 5.0 will.
> The followging test case will demonstrate this issue.
> public void test_JarFile_Modified_Manifest_EntryAttributes()
> 			throws IOException {
> 		JarFile jarFile = null;
>               String path = URLDecoder.decode(this.getClass().getResource(".").getPath(),
> 				"UTF-8");              
> 		String fileName = path + "/Modified_Manifest_EntryAttributes.jar";
> 		jarFile = new JarFile(fileName, true);
> 		JarEntry jarEntry = jarFile.getJarEntry("META-INF/MANIFEST.MF");
> 		try {
> 			jarFile.getInputStream(jarEntry);
> 			fail("should throw Security Excetpion");
> 		} catch (SecurityException e) {
> 			// desired
> 		}		
> 	}

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


[jira] Commented: (HARMONY-204) java.util.jar.JarFile should throw Security Exception when getInputStream from a jar file in which the content of main attributes in manifest has been tampered

Posted by "Richard Liang (JIRA)" <ji...@apache.org>.
    [ http://issues.apache.org/jira/browse/HARMONY-204?page=comments#action_12373084 ] 

Richard Liang commented on HARMONY-204:
---------------------------------------

Hello George, 

The fix looks good. Please close this issue. :-)  Thanks a lot.

> java.util.jar.JarFile should throw Security Exception when getInputStream from a jar file in which the content of main attributes in manifest has been tampered
> ---------------------------------------------------------------------------------------------------------------------------------------------------------------
>
>          Key: HARMONY-204
>          URL: http://issues.apache.org/jira/browse/HARMONY-204
>      Project: Harmony
>         Type: Bug

>   Components: Classlib
>     Reporter: Richard Liang
>     Assignee: George Harley
>  Attachments: Modified_Manifest_MainAttributes.jar, harmony204.updated.zip, harmony204.zip
>
> According to the new feature in JAR File Specification for java 5.0, .SF signature file which verifies the manifest has a new algorithm-Digest-Manifest-Main-Attributes entry which verifies the main attributes of the manifest. If the main attributes are tampered, harmony will not throw security exception while RI 5.0 will.
> The followging test case will demonstrate this issue.
> public void test_JarFile_Modified_Manifest_EntryAttributes()
> 			throws IOException {
> 		JarFile jarFile = null;
>               String path = URLDecoder.decode(this.getClass().getResource(".").getPath(),
> 				"UTF-8");              
> 		String fileName = path + "/Modified_Manifest_EntryAttributes.jar";
> 		jarFile = new JarFile(fileName, true);
> 		JarEntry jarEntry = jarFile.getJarEntry("META-INF/MANIFEST.MF");
> 		try {
> 			jarFile.getInputStream(jarEntry);
> 			fail("should throw Security Excetpion");
> 		} catch (SecurityException e) {
> 			// desired
> 		}		
> 	}

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


[jira] Updated: (HARMONY-204) java.util.jar.JarFile should throw Security Exception when getInputStream from a jar file in which the content of main attributes in manifest has been tampered

Posted by "Richard Liang (JIRA)" <ji...@apache.org>.
     [ http://issues.apache.org/jira/browse/HARMONY-204?page=all ]

Richard Liang updated HARMONY-204:
----------------------------------

    Attachment: harmony204.updated.zip

Sorry, George. There are something wrong in my previous patch. :-)

Would you please try to my new patch: harmony204.updated.zip? Thanks a lot.

> java.util.jar.JarFile should throw Security Exception when getInputStream from a jar file in which the content of main attributes in manifest has been tampered
> ---------------------------------------------------------------------------------------------------------------------------------------------------------------
>
>          Key: HARMONY-204
>          URL: http://issues.apache.org/jira/browse/HARMONY-204
>      Project: Harmony
>         Type: Bug

>   Components: Classlib
>     Reporter: Richard Liang
>     Assignee: George Harley
>  Attachments: Modified_Manifest_MainAttributes.jar, harmony204.updated.zip, harmony204.zip
>
> According to the new feature in JAR File Specification for java 5.0, .SF signature file which verifies the manifest has a new algorithm-Digest-Manifest-Main-Attributes entry which verifies the main attributes of the manifest. If the main attributes are tampered, harmony will not throw security exception while RI 5.0 will.
> The followging test case will demonstrate this issue.
> public void test_JarFile_Modified_Manifest_EntryAttributes()
> 			throws IOException {
> 		JarFile jarFile = null;
>               String path = URLDecoder.decode(this.getClass().getResource(".").getPath(),
> 				"UTF-8");              
> 		String fileName = path + "/Modified_Manifest_EntryAttributes.jar";
> 		jarFile = new JarFile(fileName, true);
> 		JarEntry jarEntry = jarFile.getJarEntry("META-INF/MANIFEST.MF");
> 		try {
> 			jarFile.getInputStream(jarEntry);
> 			fail("should throw Security Excetpion");
> 		} catch (SecurityException e) {
> 			// desired
> 		}		
> 	}

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira