Support HTTP over Unix domain sockets
bugzilla.mozilla.org
bugzilla.mozilla.org
In addition you can rely on Unix access control with the socket. Much better than granting access to all local users, such as is the case by default with e.g. Syncthing.
OpenSSH can also forward these sockets, so remote use can be safer that way and the port configuration issue is relevant here as well.
I've also hoped that NFS and its ilk would be able to transfer Unix domain sockets, but I haven't heard of a system that could do that. Then one could, in principle, just ssh /var/servers/gw over NFS!
edit: actually read the proposal and it mentions most of my points, including Syncthing :).
It's pretty useful in test suites where you don't want to open a public TCP port (even on localhost), for obvious security reasons but also because it's hard to pick an unused port without conflicting with other tests running at the same time. Example test using this: https://gitlab.com/nbdkit/nbdkit/-/blob/master/tests/test-cu...
Can someone explain this a bit more? It's my understanding that all localhost traffic is confined to the host, and so only available to the host itself. If something malicious could access traffic on localhost, wouldn't that mean you've already lost?
On a multi-user machine, as a regular user, serving over TCP immediately allows any other logged-on users to access it, which can be unacceptable in some circumstances.
Unix domain sockets can be confined to a randomly generated directory under /tmp and locked down with file permissions.
EDIT: I stand corrected
virtus ~ # nft list ruleset
virtus ~ # nc -vvv -l -s 127.0.0.1 -p 1234
Listening on localhost 1234
virtus ~ # ip -4 addr show scope global dev enp3s0
2: enp3s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
inet 10.20.1.75/24 brd 10.20.1.255 scope global enp3s0
valid_lft forever preferred_lft forever
virtus ~ # nc -vvv 10.20.1.75 1234
nc: connect to 10.20.1.75 port 1234 (tcp) failed: Connection refused
The security consideration with binding to localhost is that every process in the same network namespace can connect to that socket, regardless of what user the process is running as, unless you use netfilter to isolate what users can connect to where. Even then any process running as the given user will be permitted. A UNIX domain socket bound to a filesystem path can be constrained by filesystem ACLs and chroots, without having to touch netfilter at all.Also running out of ports is a thing! There are only 64K ports (with many not being usable) and a CI machine might be running many tests in parallel. Unix domain sockets give me an infinite space of ports, since they use filenames.
As a workaround, (I believe, though only through a cursory web search and haven't tested) you can use network namespaces and socat to proxy traffic from Unix sockets to a private IP:port range only visible to your user - taking that part of containerization without necessarily having to execute things inside containers.
I like the idea of specifying the socket in place of the port number in the URL.
I wonder why an actually secure local connection to a web UI is considered to be of very little benefit. This sounds crazy to me, for all these years.
Currently it can be achieved by a program as non-trivial as netcat
Also I don't share their concerns about SNI. To my mind, the Host header can just be unsupported for Unix sockets. SNI makes sense when the several domain names resolve to the same IP address. This should not be an important, case with Unix sockets. Not supporting it is a much better compromise than not supporting Unix sockets at all.
It's not insurmountable absolutely and I would appreciate it absolutely.
If there is a will, there is a way. I think the will is lacking here. The developers themselves do no care. I can see why the Chrome team is opposed to that: it's the Google's interest to eliminate all things offline. I didn't expect Mozilla folks to be so unreceptive though. Having the unix domain socket support would be a distinct advantage.
I haven’t seen this proposal yet in this thread: instead of convincing browser vendors to support connecting to Unix domain sockets, contrive a tiny adapter which listens on a localhost port and expects http with basic auth (and either generates a random username and password or accepts them by environment variables), prints out a url with the password like
Hi! To connect to your service at /tmp/whatever-service.unix, tell your browser to go to
http://fwahjiddbjko:derhhkiytdfbkifdx@localhost:45678/
and then the adapter accepts connections, checks the auth, and then proxies the connection to the unix socket.You could do this with nginx really easily but you’d have to keep track of a config file for each service.
See https://stackoverflow.com/questions/17701420/bypassing-http-... for a similar idea (but that is about stripping auth, not adding it)
Windows already supports password-less authentication quite well. It's just a matter of time until there are good solutions for Linux too.
I have already some systems set up in a way that they ask for a TOTP when doing username/password login via SSH: https://github.com/google/google-authenticator-libpam
So for example if CUPS or Syncthing listened on a UNIX socket you can use NGINX to expose this over TCP, but now you are back at the original problem of any local process can access this service and you need to worry about port conflicts. You can work around this by adding access control but this doesn't elegantly solve the core problem.
So it is valuable to have a client (like Firefox) that can directly access the socket. This way you get native UNIX permissions and a whole filesystem namespace to prevent conflicts.
I use it to run a number of services under systemd, and haven’t had any issues.
Actualy namespacing syncthing per user might be enough for every user at same system to run syncthing at tcp/8080 or whatever.
I use it for the usecase you describe.
Unix domain sockets are great. I find it completely amazing that they are not used more widely.
Since when was it OK to open a TCP listener when you don't want to receive connections over the network? Did everyone forget about that during their Kuberenetes fling, am I too old, or what?
For a great example of this, see how Guile's live REPL was localhost + port... cool, only local users could access it, right? Except browsers could access localhost + port, and it turned out this was a path to being able to do arbitrary code execution in the browser https://lists.gnu.org/archive/html/guile-user/2016-10/msg000...
Switching to unix domain sockets was the recommended path, and that's only because browsers don't support them.
If you want to support unix domain sockets, you could, but it would have to be via object capability security discipline, and the poster explicitly talks about an ACL "protecting" things... it wouldn't.
Luckily this is 3 years old and hopefully will never make progress.
Maybe the recommended path should have been to implement some actual security?
> https://lists.gnu.org/archive/html/guile-user/2016-10/msg000... > DNS rebinding attack
Can't DNS rebind to a "unix socket address" — feels like that by itself would considerably improve security for anything you're working on locally?
For web based desktop applications this might be a good solution. But there it is usually done with custom IPC. I think Electron can do it with custom protocols.
Listening on localhost is usually not a great solution. It's impossible to do HTTPS right this way (without HTTPS there is a danger of a MITM attack from an unprivileged process). Also authentication is an issue then, without authentication there is a possibility of an privilege escalation.
I think using a UNIX socket instead of a TCP server for local HTTP development would be extremely useful. It solves most of the problems associated with creating a local TCP server (which everyone already does) without introducing new problems.
UNIX sockets would of course solve this issue.
But UNIX sockets are not available on all platforms, which defeats a bit the general idea of a browser. Windows got UNIX socket support a while ago, but I don't know how well it works.
This can't be said enough times. Browser vendors should never, ever say "we're not supporting feature X because it's not popular enough, and other browsers don't support it" when lack of browser support is what's keeping it from getting popular. We'd literally never get any new features if they always used that logic.
I saw a similar hack https://tldp.org/HOWTO/html_single/TCP-Keepalive-HOWTO/#libk...
i want out of this community. all these little people who have zero contextual understanding always requesting and implementing these features at all costs as long as the idea exists. this is a un*x problem at the core: if a feature conceptually exists, we must implement it at all costs. and another un*x problem here is having a global namespace (tcp port numbers) that things are just exposed to everything (either localhost or the network) by default when they could have easily just used an opaqaue handle that the machine operator can copy and paste into whatever application he wants to use it (no some openauth type shit that failed to be secure for 15 years is not what i have in mind)
Browsers implementing support for unix domain sockets would of course need to completely block such connection from tcp pages and only allow connection to a given socket provided it is the one currently in the url bar, that the current page has been loaded from.
If that's not enough, you can always use the file permission system to block your everyday browser running as your regular user to access the service sockets, and spawn a browser using a dedicated user account (www-sock? just like we have www-data for web servers?) that you only use for this.
> when they could have easily just used an opaque handle that the machine operator can copy and paste into whatever application he wants to use it
Then the point of failure would be the random number generator used to generate the "opaque handle". Security by obscurity never works.
[0]: https://gs.statcounter.com/os-market-share/desktop/worldwide...
https://devblogs.microsoft.com/commandline/af_unix-comes-to-...
[0]: https://devblogs.microsoft.com/commandline/windowswsl-intero...