CWEweakness

CWE-111 Direct Use of Unsafe JNI

Official page ↗
Abstraction
Variant
Structure
Simple
Status
Draft
Languages
Java
CWE version
5.0

Description

When a Java application uses the Java Native Interface (JNI) to call code written in another programming language, it can expose the application to weaknesses in that code, even if those weaknesses cannot occur in Java.

Common consequences

• Access Control: Bypass Protection Mechanism

Potential mitigations

• [Implementation] Implement error handling around the JNI call. • [Implementation] Do not use JNI calls if the native library can't be trusted. • [Implementation] Be reluctant to use JNI calls. A Java API equivalent may exist.

Detection methods

• Automated Static Analysis: Automated static analysis, commonly referred to as Static Application Security Testing (SAST), can find some instances of this weakness by analyzing source code (or binary/compiled code) without having to execute it. Typically, this is done by building a model of data flow and control flow, then searching for potentially-vulnerable patterns that connect "sources" (origins of input) with "sinks" (destinations where the data interacts with external components, a lower layer such as the OS, etc.)

Related

Child of · CWE (2)

  • CWE-20 Improper Input Validation weakness
  • CWE-695 Use of Low-Level Functionality weakness

Referenced by CVE · weakness (2)

  • CVE-2018-12549 In Eclipse OpenJ9 version 0.11.0, the OpenJ9 JIT compiler may incorrectly omit a null check on the receiver object of an Unsafe call when… vulnerability
  • CVE-2016-9160 A vulnerability in SIEMENS SIMATIC WinCC (All versions < SIMATIC WinCC V7.2) and SIEMENS SIMATIC PCS 7 (All versions < SIMATIC PCS 7 V8.0… vulnerability