267
Many safety features that programmers may take for granted do not apply for native code, so you
must carefully review all such code for potential problems. The languages used to implement native
code may be more susceptible to buffer overflows and other attacks. Native code is unprotected by
the security features enforced by the runtime environment, such as strong typing and array bounds
checking.
Relationships
The table(s) below shows the weaknesses and high level categories that are related to this
weakness. These relationships are defined as ChildOf, ParentOf, MemberOr and give insight to
similar items that may exist at higher and lower levels of abstraction. In addition, relationships such
as PeerOf and CanAlsoBe are defined to show similar weaknesses that may want to be explored.
Relevant to the view "Research Concepts" (CWE-1000)
Nature Type ID Name Page
ChildOf 695 Use of Low-Level Functionality 1524
Relevant to the view "Seven Pernicious Kingdoms" (CWE-700)
Nature Type ID Name Page
ChildOf 20 Improper Input Validation 20
Weakness Ordinalities
Primary :
Applicable Platforms
Language : Java (Prevalence = Undetermined)
Common Consequences
Scope Impact Likelihood
Access Control Bypass Protection Mechanism
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.)
Effectiveness = High
Potential Mitigations
Phase: Implementation
Implement error handling around the JNI call.
Phase: Implementation
Strategy = Refactoring
Do not use JNI calls if you don't trust the native library.
Phase: Implementation
Strategy = Refactoring
Be reluctant to use JNI calls. A Java API equivalent may exist.
Demonstrative Examples
Example 1:
CWE Version 4.14
CWE-111: Direct Use of Unsafe JNI
CWE-111: Direct Use of Unsafe JNI