CWE
Home > CWE List > CWE- Individual Dictionary Definition (1.1)  
Search by ID:

CWE-605: Multiple Binds to the Same Port

Individual Definition in a New Window
Multiple Binds to the Same Port
Status: Draft
Weakness ID: 605 (Weakness Base)
Description
Summary

When multiple sockets are allowed to bind to the same port, other services on that port may be stolen or spoofed.

Common Consequences

Packets from a variety of network services may be stolen or the services spoofed.

Potential Mitigations

Restrict server socket address to known local addresses.

Demonstrative Examples

#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);
Other Notes

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.

Relationships
NatureTypeIDNameView(s) this relationship pertains toView(s)
ChildOfWeakness ClassWeakness ClassWeakness Class675Duplicate Operations on Resource
Research Concepts (primary)1000
ChildOfWeakness BaseWeakness BaseWeakness Base666Operation on Resource in Wrong Phase of Lifetime
Research Concepts1000
ChildOfWeakness ClassWeakness ClassWeakness Class227Failure to Fulfill API Contract (aka 'API Abuse')
Development Concepts (primary)699
Taxonomy Mappings
Mapped Taxonomy Name
Anonymous Tool Vendor (under NDA)
Applicable Platforms
Languages
All
Time of Introduction
* Architecture and Design
* Implementation
* Operation
Content History
Submissions
Anonymous Tool Vendor (under NDA). (Externally Mined)
Modifications
Eric Dalci. Cigital. 2008-07-01. (External)
updated Time_of_Introduction
CWE Content Team. MITRE. 2008-09-08. (Internal)
updated Common_Consequences, Relationships, Other_Notes, Taxonomy_Mappings
Previous Entry Names
* Multiple Binds to Same Port (changed 2008-04-11)
Page Last Updated: November 24, 2008