lantern icon indicating copy to clipboard operation
lantern copied to clipboard

Lantern throws a blank page instead of an error message if the user tries to go to an inexistent domain name.

Open xiam opened this issue 11 years ago • 33 comments

I disabled chained proxies and typed an inexistent domain name by mistake, Lantern gave me a blank page instead of telling me the domain could not be found.

I also tried with this hostname: bxhhs.co.eaa, same result.

Jul 15 16:20:01.775 - DEBUG balancer: balancer.go:96 Dialing tcp://bxhhs.co.eaa:80 with (trusted) fronted proxy at issue-2184.getiantem.org:443 using masquerade set testflare
Jul 15 16:20:02.112 - DEBUG enproxy: conn_intf.go:239 Failing on Dest: bxhhs.co.eaa:80    ProxyHost:     Unable to issue write request: Bad response status for read: 403 Forbidden
Jul 15 16:20:02.112 - DEBUG enproxy: conn_intf.go:239 Failing on Bad response status for read: 403 Forbidden
Jul 15 16:20:02.112 - ERROR flashlight.client: reverseproxy.go:186 http: proxy error: Dest: bxhhs.co.eaa:80    ProxyHost:     Unable to issue write request: Bad response status for read: 403 Forbidden

This happens when Lantern is using the fronting technique.

xiam avatar Jul 15 '15 16:07 xiam

I get this response with curl, using domain fronting and an inexistent domain. The browser shows the same result with and without lantern.

