Multiple Binds to the Same Port |
Weakness ID: 605 (Weakness Base) | Status: Draft |
Description Summary
When multiple sockets are allowed to bind to the same port, other services on that port may be stolen or spoofed.
Scope | Effect |
---|---|
Confidentiality Integrity | Packets from a variety of network services may be stolen or the services spoofed. |
Example 1
Example Language: C
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <unistd.h>
#include <stdio.h>
#include <arpa/inet.h>
void bind_socket(void) {
int server_sockfd;
int server_len;
struct sockaddr_in server_address;
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);
On most systems, a combination of setting the SO_REUSEADDR socket option, and a call to bind() allows any process to bind to a port to which a previous process has bound width INADDR_ANY. This allows a user to bind to the specific address of a server bound to INADDR_ANY on an unprivileged port, and steal its udp packets/tcp connection. |
Nature | Type | ID | Name | View(s) this relationship pertains to![]() |
---|---|---|---|---|
ChildOf | ![]() | 227 | Failure to Fulfill API Contract ('API Abuse') | Development Concepts (primary)699 |
ChildOf | ![]() | 666 | Operation on Resource in Wrong Phase of Lifetime | Research Concepts1000 |
ChildOf | ![]() | 675 | Duplicate Operations on Resource | Research Concepts (primary)1000 |
Submissions | ||||
---|---|---|---|---|
Submission Date | Submitter | Organization | Source | |
Anonymous Tool Vendor (under NDA) | Externally Mined | |||
Modifications | ||||
Modification Date | Modifier | Organization | Source | |
2008-07-01 | Eric Dalci | Cigital | External | |
updated Time of Introduction | ||||
2008-09-08 | CWE Content Team | MITRE | Internal | |
updated Common Consequences, Relationships, Other Notes, Taxonomy Mappings | ||||
2009-05-27 | CWE Content Team | MITRE | Internal | |
updated Demonstrative Examples | ||||
2009-10-29 | CWE Content Team | MITRE | Internal | |
updated Common Consequences | ||||
Previous Entry Names | ||||
Change Date | Previous Entry Name | |||
2008-04-11 | Multiple Binds to Same Port | |||