Programmers typically catch NullPointerException under three circumstances:
Of these three circumstances, only the last is acceptable.
| Impact | Details |
|---|---|
|
DoS: Resource Consumption (CPU) |
Scope: Availability |
| Phase(s) | Mitigation |
|---|---|
|
Architecture and Design; Implementation |
Do not extensively rely on catching exceptions (especially for validating user input) to handle errors. Handling exceptions can decrease the performance of an application.
|
| Nature | Type | ID | Name |
|---|---|---|---|
| ChildOf | Class Class - a weakness that is described in a very abstract fashion, typically independent of any specific language or technology. More specific than a Pillar Weakness, but more general than a Base Weakness. Class level weaknesses typically describe issues in terms of 1 or 2 of the following dimensions: behavior, property, and resource. | 705 | Incorrect Control Flow Scoping |
| ChildOf | Class Class - a weakness that is described in a very abstract fashion, typically independent of any specific language or technology. More specific than a Pillar Weakness, but more general than a Base Weakness. Class level weaknesses typically describe issues in terms of 1 or 2 of the following dimensions: behavior, property, and resource. | 755 | Improper Handling of Exceptional Conditions |
| Nature | Type | ID | Name |
|---|---|---|---|
| MemberOf | Category Category - a CWE entry that contains a set of other entries that share a common characteristic. | 389 | Error Conditions, Return Values, Status Codes |
| Phase | Note |
|---|---|
| Implementation |
Java (Undetermined Prevalence)
Example 1
The following code mistakenly catches a NullPointerException.
| Method | Details |
|---|---|
|
Automated Static Analysis - Binary or Bytecode |
According to SOAR [REF-1479], the following detection techniques may be useful: Cost effective for partial coverage:
Effectiveness: SOAR Partial |
|
Dynamic Analysis with Manual Results Interpretation |
According to SOAR [REF-1479], the following detection techniques may be useful: Cost effective for partial coverage:
Effectiveness: SOAR Partial |
|
Manual Static Analysis - Source Code |
According to SOAR [REF-1479], the following detection techniques may be useful: Cost effective for partial coverage:
Effectiveness: SOAR Partial |
|
Automated Static Analysis - Source Code |
According to SOAR [REF-1479], the following detection techniques may be useful: Highly cost effective:
Effectiveness: High |
|
Architecture or Design Review |
According to SOAR [REF-1479], the following detection techniques may be useful: Highly cost effective:
Cost effective for partial coverage:
Effectiveness: High |
| Nature | Type | ID | Name |
|---|---|---|---|
| MemberOf | CategoryCategory - a CWE entry that contains a set of other entries that share a common characteristic. | 388 | 7PK - Errors |
| MemberOf | CategoryCategory - a CWE entry that contains a set of other entries that share a common characteristic. | 851 | The CERT Oracle Secure Coding Standard for Java (2011) Chapter 8 - Exceptional Behavior (ERR) |
| MemberOf | CategoryCategory - a CWE entry that contains a set of other entries that share a common characteristic. | 962 | SFP Secondary Cluster: Unchecked Status Condition |
| MemberOf | CategoryCategory - a CWE entry that contains a set of other entries that share a common characteristic. | 1410 | Comprehensive Categorization: Insufficient Control Flow Management |
Rationale
This CWE entry is at the Base level of abstraction, which is a preferred level of abstraction for mapping to the root causes of vulnerabilities.Comments
Carefully read both the name and description to ensure that this mapping is an appropriate fit. Do not try to 'force' a mapping to a lower-level Base/Variant simply to comply with this preferred level of abstraction.| Mapped Taxonomy Name | Node ID | Fit | Mapped Node Name |
|---|---|---|---|
| 7 Pernicious Kingdoms | Catching NullPointerException | ||
| The CERT Oracle Secure Coding Standard for Java (2011) | ERR08-J | Do not catch NullPointerException or any of its ancestors |
| Submissions | |||
|---|---|---|---|
| Submission Date | Submitter | Organization | |
|
2006年07月19日
(CWE Draft 3, 2006年07月19日) |
7 Pernicious Kingdoms | ||
| Modifications | |||
| Modification Date | Modifier | Organization | |
|
2025年09月09日
(CWE 4.18, 2025年09月09日) |
CWE Content Team | MITRE | |
| updated Detection_Factors, References | |||
|
2024年02月29日
(CWE 4.14, 2024年02月29日) |
CWE Content Team | MITRE | |
| updated Demonstrative_Examples | |||
| 2023年06月29日 | CWE Content Team | MITRE | |
| updated Mapping_Notes | |||
| 2023年04月27日 | CWE Content Team | MITRE | |
| updated Relationships | |||
| 2020年02月24日 | CWE Content Team | MITRE | |
| updated References | |||
| 2019年01月03日 | CWE Content Team | MITRE | |
| updated Taxonomy_Mappings | |||
| 2014年07月30日 | CWE Content Team | MITRE | |
| updated Detection_Factors, Relationships | |||
| 2014年06月23日 | CWE Content Team | MITRE | |
| updated Description, Other_Notes | |||
| 2012年10月30日 | CWE Content Team | MITRE | |
| updated Potential_Mitigations | |||
| 2012年05月11日 | CWE Content Team | MITRE | |
| updated Relationships | |||
| 2011年06月01日 | CWE Content Team | MITRE | |
| updated Common_Consequences, Relationships, Taxonomy_Mappings | |||
| 2011年03月29日 | CWE Content Team | MITRE | |
| updated Other_Notes, Relationships | |||
| 2009年05月27日 | CWE Content Team | MITRE | |
| updated Demonstrative_Examples | |||
| 2009年03月10日 | CWE Content Team | MITRE | |
| updated Relationships | |||
| 2008年09月08日 | CWE Content Team | MITRE | |
| updated Relationships, Other_Notes, Taxonomy_Mappings | |||
| 2008年07月01日 | Eric Dalci | Cigital | |
| updated Time_of_Introduction | |||
| Previous Entry Names | |||
| Change Date | Previous Entry Name | ||
| 2008年04月11日 | Catch NullPointerException | ||
Use of the Common Weakness Enumeration (CWE™) and the associated references from this website are subject to the Terms of Use. CWE is sponsored by the U.S. Department of Homeland Security (DHS) Cybersecurity and Infrastructure Security Agency (CISA) and managed by the Homeland Security Systems Engineering and Development Institute (HSSEDI) which is operated by The MITRE Corporation (MITRE). Copyright © 2006–2025, The MITRE Corporation. CWE, CWSS, CWRAF, and the CWE logo are trademarks of The MITRE Corporation.