0

I am using a public wifi network.

When I start a nodejs express server at my local system at port 3000, I can access that website on another device (that is connected to the same public wifi network) by going to the http://(private ip address of nodejs host assigned by public wifi dhcp):3000/index.html , for example.

So to prevent this, I had my phone connect to the public wifi network and fired up the built in android hotspot. Then I connected my nodejs host machine to the hotspot to start the express server at port 3000.

I could no longer access that website anymore from a different device on the public wifi network because express server was now inside the private network within that public wifi network.

I can ping from a device inside the android hotspot private network to a device in the public wifi network. But the device from the public wifi network could not ping devices inside the android hotspot private network.

Is there a way for an attacker on that public wifi network to gain access to my android hotspot private network without knowing the SSID passphrase?

Could they use some kind of network pivoting technique so that they can access my private html website on port 3000? Using something like ip route add ?

Steffen Ullrich
  • 184,332
  • 29
  • 363
  • 424
an0nhi11
  • 15
  • 3
  • 2
    I replaced your claim of *"start a nodejs express server at my __localhost__"* with *"... at my __local system__"*, since *localhost* has a very specific meaning, i.e. the system local network with IP 127.0.0.1. And this network is not reachable from outside the system, so *localhost* would not allow the private_ip:3000 access you described as possible. – Steffen Ullrich Jul 17 '22 at 10:14
  • thanks for the correction! – an0nhi11 Jul 17 '22 at 10:16

1 Answers1

1

By connecting your phone to the public WiFi AP, then connecting your local system to the phone, you are creating two layers of NAT. So, your question boils down to whether an attacker connected to the the same router as your phone (i.e. the public WiFi AP) can traverse the NAT running on your phone, then access your local system.

In general, NAT (by itself) is not considered to be a reliable firewall. See How important is NAT as a security layer? for some interesting reading on this subject. Unless you are sure that you phone provides a firewall function (in addition to NAT) when running as a local hotspot, I would not recommend relying on this solution.

A better solution would be to run a firewall on your local system, to block any incoming connections to port 3000 other than those from localhost. If you do this, then you can safely connect your local system to the public WiFi AP, instead of trying to rely on your phone as a firewall.

mti2935
  • 19,868
  • 2
  • 45
  • 64