News for hackers. Stuff that matters.
Re:Guile security vulnerability with listening on localhost ... by imagist on Thursday October 13, 2016 @11:42PM (#12705996)
Is this an issue with Guile, or is this an issue with browsers? It seems like allowing sites to query localhost is a vulnerability that could affect a wide variety of development tools. Maybe I'm not thinking of some use case, but it seems to me that we would only ever want requests to localhost to come from local sources, no?
Re:Guile security vulnerability with listening on localhost ... by pilif on Friday October 14, 2016 @01:03AM (#12706229)
Dropbox and Github both use it to talk to their installed desktop clients from the website. It's very useful as it by just installing an app, a website can get more access to the local machine's hardware without having to resort to browser-specific plugins.

In our case, we're using it to read data from a barcode scanner to use it on a web application. All a user needs to do is to install the application an once that's done it works in all browsers.

Re:Guile security vulnerability with listening on localhost ... by flukus on Friday October 14, 2016 @01:32AM (#12706300)
Can any websites talk to these apps? I've built a similar one (a decade ago now), but we at least had the benefit of only running on a closed network.
Re:Guile security vulnerability with listening on localhost ... by pilif on Friday October 14, 2016 @04:40AM (#12706811)
Potentially, yes. In our case we're doing a bit of additional work to prevent this from happening though. Other sites would get access to the built-in web server, but they wouldn't get anything apart from a 403 error.
Re:Guile security vulnerability with listening on localhost ... by imagist on Tuesday October 18, 2016 @09:45AM (#12734218)
> Dropbox and Github both use it to talk to their installed desktop clients from the website. It's very useful as it by just installing an app, a website can get more access to the local machine's hardware without having to resort to browser-specific plugins.

Okay, but from a user's perspective this is exactly what I would NOT want--it's unintuitive to me that going onto GitHub would give them access to my machine's hardware just because I have the app installed.

The program should serve the user, not GitHub or DropBox.

Re:Guile security vulnerability with listening on localhost ... by rixed on Friday October 14, 2016 @01:17AM (#12706254)
The site is not querying localhost, the browser is. I find it strange that we consider the error to lie in guile or redis or memcached or elastic search when clearly the browser is the security hole. Why is it so?
Re:Guile security vulnerability with listening on localhost ... by antocv on Friday October 14, 2016 @07:06AM (#12707297)
Well the browser must be able to visit http://127.0.0.1 whats so different about that than https://192.168.1.1 or any other address?

Its only in combination with DNS that a browser can be tricked into sending requests where it didnt intend - but thats a problem of DNS.

So libnss or whatever library the browser uses sees lists.gnu.org and resolves that to 208.118.235.17 so browser initiates connection to that IP, but on subsequent requests, the name lists.gnu.org is changed to 127.0.0.1, how would a web-browser notice this, shouldnt the dns-library warn about this or just use a cache?

In any case, you can prevent it like this

iptables -A OUTPUT -d 127.0.0.0/8 -p tcp -m owner --uid-owner $YOUR_USER_ID_OF_BROWSER -m tcp -j REJECT --reject-with-tcp-reset

that is, if you run the browser under its own uid.

Re:Guile security vulnerability with listening on localhost ... by Matt3o12_ on Friday October 14, 2016 @10:58AM (#12708479)
Quite simple. I don't think it is a good idea to allow querying sites from the locale network if the visited site is hosted on the public internet.

Let's say I visit google.com and it resolves to google's public Webserver. Your browser should be able to see whether the IP is in the public range (if I'm not mistaken you just checking that the IP is not an A, B, or C class IP, but don't quote me on that). If it is not a local IP (e.g. localhost, LAN, WAN), the browser should disallow all request to local IP addresses (Ajax queries, HTML frames, form requests) initiated by the initial page (google or whatever). It should work the other way around of course and I have never seen a use case where a public webpage relies on being able to query or send a request to my local network if this page is from the internet.

A normal HTTP redirect could be allowed because I think some routers rely on that to give the user a way to configure it (they tell the user to start configuring their router by going to config.manufacture.tld which displays some information and then issues a normal redirect to the default router IP).

Post request directly sent to the local network should be strictly forbidden, though. Why would I ever want to do that?

Re:Guile security vulnerability with listening on localhost ... by l_zzie on Friday October 14, 2016 @11:44AM (#12708834)
That could be nice. So, now the browser needs to understand routing tables?
Re:Guile security vulnerability with listening on localhost ... by Matt3o12_ on Friday October 14, 2016 @12:25PM (#12709143)
I'm not sure I follow. How are routing tabels related to knowing if the IP address is within one of the following ranges: 10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16, 127.0.0.0/8 and if it is the case, just not let the request get though (Adblock does that already).
Re:Guile security vulnerability with listening on localhost ... by rixed on Sunday October 16, 2016 @06:23AM (#12717920)
My original though as well. But eventually I prefer the DNS resolver to just forward whatever the DNS server says. Therefore, the issue can be said to lie in the DNS protocol.

But still, whatever the protocol, the browser is the program that does something privacy sensitive by basically being used as a remote code execution tool, and it should not trust whatever information from whatever source, including name resolution regardless of the protocol. Therefore the browser trusting DNS when something obviously shady is going on (such as a resource ip changing to 127.0.0.1) is a bug in the browser, I think. I would feel safer, for instance, if the same origin policy would apply to the same TCP connection for instance, so that no amount of name or IP spoofing could work. Of course internet giants would not like it, but that would be their problem not mine, and really not so hard to solve.

Re:Guile security vulnerability with listening on localhost ... by imagist on Tuesday October 18, 2016 @09:49AM (#12734259)
> Well the browser must be able to visit http://127.0.0.1 whats so different about that than https://192.168.1.1 or any other address?

127.0.0.1 accesses local servers that might be running code which is typically in development and insecure. There's nothing confusing about this.

Re:Guile security vulnerability with listening on localhost ... by JoshTriplett on Friday October 14, 2016 @03:10AM (#12706541)
Both. Browsers shouldn't allow requests to localhost or 127.0.0.0/8 from anything other than localhost, but guile also shouldn't listen on a port on localhost by default.
Re:Guile security vulnerability with listening on localhost ... by rekado on Friday October 14, 2016 @05:17AM (#12706929)
Guile does not listen on any port by default. To make it listen the `--listen` option has to be provided.
Re:Guile security vulnerability with listening on localhost ... by X-Istence on Thursday October 13, 2016 @11:48PM (#12706016)
This is a DNS re-bind attack.
Re:Guile security vulnerability with listening on localhost ... by brazzledazzle on Friday October 14, 2016 @12:37AM (#12706160)
I wonder if browsers will need to start including a dev mode toggle to allow access to anything hosted on the local loopback.
Re:Guile security vulnerability with listening on localhost ... by aikah on Friday October 14, 2016 @04:49AM (#12706844)
browsers absolutely SHOULD do that. A page on the internet shouldn't have access to localhost by default ever.
Re:Guile security vulnerability with listening on localhost ... by antocv on Friday October 14, 2016 @07:07AM (#12707302)
But this is not a case of a webpage on the internet having access to your localhost, its your local process which access local host!
Re:Guile security vulnerability with listening on localhost ... by languagewars on Friday October 14, 2016 @08:09AM (#12707540)
This is a webpage with an origin outside your host, it is only supposed to have implicit access to the same origin in a sandbox imposed by the local browser. Unfortunately the nature of that policy is broken by not going bellow resolved names, most especially for non-http where the service isn't sent the hostname the client used to resolve it.

So, it is most certainly appropriate for a browser to block local networks (including localhost) from being in foreign domains AFA sanboxing. I also don't want a website attacking my (id)iot router via this broken sandbox.

Re:Guile security vulnerability with listening on localhost ... by brazzledazzle on Friday October 14, 2016 @01:44PM (#12709806)
But don't they update DNS so that the origin for the (presumably sub) domain is now pointing at your localhost? Perhaps the solution is to track the DNS state. Any external to localhost changes should be blocked. And any communication between parent/sub domains should never cross the localhost boundary no matter what DNS might say.

Of course this would interfere with development so it would need to be something you could toggle. But I'm 100% sure there's something I haven't thought of that depends on this behavior.

Re:Guile security vulnerability with listening on localhost ... by l_zzie on Friday October 14, 2016 @11:45AM (#12708853)
It's not only a DNS rebind attack. I'm pretty sure in this case even a GET could get rce , so you don't even need to check the cors headers. You can just XHR.
Re:Guile security vulnerability with listening on localhost ... by flukus on Thursday October 13, 2016 @10:33PM (#12705792)
The same issue was discussed on here recently:

http://bouk.co/blog/hacking-developers/

I think we're only scratching the surface on the number of vulnerabilities exposed.

Re:Guile security vulnerability with listening on localhost ... by l_zzie on Friday October 14, 2016 @11:48AM (#12708868)
I don't think this is the same vulnerability. You don't even need to rebind DNS to do it, I believe: just make an XmlHTTPRequest. Your GET is considered code. The browser will get back a request that doesn't have a cors header and so not let you read it, but your code still executes. So there's no reason to be on the same origin, so DNS rebinding is unnecessary
Re:Guile security vulnerability with listening on localhost ... by qwertyuiop924 on Friday October 14, 2016 @07:26AM (#12707377)
This is actually a vulnerability in any language that provides a networked REPL.

I'm glad that Guile kept the option to run a REPL via a port, because that's really useful for debugging nonlocal servers (investigating production issues, etc.).

Re:Guile security vulnerability with listening on localhost ... by paroneayea on Friday October 14, 2016 @10:30AM (#12708293)
It does look like there's a way to "forward" a unix domain socket over ssh enough to do that kind of debugging:

https://debian-administration.org/users/dkg/weblog/68

Re:Guile security vulnerability with listening on localhost ... by qwertyuiop924 on Friday October 14, 2016 @11:48AM (#12708871)
That's certainly a potential solution.
Re:Guile security vulnerability with listening on localhost ... by tetrep on Friday October 14, 2016 @11:04AM (#12708517)
Why not have the REPL (or whatever else you're exposing to localhost) require a token for authentication of each request?
Re:Guile security vulnerability with listening on localhost ... by qwertyuiop924 on Friday October 14, 2016 @11:31AM (#12708735)
Because it's usually a raw socket, not an HTTP interface, so that's kind of tricky. But it could work.
Re:Guile security vulnerability with listening on localhost ... by fulafel on Friday October 14, 2016 @10:49AM (#12708421)
Networked REPL doesn't preclude security. See eg Twisted's SSH based twisted.conch.manhole
Re:Guile security vulnerability with listening on localhost ... by qwertyuiop924 on Friday October 14, 2016 @02:06PM (#12709957)
Yeah, but until you linked that, I'd never seen a networked REPL that actually provided it.
Re:Guile security vulnerability with listening on localhost ... by Tepix on Friday October 14, 2016 @01:52AM (#12706358)
The browsers should consider detecting when an adress in DNS changes from non-local to localhost and blocking requests when this occurs.
Re:Guile security vulnerability with listening on localhost ... by antocv on Friday October 14, 2016 @07:08AM (#12707308)
Not the browsers, the dns library. Protect any application.
Re:Guile security vulnerability with listening on localhost ... by tedunangst on Friday October 14, 2016 @12:21AM (#12706126)
> the presumption that "localhost" is only accessible by local users

Why is there even a presumption that all local users are equally trusted?

Re:Guile security vulnerability with listening on localhost ... by cyphar on Friday October 14, 2016 @02:17AM (#12706407)
Their suggested methods (Unix sockets and named pipes) both use Unix filesystem ACLs which means they're resilient to this problem.

This is the main reason I've never liked binding to 127.0.0.1 rather than just using a socket -- you lose the access control you could have if you used sockets.

Re:Guile security vulnerability with listening on localhost ... by caf on Friday October 14, 2016 @05:24AM (#12706958)
It was once the case on BSD that filesystem DAC bits weren't applied to AF_UNIX sockets. Can that be universally relied upon now?
Re:Guile security vulnerability with listening on localhost ... by cyphar on Friday October 14, 2016 @11:07AM (#12708541)
I know it works on GNU/Linux, and I'm fairly sure it works on illumos (Solaris). I don't really use any of the BSDs, so I can't comment on that. Sounds like a nasty kernel bug though -- Linux implements AF_UNIX sockets as actual filesystem objects (so you go through VFS implicitly to interact with them).
Re:Guile security vulnerability with listening on localhost ... by caf on Saturday October 15, 2016 @09:04AM (#12713801)
It does work on FreeBSD now at least.

It wasn't a bug, though - just a questionable design (POSIX still doesn't mandate how filesystem permissions interact with connect() on AF_UNIX sockets AFAICS).

Re:Guile security vulnerability with listening on localhost ... by flukus on Friday October 14, 2016 @12:32AM (#12706150)
Someone logged in to the machine likely has enough access to make this attack irrelevant.
Re:Guile security vulnerability with listening on localhost ... by Arnt on Friday October 14, 2016 @03:01AM (#12706517)
Even HN has enough access to your machine. Your browser is showing you this page, the page may contain javascript (probably does, feh), and the javascript can retrieve http://localhost:43278/this/that.
Re:Guile security vulnerability with listening on localhost ... by tmsbrg on Friday October 14, 2016 @09:43AM (#12707986)
That doesn't even require JavaScript, does it? Just `<img src="http://localhost..."/>`.
Re:Guile security vulnerability with listening on localhost ... by Arnt on Saturday October 15, 2016 @05:44AM (#12713407)
I suppose you're right.

Although for the good stuff you want POST. With POST and an error-tolerant SMTP server you can send mail, I imagine other kinds of servers might be equally accommodating.

Re:Guile security vulnerability with listening on localhost ... by cheiVia0 on Friday October 14, 2016 @03:15AM (#12706554)
Not if you have noscript and the ABE protection turned on.
Re:Guile security vulnerability with listening on localhost ... by JoshTriplett on Friday October 14, 2016 @03:09AM (#12706537)
Not necessarily; unless they have root, they likely don't have permission to run as your user account, only their own.
Re:Guile security vulnerability with listening on localhost ... by 0x0 on Friday October 14, 2016 @07:52AM (#12707489)
Sounds very similar to the emergency patch issued for Android Studio and IntelliJ IDEA back in May, https://blog.jetbrains.com/blog/2016/05/11/security-update-f...
Re:Guile security vulnerability with listening on localhost ... by fulafel on Friday October 14, 2016 @01:36AM (#12706310)
Clojure should pick up on this too.
Re:Guile security vulnerability with listening on localhost ... by aardvark179 on Friday October 14, 2016 @06:27AM (#12707160)
There is https://github.com/monsanto/nreplds but it requires some native code, and obviously isn't a solution for those on Windows. I'm not sure how vulnerable nRepl is to http attacks as I don't think either of its default transports would accept or filter out http commands.
Re:Guile security vulnerability with listening on localhost ... by fulafel on Friday October 14, 2016 @07:31AM (#12707395)
I'm not so sure, certainly one of the two socket protocols is vulnerable (the "tty" one) judging by what the regular repl does with '' GET /%20(println"hello") HTTP/1.0 '' and it's somewhat likely that you could get through the bencode transport too.
Re:Guile security vulnerability with listening on localhost ... by l_zzie on Friday October 14, 2016 @11:50AM (#12708892)
I tried to get nrepl to accept http requests once and I couldn't make it validate anything. (But of course I'd love to see someone manage to do it...)