[[Category:FIXME|This is the text from the old template. This needs to be rewritten using the new template.]]

+

[[ASDR_TOC_Vulnerabilities|Vulnerabilities Table of Contents]]

−

+

−

+

==Description==

==Description==

−

Improper use of the Java Native Interface (JNI) can render Java applications vulnerable to security flaws in other languages.

Improper use of the Java Native Interface (JNI) can render Java applications vulnerable to security flaws in other languages.

Line 22:

Line 13:

==Risk Factors==

==Risk Factors==

−

TBD

TBD

==Examples==

==Examples==

−

The following Java code defines a class named Echo. The class declares one native method (defined below), which uses C to echo commands entered on the console back to the user.

The following Java code defines a class named Echo. The class declares one native method (defined below), which uses C to echo commands entered on the console back to the user.

Line 64:

Line 53:

The Sun Java(TM) Tutorial provides the following description of JNI [2]:

The Sun Java(TM) Tutorial provides the following description of JNI [2]:

−

<pre>

+

''The JNI framework lets your native method utilize Java objects in the same way that Java code uses these objects. A native method can create Java objects, including arrays and strings, and then inspect and use these objects to perform its tasks. A native method can also inspect and use objects created by Java application code. A native method can even update Java objects that it created or that were passed to it, and these updated objects are available to the Java application. Thus, both the native language side and the Java side of an application can create, update, and access Java objects and then share these objects between them.''

−

+

−

The JNI framework lets your native method utilize Java objects in the same way that Java code

+

−

uses these objects. A native method can create Java objects, including arrays and strings, and

+

−

then inspect and use these objects to perform its tasks. A native method can also inspect and

+

−

use objects created by Java application code. A native method can even update Java objects that

+

−

it created or that were passed to it, and these updated objects are available to the Java

+

−

application. Thus, both the native language side and the Java side of an application can

+

−

create, update, and access Java objects and then share these objects between them.

+

−

</pre>

+

The vulnerability in the example above could easily be detected through a source code audit of the native method implementation. This may not be practical or possible depending on the availability of the C source code and the way the project is built, but in many cases it may suffice. However, the ability to share objects between Java and native methods expands the potential risk to much more insidious cases where improper data handling in Java may lead to unexpected vulnerabilities in native code or unsafe operations in native code corrupt data structures in Java.

The vulnerability in the example above could easily be detected through a source code audit of the native method implementation. This may not be practical or possible depending on the availability of the C source code and the way the project is built, but in many cases it may suffice. However, the ability to share objects between Java and native methods expands the potential risk to much more insidious cases where improper data handling in Java may lead to unexpected vulnerabilities in native code or unsafe operations in native code corrupt data structures in Java.

−

Vulnerabilities in native code accessed through a Java application are typically exploited in the same manner as they are in applications written in the native language. The only challenge to such an attack is for the attacker to identify that the Java application uses native code to perform certain operations. This can be accomplished in a variety of ways, including identifying specific behaviors that are often implemented with native code or by exploiting a system information leak in the Java application that exposes its use of JNI [2].

+

Vulnerabilities in native code accessed through a Java application are typically exploited in the same manner as they are in applications written in the native language. The only challenge to such an attack is for the attacker to identify that the Java application uses native code to perform certain operations. This can be accomplished in a variety of ways, including identifying specific behaviors that are often implemented with native code or by exploiting a system information leak in the Java application that exposes its use of JNI [2].

==Related [[Attacks]]==

==Related [[Attacks]]==

Line 93:

Line 73:

==Related [[Controls]]==

==Related [[Controls]]==

−

* [[[:Category:Input Validation]]

+

* [[:Category:Input Validation]]

−

+

==Related [[Technical Impacts]]==

==Related [[Technical Impacts]]==

Line 107:

Line 86:

* [2] Fortify Descriptions. http://vulncat.fortifysoftware.com.

* [2] Fortify Descriptions. http://vulncat.fortifysoftware.com.

+

[[Category:FIXME|The first link works, but the page says the content is going to be removed at some point. Need to change link]]

Because the example is implemented in Java, it may appear that it is immune to memory issues like buffer overflow vulnerabilities. Although Java does do a good job of making memory operations safe, this protection does not extend to vulnerabilities occurring in source code written in other languages that are accessed using the Java Native Interface. Despite the memory protections offered in Java, the C code in this example is vulnerable to a buffer overflow because it makes use of gets(), which does not perform any bounds checking on its input.

The Sun Java(TM) Tutorial provides the following description of JNI [2]:

The JNI framework lets your native method utilize Java objects in the same way that Java code uses these objects. A native method can create Java objects, including arrays and strings, and then inspect and use these objects to perform its tasks. A native method can also inspect and use objects created by Java application code. A native method can even update Java objects that it created or that were passed to it, and these updated objects are available to the Java application. Thus, both the native language side and the Java side of an application can create, update, and access Java objects and then share these objects between them.

The vulnerability in the example above could easily be detected through a source code audit of the native method implementation. This may not be practical or possible depending on the availability of the C source code and the way the project is built, but in many cases it may suffice. However, the ability to share objects between Java and native methods expands the potential risk to much more insidious cases where improper data handling in Java may lead to unexpected vulnerabilities in native code or unsafe operations in native code corrupt data structures in Java.

Vulnerabilities in native code accessed through a Java application are typically exploited in the same manner as they are in applications written in the native language. The only challenge to such an attack is for the attacker to identify that the Java application uses native code to perform certain operations. This can be accomplished in a variety of ways, including identifying specific behaviors that are often implemented with native code or by exploiting a system information leak in the Java application that exposes its use of JNI [2].