* Rebuilt URL to: asdfgfgg3gsagasg.com/
* Hostname was NOT found in DNS cache
*   Trying 127.0.0.1...
* Connected to 127.0.0.1 (127.0.0.1) port 8787 (#0)
> GET HTTP://asdfgfgg3gsagasg.com/ HTTP/1.1
> User-Agent: curl/7.37.1
> Host: asdfgfgg3gsagasg.com
> Accept: */*
> Proxy-Connection: Keep-Alive
>
< HTTP/1.1 500 Internal Server Error
< Date: Wed, 29 Jul 2015 17:01:41 GMT
< Content-Length: 0
< Content-Type: text/plain; charset=utf-8
<

uaalto avatar Jul 29 '15 17:07 uaalto

Interesting thanks guys. @xiam that 403 error you're seeing is super interesting too -- very odd you'd get a 403 of all errors. Could be another clue on #2395?

Actually @xiam it looks like you're running that against a test server. Can you update the enproxy server code on that machine to be the latest on valencia? That should give us more information in the response body assuming the 403 is from us and not CloudFlare.

myleshorton avatar Jul 29 '15 17:07 myleshorton

Sure, let's try @myleshorton

xiam avatar Jul 29 '15 17:07 xiam

Attaching my results using a recent lantern server built from the latest valencia code, skipping the CDN.

curl -x "127.0.0.1:8787" http://foo.bar --verbose
* Rebuilt URL to: http://foo.bar/
* Hostname was NOT found in DNS cache
*   Trying 127.0.0.1...
* Connected to 127.0.0.1 (127.0.0.1) port 8787 (#0)
> GET http://foo.bar/ HTTP/1.1
> User-Agent: curl/7.37.1
> Host: foo.bar
> Accept: */*
> Proxy-Connection: Keep-Alive
>
< HTTP/1.1 500 Internal Server Error
< Date: Wed, 29 Jul 2015 18:04:57 GMT
< Content-Length: 0
< Content-Type: text/plain; charset=utf-8
<
* Connection #0 to host 127.0.0.1 left intact

Lantern says:

Jul 29 18:07:53.597 - 4m47s DEBUG enproxy: conn_impl.go:179 Got OK from fronting provider
Jul 29 18:07:53.597 - 4m47s DEBUG enproxy: conn_impl_requests.go:51 Issued write request with result: <nil>
Jul 29 18:07:53.797 - 4m47s DEBUG detour: detour.go:132 Dial initially to foo.bar:80 failed: dial tcp: lookup foo.bar: no such host
Jul 29 18:07:53.797 - 4m47s ERROR flashlight.client: reverseproxy.go:186 http: proxy error: dial tcp: lookup foo.bar: no such host

And here's the blank page:

screen shot 2015-07-29 at 1 04 51 pm

Without Lantern we get another page, which is generated by the browser:

screen shot 2015-07-29 at 1 06 25 pm

Will try again with the CDN in the middle.

xiam avatar Jul 29 '15 18:07 xiam

Tested again, got a 403 with the CDN in the middle:

Jul 29 18:48:15.073 - 0m1s DEBUG balancer: balancer.go:96 Dialing tcp://foo.bar:80 with (trusted) fronted proxy at issue-2184.getiantem.org:443 using masquerade set cloudflare
Jul 29 18:48:15.074 - 0m1s DEBUG balancer: balancer.go:103 Successfully dialed to tcp://foo.bar:80 on pass 0
Jul 29 18:48:15.099 - 0m1s DEBUG fronted: dialer.go:228 Dialing geo.getiantem.org:80 with direct domain fronter
Jul 29 18:48:15.122 - 0m1s DEBUG enproxy: conn_impl.go:179 Got OK from fronting provider
Jul 29 18:48:15.122 - 0m1s DEBUG enproxy: conn_impl_requests.go:51 Issued write request with result: <nil>
Jul 29 18:48:15.202 - 0m1s DEBUG enproxy: conn_impl.go:179 Got OK from fronting provider
Jul 29 18:48:15.231 - 0m1s DEBUG enproxy: conn_impl.go:179 Got OK from fronting provider
Jul 29 18:48:15.231 - 0m1s DEBUG enproxy: conn_impl_requests.go:51 Issued write request with result: <nil>
Jul 29 18:48:15.242 - 0m1s DEBUG enproxy: conn_impl_requests.go:51 Issued write request with result: Bad response status for read from fronting provider: HTTP/1.1 403 Forbidden^M
Jul 29 18:48:15.242 - 0m1s Content-Length: 148^M
Jul 29 18:48:15.242 - 0m1s Cf-Ray: 20daff365d7c1822-MIA^M
Jul 29 18:48:15.242 - 0m1s Connection: keep-alive^M
Jul 29 18:48:15.242 - 0m1s Content-Type: text/plain; charset=utf-8^M
Jul 29 18:48:15.242 - 0m1s Date: Wed, 29 Jul 2015 18:48:15 GMT^M
Jul 29 18:48:15.242 - 0m1s Server: cloudflare-nginx^M
Jul 29 18:48:15.242 - 0m1s Set-Cookie: __cfduid=dbdc6b6437411682042a519bd6492cabd1438195695; expires=Thu, 28-Jul-16 18:48:15 GMT; path=/; domain=.getiantem.org; HttpOnly^M
Jul 29 18:48:15.242 - 0m1s ^M
Jul 29 18:48:15.242 - 0m1s Enproxy server responding Forbidden: Not allowed: Unable to resolve destination IP addr foo.bar: lookup foo.bar: No address associated with hostname
Jul 29 18:48:15.242 - 0m1s DEBUG enproxy: conn_intf.go:239 Failing on Dest: foo.bar:80    ProxyHost:     Unable to issue write request: Bad response status for read from fronting
Jul 29 18:48:15.242 - 0m1s Content-Length: 148^M

I enabled "Proxy All" on this test. With or without "Proxy All" the client still sees a 500 error with no content:

curl -x "127.0.0.1:8787" http://foo.bar --verbose
* Rebuilt URL to: http://foo.bar/
* Hostname was NOT found in DNS cache
*   Trying 127.0.0.1...
* Connected to 127.0.0.1 (127.0.0.1) port 8787 (#0)
> GET http://foo.bar/ HTTP/1.1
> User-Agent: curl/7.37.1
> Host: foo.bar
> Accept: */*
> Proxy-Connection: Keep-Alive
>
< HTTP/1.1 500 Internal Server Error
< Date: Wed, 29 Jul 2015 18:48:15 GMT
< Content-Length: 0
< Content-Type: text/plain; charset=utf-8
<
* Connection #0 to host 127.0.0.1 left intact

xiam avatar Jul 29 '15 18:07 xiam

Nice thanks @xiam that's fascinating. So the line:

Enproxy server responding Forbidden: Not allowed: Unable to resolve destination IP addr foo.bar: lookup foo.bar: No address associated with hostname

could entirely tell us what's up with #2395. Basically enproxy returns a 403 when it can't do a DNS lookup! That's coming from:

https://github.com/getlantern/lantern/blob/valencia/src/github.com/getlantern/fronted/server.go#L191

It's not clear what we should actually return in that case. Maybe the IETF's April Fool's "I am a teapot" 418 response?

myleshorton avatar Jul 29 '15 19:07 myleshorton

I'm also not really worried about the 500 Internal Server Error response I should mention. What would be a better response? What problem does it cause?

I guess it might be an opportunity for us to put up a cool Lantern-branded page but I'm not sure what else we would do. The browser itself fails pretty dramatically in that case with no proxy.

myleshorton avatar Jul 29 '15 19:07 myleshorton

Ha! Go supports status teapot!

https://golang.org/src/net/http/status.go

myleshorton avatar Jul 29 '15 20:07 myleshorton

I think it would be better if we show it to the user instead of the blank page they are getting when something like this happens.

I first found this error when I had a typo while typing a real URL, something like "bbc.co.ku" I was not aware of my typo after a more closer inspection, so I think that's the real world use case.

It's not clear what we should actually return in that case. Maybe the IETF's April Fool's "I am a teapot" 418 response?

Hah! Yeah, technically, there is no HTTP code for a failed DNS lookup, maybe just printing the 500 error along a description would be just fine for now :).

We can probably add a fancy error page later, I think the error message would be enough to tell the user that something went wrong.

xiam avatar Jul 29 '15 20:07 xiam

Actually, I'll try to take a stab a this one :), just to see how difficult this one could be.

xiam avatar Jul 29 '15 20:07 xiam

Honestly the much more important part of this is the 403 error. That's the #1 error in our logs right now, and this could be the entire cause. One simple change we could make would be to actually return the error message in the HTTP response body to the browser too -- that would significantly aid our debugging in general for all users who seem to get blank pages for some reason using Lantern.

I'm working on changing the 403 error on the server side right now, as actually a bunch of the server side error codes are way too coarse-grained.

Would you want to work on returning whatever the server returns in its response body for errors all the way up to the browser @xiam? That would also enable us to customize that page to look however we want on the server side going forward, but I think those types of changes are more important at this point than the look of the page itself.

myleshorton avatar Jul 29 '15 20:07 myleshorton

Would you want to work on returning whatever the server returns in its response body for errors all the way up to the browser? That would also enable us to customize that page to look however we want on the server side?

Good idea! Let's do that.

xiam avatar Jul 29 '15 20:07 xiam

Awesome! Great find by the way - I think these changes could make a really big difference.

myleshorton avatar Jul 29 '15 20:07 myleshorton

Just for the record it looks like when using reverseproxy the body is discarded: https://golang.org/src/net/http/httputil/reverseproxy.go#L148 the only thing that is written is a 500 staus message, that's why we got a "server status error" everytime, despite of the actual error message. In this case we'll have to modify our transport to be less strict.

xiam avatar Jul 29 '15 21:07 xiam

Oh that's super interesting @xiam. I think modifying the transport there might be an interesting change anyway, as those internal reverseproxy error messages are tricky to handle.

myleshorton avatar Jul 29 '15 21:07 myleshorton

We could also theoretically just write the HTTP response body in our Transport but otherwise leave things untouched...

myleshorton avatar Jul 29 '15 21:07 myleshorton

We could also theoretically just write the HTTP response body in our Transport but otherwise leave things untouched...

@myleshorton That's right we could also do that. Let me see what would be the cleanest solution that would require touching less code.

xiam avatar Jul 29 '15 21:07 xiam

Sounds great @xiam. I gotta say I'm super excited about this change -- I think it will make debugging with users much, much easier.

myleshorton avatar Jul 29 '15 21:07 myleshorton

The wrapper idea around RoundTripper did not work as I expected, this line:

res, err := rt.orig.RoundTrip(req)

Returns errors like dial tcp: lookup foo.bar: no such host or No dialers left to try on pass, but when an error is returned the res is always nil. This RoundTrip is invoked by reverseproxy.

I think the error we want to show is actually catched by a dialer before returning the net.Conn that the reverseproxy is going to use, so I guess I'll start checking that part.

xiam avatar Jul 29 '15 23:07 xiam

Found another (multiline) error message:

Dest: foo.bar:80    ProxyHost:     Unable to issue write request: Bad response status for read from fronting provider: HTTP/1.1 403 Forbidden^M
Content-Length: 0^M
Cf-Ray: XXX-MIA^M
Connection: keep-alive^M
Content-Type: text/plain; charset=utf-8^M
Date: Wed, 29 Jul 2015 23:53:41 GMT^M
Server: cloudflare-nginx^M
Set-Cookie: __cfduid=XXX; expires=Thu, 28-Jul-16 23:53:40 GMT; path=/; domain=.getiantem.org; HttpOnly^M
^M

I think the simplest thing right now would be using the transport to write the first line of the error message returned by the RoundTrip method. The user would see something like:

Dest: foo.bar:80    ProxyHost:     Unable to issue write request: Bad response status for read from fronting provider: HTTP/1.1 403 Forbidden

Except that would not give us fine grained control over the error we are showing to the user and it may even be more confusing in some cases.

xiam avatar Jul 30 '15 00:07 xiam