Versions Compared

Key

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

...

Wiki Markup
Improper use of public static fields can also result in type-safety issues. For example, untrusted code can supply an unexpected subtype with malicious methods when the variable is defined to be of a more general type, such as {{java.lang.Object}} \[[Gong 2003|AA. Bibliography#Gong 03]\]. As a result, classes must not contain nonfinal public static fields.

...

Replacing the function table gives the attacker access to XPathContext, which is used to set the reference node for evaluating XPath expressions. Manipulating XPathContext can cause XML fields to be modified in inconsistent ways, resulting in unexpected behavior. Also, because static variables are global across the Java Runtime Environment (JRE), they can be used as a covert communication channel between different application domains (for example, through code loaded by different class loaders).

Note that this This vulnerability was repaired in JDK v1.4.2_05.

...

Code Block
bgColor#ccccff
public static final FuncLoader m_functions;
// Initialize m_functions in a constructor

Fields declared static and final are also safe for multithreaded use. (See rule [TSM03-J. Do not publish partially initialized objects for more information.) However, remember that simply changing the modifier to final might not prevent attackers from indirectly retrieving an incorrect value from the static final variable before its initialization. (See rule DCL00-J. Prevent class initialization cycles for more information.) Furthermore, individual members of the referenced object can also be changed if the object itself is mutable.

...

Noncompliant Code Example (serialVersionUID)

This noncompliant code example uses a public static nonfinal serialVersionUID field in a class designed for serialization.

...

This compliant solution declares the serialVersionUID field final and limits its accessibility to private.

Code Block
bgColor#ccccff
class DataSerializer implements Serializable {
  private static final long serialVersionUID = 1973473122623778747L;
}

...

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="186b57123e2bc6a2-9878cf52-465348c4-92438ae0-cad37f0010fb260f1433b17f"><ac:plain-text-body><![CDATA[

[[FT 2008

AA. Bibliography#FT 08]]

Function Table, Class Function Table

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

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="d85e1173e0485498-8141baf8-44b8434b-958a9fdd-02c8ab20fd88e299afc0656a"><ac:plain-text-body><![CDATA[

[[Gong 2003

AA. Bibliography#Gong 03]]

9.3, Static Fields

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

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="d7a7e77585295505-faa13277-4018453e-bcf6985c-6d577e363e0d42aa454e9b20"><ac:plain-text-body><![CDATA[

[[Nisewanger 2007

AA. Bibliography#Nisewanger 07]]

Antipattern 5, Misusing Public Static Variables

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

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="b8d3f4e81d6dc93f-33ffc3ca-4462466a-b621b781-6566b9a73f315ed597cdd537"><ac:plain-text-body><![CDATA[

[[Sterbenz 2006

AA. Bibliography#Sterbenz 06]]

Antipattern 5, Misusing Public Static Variables

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

...