Skip to content
This repository has been archived by the owner on Nov 6, 2023. It is now read-only.

Block FTP requests if "Block all unencrypted requests" is on #11738

Closed
wants to merge 12 commits into from
Closed

Block FTP requests if "Block all unencrypted requests" is on #11738

wants to merge 12 commits into from

Conversation

ghost
Copy link

@ghost ghost commented Aug 7, 2017

No description provided.

@J0WI
Copy link
Contributor

J0WI commented Aug 10, 2017

This should fix #2311

@J0WI
Copy link
Contributor

J0WI commented Aug 10, 2017

@Hainish can we ship this in the next release? I think this is a quite important feature.

@ghost ghost mentioned this pull request Aug 10, 2017
@ghost
Copy link
Author

ghost commented Aug 10, 2017

@Hainish Just test it thoroughly, I don't want any bugs to end up in the release because of me. Remember the #10852? I didn't test it at all, same with this one. I rely on you testing it.

@ghost
Copy link
Author

ghost commented Aug 10, 2017

@J0WI Add this to "Work in Progress" in your kanban I guess.

Copy link
Member

@Hainish Hainish left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Other than the question LGTM.

!/\.onion$/.test(uri.hostname) &&
!/^localhost$/.test(uri.hostname) &&
!/^127(\.[0-9]{1,3}){3}$/.test(uri.hostname) &&
!/^0\.0\.0\.0$/.test(uri.hostname)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why remove this?

Copy link
Author

@ghost ghost Aug 15, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Hainish 0.0.0.0 is not a valid IPv4 address. Not sure why we have it here.

Copy link
Author

@ghost ghost Aug 15, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also changed the regexp for loopback IP addresses just now.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is a valid IP address. See https://en.wikipedia.org/wiki/0.0.0.0

In the Internet Protocol Version 4, the address 0.0.0.0 is a non-routable meta-address used to designate an invalid, unknown or non-applicable target. To give a special meaning to an otherwise invalid piece of data is an application of in-band signaling.

In the context of servers, 0.0.0.0 means "all IPv4 addresses on the local machine". If a host has two IP addresses, 192.168.1.1 and 10.1.2.1, and a server running on the host listens on 0.0.0.0, it will be reachable at both of those IPs.

For instance, setting up a simple local webserver with python is by default accessible over 0.0.0.0:

user@https-everywhere ~/blah $ python -m SimpleHTTPServer &
[1] 16779
user@https-everywhere ~/blah $ Serving HTTP on 0.0.0.0 port 8000 ...

user@https-everywhere ~/blah $ curl 0.0.0.0:8000
127.0.0.1 - - [15/Aug/2017 11:27:48] "GET / HTTP/1.1" 200 -
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"><html>
<title>Directory listing for /</title>
<body>
<h2>Directory listing for /</h2>
<hr>
<ul>
<li><a href="default.rulesets.gz.base64">default.rulesets.gz.base64</a>
<li><a href="rulesets-signature.sha256.base64">rulesets-signature.sha256.base64</a>
<li><a href="rulesets-timestamp">rulesets-timestamp</a>
</ul>
<hr>
</body>
</html>
user@https-everywhere ~/blah $

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Hainish Thanks for useful information!

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Hainish Done.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Hainish Chrome returns ERR_ADDRESS_INVALID if you attempt to visit http://0.0.0.0/ though.

@@ -568,7 +566,7 @@ function onBeforeRedirect(details) {

// Registers the handler for requests
// See: https://github.com/EFForg/https-everywhere/issues/10039
wr.onBeforeRequest.addListener(onBeforeRequest, {urls: ["*://*/*"]}, ["blocking"]);
wr.onBeforeRequest.addListener(onBeforeRequest, {urls: ["http://*/*", "https://*/*", "ftp://*/*"]}, ["blocking"]);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why change this back to http://*/* and https://*/* rather than keep *://*/*? Is this just for readability?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed.

@Hainish
Copy link
Member

Hainish commented Aug 15, 2017

This seems not to be blocking unencrypted ftp requests when I access e.g. ftp://mirror.fra10.de.leaseweb.net/centos/

@Hainish
Copy link
Member

Hainish commented Aug 15, 2017

For either Chromium or Firefox. It also doesn't work when I switch the match pattern to <all_urls>

@Hainish
Copy link
Member

Hainish commented Aug 17, 2017

This is probably a bug in the WebExtensions APIs. This would be a good feature to have, let's open bugs the respective implementations.

@ghost
Copy link
Author

ghost commented Aug 17, 2017

@Hainish I found what caused the problem: sloppy code in onBeforeRequest function. Expect fix soon. WebExtensions is not to blame.

@ghost
Copy link
Author

ghost commented Aug 19, 2017

@Hainish Done. Test and if there are no problems, merge.

@ghost
Copy link
Author

ghost commented Aug 19, 2017

@Hainish Can you figure out why the tests fail? My testing can't find any issues.

@Hainish
Copy link
Member

Hainish commented Aug 23, 2017

Re-running seems to have resolved the issue

@Hainish
Copy link
Member

Hainish commented Aug 23, 2017

Testing again with ftp://mirror.fra10.de.leaseweb.net/centos/ I see the same behavior - this request is not blocked. It is a problem with WebExtensions. Add the following lines to the top of onBeforeRequest:

console.log('GOT HERE');
console.log(details);

With ftp URLs, this is never triggered.

@ghost
Copy link
Author

ghost commented Aug 23, 2017

@Hainish Try with an extension that cancels all requests.

@Hainish
Copy link
Member

Hainish commented Aug 24, 2017

The hook itself doesn't work.

@ghost
Copy link
Author

ghost commented Aug 24, 2017

@Hainish File a bug on Chromium and Firefox.

@ghost
Copy link
Author

ghost commented Aug 25, 2017

Blocked by WebExtensions flaw.

@ghost ghost closed this Aug 25, 2017
This pull request was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants