Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Wiki Markup
[CVE-2008-5353 |http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2008-5353] describes a Java vulnerability, discovered in August 2008 by Sami Koivu \[[CVE|AA. Bibliography#CVE]\]. Julien Tinnes subsequently wrote an exploit that allowed arbitrary code execution on multiple platforms that ran vulnerable versions of Java. The problem resulted from deserializing untrusted input from within a privileged context. The vulnerability involves the ({{sun.util.Calendar.Zoneinfo}}) object, which being a serializable class, is deserialized by the {{readObject()}} method of the {{ObjectInputStream}} class.

The default security model of an applet does not allow access to sun.util.calendar.ZoneInfo because all classes within the sun package are treated as untrusted. As a result, prior to JDK 1.6 u11, the acceptable method for an unsigned applet to deserialize a Zoneinfo object was to execute the call from a privileged context, such as a doPrivileged block. This constitutes a vulnerability because there is no guaranteed method of knowing whether the serialized stream contains a Zoneinfo object and not a malicious serializable class. The vulnerable code casts the malicious object to the ZoneInfo type, which typically causes a ClassCastException if the actual deserialized class is not a ZoneInfo. This exception, however, is of little consequence as because it is possible to store a reference to the newly created object in some static context so that the garbage collector does not act upon it.

A non-serializable class can be extended and its subclass can be made serializable. Also, a subclass automatically becomes serializable if it derives from a serializable class. During deserialization of the subclass, the JVM calls the no-argument constructor of the most derived superclass that does not implement java.io.Serializable either directly or indirectly. This allows it to fix the state of this superclass. In the following code snippet, class A's no-argument constructor is called when C is deserialized because A does not implement Serializable. Subsequently, Object's constructor is invoked. This procedure cannot be carried out programmatically, consequently so the JVM generates the equivalent bytecode at runtime. Typically, when the superclass's constructor is called by a subclass, the subclass remains on the stack. However, in deserialization this does not happen. Only the unvalidated bytecode is present. This allows any security checks within the superclass's constructor to be bypassed in that the complete execution chain is not scrutinized.

...

At this point, there is no subclass code on the stack and the superclass's constructor is executed with no restrictions as because doPrivileged() allows the immediate caller to exert its full privileges. Because the immediate caller java.util.Calendar is trusted, it exhibits full system privileges.

A custom class loader can be used to exploit this vulnerability. Instantiating a class loader object requires special permissions that are made available by the security policy that is enforced by the SecurityManager. An unsigned applet cannot carry out this step by default. If an unsigned applet can execute a custom class loader's constructor, it can effectively bypass all the security checks (it has the requisite privileges as a direct consequence of the vulnerability). A custom class loader can be designed to extend the System Class Loader, undermine security, and carry out prohibited actions such as reading or deleting files on the user's file system. Moreover, any legitimate security checks in the constructor are meaningless as because the code is granted all privileges.

...

Related Guidelines

MITRE CWE

CWE ID -250, "Execution with Unnecessary Privileges"

...

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="bff771d06dd79262-bf0897d8-4a284b50-bc818642-2c9a55dceee416a2d962d9ab"><ac:plain-text-body><![CDATA[

[[API 2006

AA. Bibliography#API 06]]

 

]]></ac:plain-text-body></ac:structured-macro>

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="0e26c76767110965-c6a86e17-41524828-ad2eb47b-eeb812d85253ce7ca999c8ad"><ac:plain-text-body><![CDATA[

[[CVE

AA. Bibliography#CVE]]

[CVE-2008-5353

http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2008-5353]

]]></ac:plain-text-body></ac:structured-macro>

...