lantern icon indicating copy to clipboard operation
lantern copied to clipboard

ensure lantern does not leak browsing to proxied domains

Open lanterndev opened this issue 14 years ago • 37 comments

  1. user in get mode requests a page from a domain on the proxied sites list
  2. request is encrypted and rerouted to a lantern peer, hiding its destination domain from intermediaries
  3. page loads, references a resource on a domain which is not on the proxied sites list
  4. browser requests the referenced resource with a referer header referring to the page that was just proxied

Lantern should proxy the request to the referenced resource, even though its domain is not on the proxied sites list, because its referrer was a proxied request. In other words, Lantern should proxy any request to a domain on the proxied sites list, or with a referer header whose domain is on the proxied sites list.

Update:

Impossible with PAC files and for https requests. But we can and should strip referer headers referencing proxied sites from http requests.

lanterndev avatar Nov 09 '12 18:11 lanterndev

Hey just thought of an interesting way to do this:

  1. Have the PAC file point all "normal" requests through lantern.
  2. For anything not on the whitelist, have Lantern send a redirect with some special token in the URI
  3. Have the PAC file always look for that and send the request it directly when it sees it. Have it strip it if possible, but otherwise make sure it's somehow innocuous.

That would allow Lantern to also strip referers or whatever else, potentially giving us the best of both worlds.

Worth playing with at least!

myleshorton avatar Feb 07 '13 03:02 myleshorton

hey @myleshorton, so something like:

function FindProxyForURL(url, host) {
  if (host === 'localhost' || host === '127.0.0.1' || isFlagged(url))
    return 'DIRECT';
  return 'PROXY 127.0.0.1:8787';
}

function isFlagged(url) {
  // check for some modification to url lantern made to indicate the request should go direct
}

? I don't think it's possible for the PAC file to strip the token from the url, all it gets to say is 'PROXY' or 'DIRECT', so we'd be sending the token on every direct request. The only way of flagging a url I can think of would be adding a query string parameter, but that could mess with application behavior, and also might make it much more obvious we're running Lantern.

That aside, I'm not seeing how this is better than just ditching PAC files and doing it all from Java, since in this design every eventually direct request has to first go through Lantern anyway. Am I missing something?

lanterndev avatar Feb 07 '13 17:02 lanterndev

http://findproxyforurl.com/pac-functions/ and other pages on that site are a good reference

lanterndev avatar Feb 07 '13 18:02 lanterndev

Right the only other thing I can think of other than query string is a fragment identifier.

It would be better because then the browser can go directly -- all the things Chrome does from your Chrome architecture doc, for example, many of which we'd otherwise be bypassing by relaying everything through Lantern. So it would reduce load on Lantern but also result in pages loading faster -- i.e. one of the main reasons we switched to the pac file in the first place.

myleshorton avatar Feb 07 '13 19:02 myleshorton

Right the only other thing I can think of other than query string is a fragment identifier.

Since browsers don't send the fragment to the server, I'm guessing the url they pass into FindProxyForURL wouldn't have the fragment either unfortunately. I tried to verify this using http://findproxyforurl.com/debug-pac-file/ but I couldn't get it to work. Can you?

It would be better because then the browser can go directly -- all the things Chrome does from your Chrome architecture doc, for example, many of which we'd otherwise be bypassing by relaying everything through Lantern. So it would reduce load on Lantern but also result in pages loading faster -- i.e. one of the main reasons we switched to the pac file in the first place.

But it can only go directly after first going through Lantern and getting the special redirect response with the tagged url, right? So every direct request has a preceding proxied request, which actually ends up slower. Maybe I'm just still not understanding the idea. Sorry if I'm not.

lanterndev avatar Feb 07 '13 20:02 lanterndev

Since browsers don't send the fragment to the server, I'm guessing the url they pass into FindProxyForURL wouldn't have the fragment either unfortunately. I tried to verify this using http://findproxyforurl.com/debug-pac-file/ but I couldn't get it to work. Can you?

