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.)
Use of Low-Level Functionality
This vulnerability occurs when code bypasses high-level framework controls by directly using low-level system functions, violating the intended security model.
What is CWE-695?
Real-world CVEs caused by CWE-695
No public CVE references are linked to this CWE in MITRE's catalog yet.
Step-by-step attacker path
- 1
The following 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 C code defines the native method implemented in the Echo class:
- 2
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 check the length of its input.
- 3
The Sun Java(TM) Tutorial provides the following description of JNI [See Reference]: 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.
- 4
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 exposure in the Java application that reveals its use of JNI [See Reference].
- 5
The following example opens a socket to connect to a remote server.
Vulnerable Java
The following 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 C code defines the native method implemented in the Echo class:
class Echo {
public native void runEcho();
static {
System.loadLibrary("echo");
}
public static void main(String[] args) {
new Echo().runEcho();
}
} Secure pseudo
// Validate, sanitize, or use a safe API before reaching the sink.
function handleRequest(input) {
const safe = validateAndEscape(input);
return executeWithGuards(safe);
} How to prevent CWE-695
- Architecture Use safe-by-default frameworks and APIs that prevent the unsafe pattern from being expressible.
- Implementation Validate input at trust boundaries; use allowlists, not denylists.
- Implementation Apply the principle of least privilege to credentials, file paths, and runtime permissions.
- Testing Cover this weakness in CI: SAST rules + targeted unit tests for the data flow.
- Operation Monitor logs for the runtime signals listed in the next section.
How to detect CWE-695
Plexicus auto-detects CWE-695 and opens a fix PR in under 60 seconds.
Codex Remedium scans every commit, identifies this exact weakness, and ships a reviewer-ready pull request with the patch. No tickets. No hand-offs.
Frequently asked questions
What is CWE-695?
This vulnerability occurs when code bypasses high-level framework controls by directly using low-level system functions, violating the intended security model.
How serious is CWE-695?
MITRE has not published a likelihood-of-exploit rating for this weakness. Treat it as medium-impact until your threat model proves otherwise.
What languages or platforms are affected by CWE-695?
MITRE has not specified affected platforms for this CWE — it can apply across most application stacks.
How can I prevent CWE-695?
Use safe-by-default frameworks, validate untrusted input at trust boundaries, and apply the principle of least privilege. Cover the data-flow signature in CI with SAST.
How does Plexicus detect and fix CWE-695?
Plexicus's SAST engine matches the data-flow signature for CWE-695 on every commit. When a match is found, our Codex Remedium agent opens a fix PR with the corrected code, tests, and a one-line summary for the reviewer.
Where can I learn more about CWE-695?
MITRE publishes the canonical definition at https://cwe.mitre.org/data/definitions/695.html. You can also reference OWASP and NIST documentation for adjacent guidance.
Weaknesses related to CWE-695
Improper Following of Specification by Caller
This weakness occurs when software fails to properly follow the documented rules, protocols, or requirements of an external component it…
Struts: Incomplete validate() Method Definition
This vulnerability occurs in a Struts application when a validator form either completely omits a validate() method or includes one but…
Struts: Form Bean Does Not Extend Validation Class
This vulnerability occurs in Apache Struts applications when a form bean class does not properly extend the framework's validation class.…
Creation of chroot Jail Without Changing Working Directory
This vulnerability occurs when a program creates a chroot jail but fails to change its current working directory afterward. Because the…
Incorrect Check of Function Return Value
This vulnerability occurs when a program misinterprets or improperly validates the return value from a function, causing it to miss…
Improper Following of a Certificate's Chain of Trust
This vulnerability occurs when software fails to properly validate the entire certificate chain back to a trusted root authority. This…
Missing Critical Step in Authentication
This vulnerability occurs when a software authentication process omits a required step, weakening its overall security.
Missing Cryptographic Step
This vulnerability occurs when a software implementation skips a critical step in a cryptographic process, resulting in security that is…
Generation of Predictable IV with CBC Mode
This vulnerability occurs when software uses a predictable or reused Initialization Vector (IV) with Cipher Block Chaining (CBC) mode…
Don't Let Security
Weigh You Down.
Stop choosing between AI velocity and security debt. Plexicus is the only platform that runs Vibe Coding Security and ASPM in parallel — one workflow, every codebase.