...
Wiki Markup |
---|
Consider two classes belonging to different protection domains. One of them is malicious whereas the other is trusted. If the malicious class extends the trusted {{public}} non-final class and inherits without overriding a method of the trusted class, the fully qualified invocation of the malicious class's version of the method uses the protection domain of the trusted class. In this case, the trusted class's permissions are examined to execute the method. \[[Gong 03|java:AA. Java References#Gong 03]\]) |
At One suggestion is that at all points that where the class can be instantiated, there must be checks to ensure that the instance being created has the same type as the class. If the type is found to be that of a subclass instead of the non-final public
superclass's type, a security manager check must can be performed to ensure that malicious classes cannot misuse the class. This approach is insecure because it allows a malicious class to add a finalizer and obtain a partially initialized instance of the class (see OBJ04-J. Do not allow partially initialized objects to be accessed). For non-final classes, the method that performs the security manager check must be passed as an argument to a private
constructor so that Object's constructor does not exit before the security check is performed.
The use of reflection is necessary to exploit the non-final class if it has members that are declared private
or are otherwise inaccessible to the attacker. Declaring the class or its methods final
prohibits this level of access.
...