I'm not actually working on this ticket now -- it's just an idea.

But it can only go directly after first going through Lantern and getting the special redirect response with the tagged url, right? So every direct request has a preceding proxied request, which actually ends up slower. Maybe I'm just still not understanding the idea. Sorry if I'm not.

Correct, but that redirect is extremely cheap -- probably 600 bytes total over localhost. All the heavy lifting is the actual servicing of the real request and associated responses, which I trust the browser to do better and faster than Lantern. If you're saying it's slower than the browser just accessing the page directly, then yeah it definitely would be, but we don't have a solution to this ticket that does that.

myleshorton avatar Feb 07 '13 20:02 myleshorton

Oh yeah, I thought any form of sending a direct request to Lantern first would result in an undesirable slowdown, but glad to hear that's not the case. Thanks for helping me understand.

lanterndev avatar Feb 07 '13 20:02 lanterndev

Do we have any sense of the latency/performance penalty incurred by passing requests through the local proxy?

On Thu, Feb 07, 2013 at 12:49:15PM -0800, myleshorton wrote:

Since browsers don't send the fragment to the server, I'm guessing the url they pass into FindProxyForURL wouldn't have the fragment either unfortunately. I tried to verify this using http://findproxyforurl.com/debug-pac-file/ but I couldn't get it to work. Can you?

I'm not actually working on this ticket now -- it's just an idea.

But it can only go directly after first going through Lantern and getting the special redirect response with the tagged url, right? So every direct request has a preceding proxied request, which actually ends up slower. Maybe I'm just still not understanding the idea. Sorry if I'm not.

Correct, but that redirect is extremely cheap -- probably 600 bytes total over localhost. All the heavy lifting is the actual servicing of the real request and associated responses, which I trust the browser to do better and faster than Lantern. If you're saying it's slower than the browser just accessing the page directly, then yeah it definitely would be, but we don't have a solution to this ticket that does that.


Reply to this email directly or view it on GitHub: https://github.com/getlantern/lantern/issues/465#issuecomment-13258792

ghostdance avatar Feb 07 '13 21:02 ghostdance

It might make sense, since we're Chrome-focused, to just build this into an extension using this API:

http://developer.chrome.com/extensions/webRequest.html

The only worry, to me, is that we're increasingly painting ourselves into a tight corner in that Lantern will only work as expected in one browser. If we have any intention of supporting any other applications, we'll have built a system that makes adapting to those use cases extremely difficult if not impossible.

On Thu, Feb 07, 2013 at 12:49:15PM -0800, myleshorton wrote:

Since browsers don't send the fragment to the server, I'm guessing the url they pass into FindProxyForURL wouldn't have the fragment either unfortunately. I tried to verify this using http://findproxyforurl.com/debug-pac-file/ but I couldn't get it to work. Can you?

I'm not actually working on this ticket now -- it's just an idea.

But it can only go directly after first going through Lantern and getting the special redirect response with the tagged url, right? So every direct request has a preceding proxied request, which actually ends up slower. Maybe I'm just still not understanding the idea. Sorry if I'm not.

Correct, but that redirect is extremely cheap -- probably 600 bytes total over localhost. All the heavy lifting is the actual servicing of the real request and associated responses, which I trust the browser to do better and faster than Lantern. If you're saying it's slower than the browser just accessing the page directly, then yeah it definitely would be, but we don't have a solution to this ticket that does that.


Reply to this email directly or view it on GitHub: https://github.com/getlantern/lantern/issues/465#issuecomment-13258792

ghostdance avatar Feb 07 '13 21:02 ghostdance

@ghostdance Not sure without testing on the performance penalty, but I would guess something like 50 milliseconds?

The WebRequests stuff definitely looks cool, and I would agree the big issue is that it only works in Chrome. With the extension generally that's totally cool because if people don't want care about the extension and just want to use another browser they can, but this change would really prevent them from ever using another browser, which is a path I'm not sure we're ready to go down.

