The product does not handle or incorrectly handles when two or more structural elements should be consistent, but are not.
View on MITRENo mitigation information available for this CWE.
No detection method information available for this CWE.
In the following C/C++ example the method processMessageFromSocket() will get a message from a socket, placed into a buffer, and will parse the contents of the buffer into a structure that contains the message length and the message body. A for loop is used to copy the message body into a local character string which will be passed to another method for processing.
However, the message length variable (msgLength) from the structure is used as the condition for ending the for loop without validating that msgLength accurately reflects the actual length of the message body (CWE-606). If msgLength indicates a length that is longer than the size of a message body (CWE-130), then this can result in a buffer over-read by reading past the end of the buffer (CWE-126).
Chain: "Heartbleed" bug receives an inconsistent length parameter (CWE-130) enabling an out-of-bounds read (CWE-126), returning memory that could include private cryptographic keys and other sensitive data.
View DetailsWeb application firewall consumes excessive memory when an HTTP request contains a large Content-Length value but no POST data.
View DetailsNo relationship information available for this CWE.
CWE-240: Improper Handling of Inconsistent Structural Elements is a Common Weakness Enumeration (CWE) entry maintained by MITRE. The product does not handle or incorrectly handles when two or more structural elements should be consistent, but are not.
If exploited, CWE-240 (Improper Handling of Inconsistent Structural Elements) it can compromise Integrity and Other, leading to outcomes such as Varies by Context and Unexpected State.
CWE-240 commonly affects Not Language-Specific. Note that weaknesses are often language-agnostic patterns, so secure coding practices apply broadly.
MITRE documents real CVEs mapped to CWE-240, including CVE-2014-0160 and CVE-2009-2299. You can look up the full details of each CVE, including CVSS scores and remediation guidance, on our CVE Lookup tool.
A CWE (Common Weakness Enumeration) like CWE-240 describes a category of software weakness — the underlying flaw type. A CVE (Common Vulnerabilities and Exposures) identifies a specific, real-world vulnerability in a particular product. In short, a CWE is the kind of mistake, and a CVE is an instance of that mistake being found in software.