1488
Nature Type ID Name Page
ParentOf 605 Multiple Binds to the Same Port 1356
ParentOf 764 Multiple Locks of a Critical Resource 1604
ParentOf 765 Multiple Unlocks of a Critical Resource 1605
ParentOf 1341 Multiple Releases of Same Resource or Handle 2246
PeerOf 102 Struts: Duplicate Validation Forms 246
PeerOf 586 Explicit Call to Finalize() 1320
PeerOf 85 Doubled Character XSS Manipulations 188
Applicable Platforms
Language : Not Language-Specific (Prevalence = Undetermined)
Common Consequences
Scope Impact Likelihood
Other Other
Demonstrative Examples
Example 1:
The following code shows a simple example of a double free vulnerability.
Example Language: C (Bad)
char* ptr = (char*)malloc (SIZE);
...
if (abrt) {
free(ptr);
}
...
free(ptr);
Double free vulnerabilities have two common (and sometimes overlapping) causes:
• Error conditions and other exceptional circumstances
• Confusion over which part of the program is responsible for freeing the memory
Although some double free vulnerabilities are not much more complicated than this example,
most are spread out across hundreds of lines of code or even different files. Programmers seem
particularly susceptible to freeing global variables more than once.
Example 2:
This code binds a server socket to port 21, allowing the server to listen for traffic on that port.
Example Language: C (Bad)
void bind_socket(void) {
int server_sockfd;
int server_len;
struct sockaddr_in server_address;
/*unlink the socket if already bound to avoid an error when bind() is called*/
unlink("server_socket");
server_sockfd = socket(AF_INET, SOCK_STREAM, 0);
server_address.sin_family = AF_INET;
server_address.sin_port = 21;
server_address.sin_addr.s_addr = htonl(INADDR_ANY);
server_len = sizeof(struct sockaddr_in);
bind(server_sockfd, (struct sockaddr *) &s1, server_len);
}
CWE Version 4.14
CWE-676: Use of Potentially Dangerous Function
CWE-676: Use of Potentially Dangerous Function