Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Raw sockets need root priviliege

Tags:

security

Why do we need root privileges when we use raw sockets ?

like image 232
user525146 Avatar asked Dec 10 '10 01:12

user525146


People also ask

What are raw socket privileges?

Raw sockets allow new IPv4 protocols to be implemented in user space. A raw socket receives or sends the raw datagram not including link level headers. The IPv4 layer generates an IP header when sending a packet unless the IP_HDRINCL socket option is enabled on the socket.

Why raw sockets are used?

The raw socket interface provides direct access to lower layer protocols, such as the Internet Protocol (IP) and Internet Control Message Protocol (ICMP or ICMPv6). You can use raw sockets to test new protocol implementations.

Why does SYN scan require root?

I was recently reading through the nmap port scanning documentation and it points out that to perform a SYN scan (-sS) you require root privileges because an unprivileged user cannot send raw packets.

Why is raw socket important and where is it used?

A raw socket is used to receive raw packets. This means packets received at the Ethernet layer will directly pass to the raw socket. Stating it precisely, a raw socket bypasses the normal TCP/IP processing and sends the packets to the specific user application (see Figure 1).


3 Answers

It's because you can spoof custom packets, which may interfere with inbound traffic. This too is also bad.

like image 75
makerofthings7 Avatar answered Oct 18 '22 20:10

makerofthings7


In short raw sockets is restricted to root because if it otherwise it would break other rules for networking that are in place.

A long standing rule is that you cannot bind on a port lower than 1024 without root's blessing. With raw sockets you can simulate a server on any port. (naturally being able to receive on this port is a different story you'd also have to sniff the network, but perhaps this could be done with a different machine.)

like image 27
rook Avatar answered Oct 18 '22 18:10

rook


Opening a raw socket allows to read anything that is received in a given interface, so, basically, you can read any packet that is directed to any application - even if that application is owned by another user. That basically means that the user with this capability is able to read any and all communications of all users.

like image 2
Javier Avatar answered Oct 18 '22 18:10

Javier