myleshorton avatar Feb 10 '13 14:02 myleshorton

@myleshorton To me, it's preferable to make the local Lantern proxy as user-agent agnostic as possible.

Is it worth it to add an exit handler to the local proxy's dispatcher and check load times? I started this the other day and added referer sniffing, but I need to do a bit more to make sure I'm setting up the Netty pipeline properly. Any guidance is very welcome.

On Sun, Feb 10, 2013 at 06:32:35AM -0800, myleshorton wrote:

@ghostdance Not sure without testing on the performance penalty, but I would guess something like 50 milliseconds?

The WebRequests stuff definitely looks cool, and I would agree the big issue is that it only works in Chrome. With the extension generally that's totally cool because if people don't want care about the extension and just want to use another browser they can, but this change would really prevent them from ever using another browser, which is a path I'm not sure we're ready to go down.


Reply to this email directly or view it on GitHub: https://github.com/getlantern/lantern/issues/465#issuecomment-13350583

ghostdance avatar Feb 10 '13 16:02 ghostdance

@myleshorton: There's a WIP for this on the referer-sniff branch.

ghostdance avatar Feb 11 '13 20:02 ghostdance

@ghostdance I'm generally all for tracking metrics, so totally cool to add more tracking in there. I don't think there's any reason to think Lantern's slow -- it's more likely users were experiencing something like a memory leak that built up over time, but again challenging to reproduce and generally the thinking behind letting the browser do what it does best and not worrying about Lantern taking over some of those functions.

myleshorton avatar Feb 12 '13 01:02 myleshorton

@myleshorton I added a exit/pass-through handler in the local proxy dispatcher on the referer-sniff branch. Is this worth pursuing?

ghostdance avatar Feb 12 '13 02:02 ghostdance

Maybe. What does the referrer-sniff branch do?

On Monday, February 11, 2013, ghostdance wrote:

@myleshorton https://github.com/myleshorton I added a exit/pass-through handler in the local proxy dispatcher on the referer-sniff branch. Is this worth pursuing?

— Reply to this email directly or view it on GitHubhttps://github.com/getlantern/lantern/issues/465#issuecomment-13415035.

Sent from Gmail Mobile

myleshorton avatar Feb 12 '13 04:02 myleshorton

Hey @myleshorton, the proxiedSites modal says "Content on other sites included in pages on these sites will also be proxied automatically." But that's not true anymore is it? Should I just hide that message until this is fixed?

lanterndev avatar Mar 13 '13 04:03 lanterndev

Yeah I guess you should. To me that's one of our top priorities after Astell, but for now it makes sense to take that out.

On Tue, Mar 12, 2013 at 9:05 PM, skivvies [email protected] wrote:

Hey @myleshorton https://github.com/myleshorton, the proxiedSites modal says "Content on other sites included in pages on these sites will also be proxied automatically." But that's not true anymore is it? Should I just hide that message until this is fixed?

— Reply to this email directly or view it on GitHubhttps://github.com/getlantern/lantern/issues/465#issuecomment-14823376 .

myleshorton avatar Mar 13 '13 05:03 myleshorton

Ok, commented out for now. We should uncomment it when this issue is fixed.

lanterndev avatar Mar 13 '13 15:03 lanterndev

The only way of flagging a url I can think of would be adding a query string parameter, but that could mess with application behavior, and also might make it much more obvious we're running Lantern.

Another way to transform a URL in a way that could be detected from the PAC file but without changing the meaning of the url is to do something like make the hostname all lowercase for urls that should go direct, and all caps for urls that should be sent upstream to a Lantern proxy, where they can get converted back to lowercase before being sent to the destination server to avoid detection.

I don't have any clever ideas for flagging hosts that don't have any letters in them, though.

lanterndev avatar Mar 15 '13 18:03 lanterndev

Now that's what I'm talking about - love it. Sneaky.

myleshorton avatar Mar 15 '13 22:03 myleshorton