Skip to content
Permalink
Browse files Browse the repository at this point in the history
common: [security fix] Make sure sockets only listen locally
  • Loading branch information
posixninja authored and nikias committed Dec 29, 2015
1 parent decffad commit df1f5c4
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions common/socket.c
Expand Up @@ -172,7 +172,7 @@ int socket_create(uint16_t port)

memset((void *) &saddr, 0, sizeof(saddr));
saddr.sin_family = AF_INET;
saddr.sin_addr.s_addr = htonl(INADDR_ANY);
saddr.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
saddr.sin_port = htons(port);

if (0 > bind(sfd, (struct sockaddr *) &saddr, sizeof(saddr))) {
Expand Down Expand Up @@ -329,7 +329,7 @@ int socket_accept(int fd, uint16_t port)

memset(&addr, 0, sizeof(addr));
addr.sin_family = AF_INET;
addr.sin_addr.s_addr = htonl(INADDR_ANY);
addr.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
addr.sin_port = htons(port);

addr_len = sizeof(addr);
Expand Down

5 comments on commit df1f5c4

@setharnold
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Has a CVE already been assigned for this issue?

Thanks

@setharnold
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nikias
Copy link
Member

@nikias nikias commented on df1f5c4 May 26, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@setharnold as you can see from the commit, Joshua Hill aka posixninja is to be credited for the reporting of this vulnerability in both libraries. He reported this to me personally.

@FunkyM
Copy link
Member

@FunkyM FunkyM commented on df1f5c4 May 27, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just for reference, please mind that this functionality is indeed wanted for a use-case of connecting externally and was not added "by accident". However, it makes sense to default to local only for now. We'll add a switch or config option for the "external" case to cover that.

@mexmer
Copy link

@mexmer mexmer commented on df1f5c4 May 27, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@FunkyM good, just wanted to ask about this, since i use remote connection to iphone from different computer. although using port forwarding trough ssh is also solution for my needs, it's just easier this way

Please sign in to comment.