Is it possible for a remote machine to access another machine's localhost data by spoofing the loopback ip?

Say if I wanted a setup where if I'm connecting from somewhere outside my own network, I will have to supply login credentials and my password will be required for all sensitive operations. However, if I am connecting from my computer, these credentials aren't needed because I have to login to my OS to access the network on that device anyway. Can I rely on the loopback address as a security measure in this way? Or is it possible for an attacker to make it appear as though they are connecting locally?

  • I do not believe so. Jul 26, 2012 at 23:50
  • 1
    Do you mean get the machine to receive a spoofed packet that appears to have come from Or do you mean get the machine to receive a spoofed packet that is addressed to Jul 27, 2012 at 0:53
  • I mean, basically, can someone break into my localhost data and do {whatever} with it by pretending to be localhost.
    – bee.catt
    Jul 27, 2012 at 2:14
  • It's not clear what "break into my localhost data" means. Does that mean make your machine receive a packet that appears to come from Jul 29, 2012 at 11:26

4 Answers 4



It is possible to send data as fake, but the reply will go "out" (stay inside actually) the loopback interface, and be 'lost'.

If there is a router on the way, it will send the packet through it's own loopback interface, and it will be lost there.

  • ok, so if I am understanding all this correctly, an attacker could potentially send something IN, but they wouldn't be able to get anything back OUT, because the nature of the loopback is that it only talks to itself. If this is correct, then could an attacker send in malicious code that makes it possible to connect remotely, or even just some code that generally breaks things?
    – bee.catt
    Jul 27, 2012 at 0:06
  • you have a routing table in your pc, which says which packets go out where. (route -n on *nix). You have an entry there for to go out through the loopback interface (does not actually go out, since it's a loopback). So, if the attacker from your lan sends a packet to your pc, your PC can accept it, but the return packet will be lost, since it will stay inside your pc (sent 'out' from the loopback)
    – mulaz
    Jul 27, 2012 at 0:17
  • 1
    An interesting idea. However the loopback interface has no MAC address. So you would have to have the target computers (technical target NIC) MAC in combination with an IP which does not belong to that MAC and hope that the receiving network stack accepts it. And then the package needs to be accepted by something expecting data and probably also listening on the real IP. Still, a nice thought.
    – Hennes
    Jul 27, 2012 at 0:23
  • You can use the mac from the ethernet card (when you send a packet to, lets say googles, you send it to your routers MAC with as dst. IP. The machine needs to have ip forwarding enabled ofcourse.
    – mulaz
    Jul 27, 2012 at 0:29
  • what about attacks at control plane? With a crafted source address as it is possible to bypass some ACLs? Oct 10, 2014 at 6:23

Yes. Surprisingly, it is possible to spoof a loopback source address. Obviously you won't get any replies, so your spoofed packet also needs to include an exploit. Also it will be stopped at a router, so you need to be on the same local network as the victim. The remote hole CVE-2014-9295 was exploitable in this way.

It turns out OS X and the Linux Kernel behave similarly in this case. Any IP packet arriving on an external interface and with the source IP will be dropped immediately. But if we use IPv6 instead we can actually spoof ::1 and send control mode packets to the daemon (some Linux distributions have firewall rules in place that protect against this, e.g. Red Hat). Thus, if we are on the same local network, we can send spoofed packets to the link-local address of the target and bypass the IP restrictions.


  • 2
    This is the real answer...
    – DeepS1X
    Jun 13, 2017 at 18:03

Loopback data usually never makes it to the network. It is intercepted and, well, looped back, before that happens. Since it never hits the actual network nothing on the network can intercept it.

  • With custom driver software and collaborating NIC hardware, it's surely possible to send ethernet frames carrying IP packages that have localhost address. It's up to the receiving end not to interpret those as true localhost packages. Not all OS do this correctly. Dec 15, 2020 at 12:26

No. The loopback is hardcoded in /etc/hosts - this is the first place the resolver will look for loopback to ip translation. Unless you are able to edit the /etc/hosts you cannot do it.

If you can edit /etc/hosts then you are an administrator so you can do anything ..

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.