ICMP echo traffic doesn't NEED to be operated on a raw socket any more than UDP or TCP traffic does, so why is it done that way?
7
votes
2
answers
1152
views
If you've ever tried writing tools that depend upon ICMP echo requests, you've inevitably run into the same problem as everyone else: you can't do it unless your tool is running as root.
When you try to find out why this is the case, the answer is always the same: "sending icmp traffic requires the privileges to open a raw socket, so you must have root privileges to send ICMP traffic."
While this is technically true, and at least advises the engineer writing the tool of their options, it fails to answer the underlying question of why ICMP traffic is somehow so special that there is no facility whatsoever for sending and receiving it as an unprivileged user.
UDP and TCP are both considerably more complex than an ICMP echo request, but UDP and TCP have both been exposed to the user without giving them the full power of reading and writing to the network with reckless abandon. What is it that actually prevents a library from providing unprivileged ability to send and receive pings with no more control over the contents than icmp sequence, packet contents (or even just the size) id, ttl, and MAYBE tos?
I'm not looking for an engineering workaround here, because one does not exist for the general purpose. I've seen advice to just make a system call to /usr/bin/ping but that's not really suitable either.
The question comes down to this: is there some potential situation where having a general-purpose ICMP echo library would lead to users either conflicting with each other or somehow provide a level of power to the user that is dangerous? The latter scenario seems ludicrous to me just based on the fact that an echo request is actually less configurable than a UDP datagram. I'd use UDP if it would serve the functions I need, but it absolutely does not.
Asked by Sniggerfardimungus
(326 rep)
Mar 2, 2025, 09:43 PM
Last activity: Mar 9, 2025, 02:56 AM
Last activity: Mar 9, 2025, 02:56 AM