Description
The product does not handle or incorrectly handles when two or more structural elements should be consistent, but are not.
Potential Impact
Integrity, Other
Varies by Context, Unexpected State
Demonstrative Examples
int processMessageFromSocket(int socket) {
int success;
char buffer[BUFFER_SIZE];char message[MESSAGE_SIZE];
// get message from socket and store into buffer
//Ignoring possibliity that buffer > BUFFER_SIZE
if (getMessage(socket, buffer, BUFFER_SIZE) > 0) {
// place contents of the buffer into message structure
ExMessage *msg = recastBuffer(buffer);
// copy message body into string for processing
int index;for (index = 0; index < msg->msgLength; index++) {message[index] = msg->msgBody[index];}message[index] = '\0';
// process message
success = processMessage(message);
}return success;
}Real-World CVE Examples
| CVE ID | Description |
|---|---|
| CVE-2014-0160 | 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 |
| CVE-2009-2299 | Web application firewall consumes excessive memory when an HTTP request contains a large Content-Length value but no POST data. |
Related Weaknesses
Taxonomy Mappings
- PLOVER: — Inconsistent Elements
Frequently Asked Questions
What is CWE-240?
CWE-240 (Improper Handling of Inconsistent Structural Elements) is a software weakness identified by MITRE's Common Weakness Enumeration. It is classified as a Base-level weakness. The product does not handle or incorrectly handles when two or more structural elements should be consistent, but are not.
How can CWE-240 be exploited?
Attackers can exploit CWE-240 (Improper Handling of Inconsistent Structural Elements) to varies by context, unexpected state. This weakness is typically introduced during the Implementation phase of software development.
How do I prevent CWE-240?
Follow secure coding practices, conduct code reviews, and use automated security testing tools (SAST/DAST) to detect this weakness early in the development lifecycle.
What is the severity of CWE-240?
CWE-240 is classified as a Base-level weakness (Medium abstraction). It has been observed in 2 real-world CVEs.