Goal Reached Thanks to every supporter — we hit 100%!

Goal: 1000 CNY · Raised: 1000 CNY

100.0%

CWE-395 (使用NullPointerException捕捉来检测空指针解引用) — Vulnerability Class 2

2 vulnerabilities classified as CWE-395 (使用NullPointerException捕捉来检测空指针解引用). AI Chinese analysis included.

CWE-395 represents a critical design weakness where developers misuse exception handling to detect null pointer dereferences instead of implementing preventive checks. This anti-pattern typically arises when programmers find catching the resulting NullPointerException easier than fixing the underlying logic flaw, or when they explicitly throw the exception to signal errors. Exploitation occurs when an attacker triggers a null reference, causing the application to catch the exception and potentially expose sensitive stack traces, internal logic, or system states. This leakage aids adversaries in mapping application architecture for further attacks. To avoid this vulnerability, developers must enforce strict null checks before dereferencing pointers. By validating object references proactively rather than reacting to failures, code remains robust, secure, and maintains clear separation between normal control flow and error handling, thereby preventing information disclosure and ensuring stable execution.

MITRE CWE Description
Catching NullPointerException should not be used as an alternative to programmatic checks to prevent dereferencing a null pointer. Programmers typically catch NullPointerException under three circumstances: The program contains a null pointer dereference. Catching the resulting exception was easier than fixing the underlying problem. The program explicitly throws a NullPointerException to signal an error condition. The code is part of a test harness that supplies unexpected input to the classes under test. Of these three circumstances, only the last is acceptable.
Common Consequences (1)
AvailabilityDoS: Resource Consumption (CPU)
Mitigations (1)
Architecture and Design, ImplementationDo not extensively rely on catching exceptions (especially for validating user input) to handle errors. Handling exceptions can decrease the performance of an application.
Examples (1)
The following code mistakenly catches a NullPointerException.
try { mysteryMethod(); } catch (NullPointerException npe) { }
Bad · Java
CVE IDTitleCVSSSeverityPublished
CVE-2025-15514 Ollama Multi-Modal Model Image Processing NULL Pointer Dereference — Ollama 7.5AIHighAI2026-01-12
CVE-2022-2832 Blender 代码问题漏洞 — Blender 8.4 -2022-08-16

Vulnerabilities classified as CWE-395 (使用NullPointerException捕捉来检测空指针解引用) represent 2 CVEs. The CWE taxonomy describes the weakness; review individual CVEs for product-specific impact.