Bad Coding Practices
A category in the Common Weakness Enumeration published by The MITRE Corporation.
Categories in the Common Weakness Enumeration (CWE) group entries based on some common characteristic or attribute.
Weaknesses in this category are related to coding practices that are deemed unsafe and increase the chances that an exploitable vulnerability will be present in the application. These weaknesses do not directly introduce a vulnerability, but indicate that the product has not been carefully developed or maintained. If a program is complex, difficult to maintain, not portable, or shows evidence of neglect, then there is a higher likelihood that weaknesses are buried in the code.
The application is deployed to unauthorized actors with debugging code still enabled or active, which can create unintended entry points or expose sensitive information.
The software's architecture contains too many - or too few - horizontal layers.
The variable's value is assigned but never used, making it a dead store.
The code contains a function or method whose signature and/or associated inline documentation does not sufficiently describe the callable's inputs, outputs, ...
The code contains a class instance that calls the method or function to delete or destroy itself.
A class contains a virtual method, but the method does not have an associated virtual destructor.
The code is compiled without sufficient warnings enabled, which may prevent the detection of subtle bugs or quality issues.
A static code block creates an instance of a class.
The software creates an immutable text string using string concatenation operations.
The software uses a data element that has an excessively large number of sub-elements with non-primitive data types such as structures or aggregated objects.
The code contains a data element with a pointer that does not have an associated copy or constructor method.
The software accesses a data resource through a database without using a connection pooling capability.
The software contains dead code, which can never be executed.
The source code declares a variable in one scope, but the variable is only used within a narrower scope.
In a language where the user can influence the name of a variable at runtime, if the variable names are not controlled, an attacker can read or write to arbitrary vari...
The source code contains a block that does not contain any code, i.e., the block is empty.
The software performs a data query with a large number of joins and sub-queries on a large data table.
The software contains a data query against an SQL table or view that is configured in a way that does not utilize an index and may cause sequential searches ...
The software contains an index range scan for a large data table, but the scan can cover a large number of rows.
The software has a loop body or loop condition that contains a control element that directly or indirectly consumes platform resources, e.g. messaging, sessions, ...
The code is structured in a way that relies too much on using or setting global variables throughout various points in the code, instead of preserving the as...
The software makes an explicit call to the finalize() method from outside the finalizer.
The product calls a function, procedure, or routine with arguments that are not correctly specified, leading to always-incorrect behavior and resultant weaknesses.
The source code contains comments that do not accurately describe or explain aspects of the portion of the code with which the comment is associated.
The source code uses comment styles or formats that are inconsistent or do not follow expected standards for the product.
The source code contains whitespace that is inconsistent across the code or does not follow expected standards for the product.
The product's code, documentation, or other artifacts do not consistently use the same naming conventions for variables, callables, groups of related callabl...
The code uses boxed primitives, which may introduce inefficiencies into performance-critical operations.
The source code uses symbolic constants, but it does not sufficiently place the definitions of these constants into a more centralized or isolated location.
The source code uses literal constants that may need to change or evolve over time, instead of using symbolic constants.
A function or method contains too many operations that utilize a data manager or file resource.
A function, method, procedure, etc. contains an excessive amount of code that has been commented out within its body.
The code contains callable control elements that contain an excessively large number of references to other application objects external to the conte...
The software uses a large data table that contains an excessively large number of indices.
The code does not have a default case in a switch statement, which might lead to complex logical errors and resultant weaknesses.
The software contains a serializable data element that does not have an associated serialization method.
When multiple sockets are allowed to bind to the same port, other services on that port may be stolen or spoofed.
The software contains a client with a function or method that contains a large number of data accesses/queries that are sent through a data manager, i.e., does not use...
The software does not maintain equal hashcodes for equal objects.
A parent class has a virtual destructor method, but the parent has a child class that does not have a virtual destructor.
A parent class contains one or more child classes, but the parent class does not have a virtual destructor method.
The software uses a storable data element that does not have all of the associated functions or methods that are necessary to support comparison.
The code uses a data representation that relies on low-level data representation or constructs that may vary across different processors, physical machines, ...
Java packages are not inherently closed; therefore, relying on them for code security is not a good practice.
The product uses automatically-generated code that cannot be executed without a specific runtime support component.
A function returns the address of a stack variable, which will cause unintended program behavior, typically in the form of a crash.
The application uses deployed components from application servers, but it also uses low-level functions/methods for management of resources, instead of the API provide...
The software contains a serializable, storable data element such as a field or member, but the data element contains member elements that are not serializable.
The source code contains elements such as source files that do not consistently provide a prologue or header that has been standardized for the project.
The code contains comments that suggest the presence of bugs, incomplete functionality, or weaknesses.
The program uses hard-coded constants instead of symbolic names for security-critical values, which increases the likelihood of mistakes during code maintenance or sec...
The software uses multiple resources that can have the same identifier, in a context in which unique identifiers are required.
The software contains a method that accesses an object but does not later invoke the element's associated finalize/destructor method.
The product relies on third-party software components that do not provide equivalent functionality across all desirable platforms.
The software has multiple functions, methods, procedures, macros, etc. that contain the same code.
The software uses the same control element across multiple architectural layers.
The code contains a callable, block, or other code element in which the same variable is used to control more than one unique task or store more than one ins...
The product relies on third-party components that are not actively supported or maintained by the original developer or a trusted proxy for the original deve...
The product uses external input to determine the names of variables into which information is extracted, without verifying that the names of the specified variables ar...
This view organizes weaknesses around concepts that are frequently used or encountered in software development. This includes all aspects of the software development l...