News for hackers. Stuff that matters.
Re:Why Is This Website Port Scanning Me? by souterrain on Wednesday May 20, 2020 @10:02AM (#23246861)
The greater issue is that browsers are allowing code executing from the public Internet scope (scope meaning security domain) network access to the localhost scope or the Intranet scope (RFC1918 addresses.)

If anything, this should require very explicit permission granting from the user. I’d prefer it be something more like an undocumented toggle accessible solely to developer types.

Re:Why Is This Website Port Scanning Me? by marcosdumay on Wednesday May 20, 2020 @10:38AM (#23247326)
> to the localhost scope or the Intranet scope

That's too little. All access from a different origin should be blocked by default, not only to local nets.

Re:Why Is This Website Port Scanning Me? by souterrain on Wednesday May 20, 2020 @10:43AM (#23247406)
I stand corrected. I think yours is the correct approach.

How shall origin be defined? I can envision the likes of Microsoft which have many, many second-level domains making calls between them.

We can’t allow the site itself to grant access. How would this be managed, other than “please stop and think what a domain name is supposed to be before spraying your product across twelve of them?”

Re:Why Is This Website Port Scanning Me? by derefr on Wednesday May 20, 2020 @12:19PM (#23248683)
To be clear, evil.com can define sub.evil.com to resolve to 127.0.0.1. You basically can’t look at domains to mean anything much. You have to look at IP addresses.

(Which is in turn made harder by IPv6 public addressing, where you can’t just block the private IP range because you might not be behind a NAT in the first place, instead only behind a firewall. So your address A::B, can route to your Intranet peer A::C, which isn’t public-routable, but is a public address. But there’s nothing, other than the firewall, that says that that’s not a public address. It’s a hard problem!)

Re:Why Is This Website Port Scanning Me? by tylerhou on Wednesday May 20, 2020 @05:23PM (#23251967)
To add on to your point, even if you allow evil.com to only access evil.com and not any subdomains, your browser is still vulnerable because of short TTLs on DNS resolution.

evil.com can set a short DNS TTL, and after you access it, it can rebind its address to 127.0.0.1. Then subsequent requests to evil.com go to localhost (e.g. fetch("evil.com", ...) on evil.com will go to 127.0.0.1 if the DNS rebound successfully).

Caching a website's IP on first use doesn't help, either, because it breaks long sessions on websites that use DNS rebinding for legitimate purposes (load balancing, fallover).

The only real way to fix this is for the local webserver to check the Host header on the HTTP request... or look at IP addresses. But building a global registry of IP addresses is hard, so we're stuck with trusting application developers (and malware writers) who run servers on localhost to use good security practices.

Re:Why Is This Website Port Scanning Me? by khc on Wednesday May 20, 2020 @05:45PM (#23252248)
This would prevent most users from visiting that site (since most of the time it will resolve to 127.0.0.1)
Re:Why Is This Website Port Scanning Me? by roywiggins on Wednesday May 20, 2020 @06:38PM (#23252828)
Evil.com could be set to resolve normally but redirect you to <plausible random word>.evil.com, which resolves normally once and then performs the attack, leaving evil.com able to keep serving new visitors.
Re:Why Is This Website Port Scanning Me? by johncolanduoni on Wednesday May 20, 2020 @04:28PM (#23251384)
We already have a notion of origin that is used for most of the browser security policies (exact match of domain, protocol, port). Websockets allow servers to enforce this policy by sending an Origin header, but unfortunately observing the error messages/timing still allows you to determine if the port is open at the transport layer even if you can’t establish a connection. Since websockets routinely need to connect to different origins (they can’t be routed exactly like normal requests, though many CDNs/reverse proxies can handle both), browsers would need to remove the information leak themselves by normalizing error messages and timing across failures.
Re:Why Is This Website Port Scanning Me? by marcosdumay on Wednesday May 20, 2020 @10:55AM (#23247571)
Granting access down seems ok to me. To make it really generic, you would need a way to query the upper domain if accessing a sibling is ok.

The process is different enough from cookies to warrant another large discussion about how to do it, with plenty of trial and errors. But the stakes are much lower, as in the worst case the user will get a dialog, instead of a site being broken.

Re:Why Is This Website Port Scanning Me? by oplav on Wednesday May 20, 2020 @10:41AM (#23247387)
That's what CORS is for, but it appears that there is no CORS for WebSockets.
Re:Why Is This Website Port Scanning Me? by souterrain on Wednesday May 20, 2020 @10:44AM (#23247423)
CORS is not in the hands of the user. I don’t want a CORS policy authorizing access to my intranet or localhost.
Re:Why Is This Website Port Scanning Me? by kevingadd on Wednesday May 20, 2020 @03:27PM (#23250725)
CORS is set by the target, so localhost CORS policy is directly in the hands of the user. intranet CORS policy is set by whoever operates that intranet service
Re:Why Is This Website Port Scanning Me? by souterrain on Wednesday May 20, 2020 @04:08PM (#23251176)
You’re right; a bit of a brain fail there for me.

Still, doesn’t mitigate attacks against non-HTTP speakers.

Re:Why Is This Website Port Scanning Me? by johncolanduoni on Wednesday May 20, 2020 @04:31PM (#23251419)
It does in the sense that you won’t be able to control the websockets payload, so the target server generally won’t respond. The problem here is that the information leak is happening prior to any data being sent over TCP, so the fact that the server will drop the connection as invalid doesn’t help.
Re:Why Is This Website Port Scanning Me? by oplav on Wednesday May 20, 2020 @10:59AM (#23247626)
If the user decides to run a service on their intranet or localhost with a wide open CORS policy, isn't that their choice?

Forgoing CORS and making all inter domain requests user opt-in would make the web experience a lot worse, IMO. Making all intranet or localhost requests user opt-in seems less disruptive.

Re:Why Is This Website Port Scanning Me? by souterrain on Wednesday May 20, 2020 @11:38AM (#23248162)
However, TCP sockets can't publish CORS policies.

In the case of scanning, a CORS denial can still reveal information about the user's internal network, as a CORS denial is a different result than a network timeout or a TCP RST.

Re:Why Is This Website Port Scanning Me? by xg15 on Wednesday May 20, 2020 @10:45AM (#23247431)
WS does have its own way of cross-domain opt-in. I think it users slightly different headers than CORS for historical reasons but effective does the same.

That a script is able to gather information about an origin that did not it in seems like a serious bug to me.

Re:Why Is This Website Port Scanning Me? by johncolanduoni on Wednesday May 20, 2020 @04:34PM (#23251448)
This is because websockets were created after the same origin policy, so they have always sent the origin header that allows the server to filter connections. CORS was only needed because the browsers were adding the same origin policy to HTTP requests that had historically never had it, so they needed some set of rules (and overrides for them) that didn’t break existing websites.
Re:Why Is This Website Port Scanning Me? by gfxgirl on Wednesday May 20, 2020 @09:49PM (#23254080)
CORS has nothing to help with here. The site doing the scanning is not able to make connections. Rather it's only able to tell if the port is listening or not. CORS would still be listening so they'd get the same info they're getting now.
Re:Why Is This Website Port Scanning Me? by api on Wednesday May 20, 2020 @10:05AM (#23246896)
Yeah, that's the best solution. It should be like microphone or camera access. It should say "this web site is attempting to access a resource on your local system / network."

I don't think you need to overdo it in terms of making the warning red, etc. Just a popup will really discourage people from trying to use this for fingerprinting.

BTW the site says:

"Port scanning is malicious." I don't agree. There are many many things that can look like a port scan but are not malicious, most notably NAT traversal attempts by WebRTC, games, chat apps, and so on.

Re:Why Is This Website Port Scanning Me? by grendelt on Wednesday May 20, 2020 @03:46PM (#23250936)
Right. "it is clearly malicious behavior and may fall on the wrong side of the law."

It's not against the law. It might be _shady_ but it's not illegal. When I'm teaching cyber intro classes, I let folks know portscanning is NOT illegal but shady. It's like going to a business after hours. It's not illegal to rattle doors and windows to see if they're locked. The police might have a different take on it, but it's not illegal.

Re:Why Is This Website Port Scanning Me? by fossuser on Wednesday May 20, 2020 @04:16PM (#23251249)
Yeah - if anything this post is evidence of a use case that isn't malicious.

While it can be used to get information to bad things, it itself can be used for good things too.

Re:Why Is This Website Port Scanning Me? by csagan5 on Wednesday May 20, 2020 @07:22PM (#23253193)
Exactly, port scans on my public IP address are not an attack, but crossing the boundary to my localhost and private networks is malicious behavior.
Re:Why Is This Website Port Scanning Me? by titzer on Thursday May 21, 2020 @12:07AM (#23254693)
Serves you right for browsing the web, you dumb dummy! /s
Re:Why Is This Website Port Scanning Me? by marcojrfurtado on Wednesday May 20, 2020 @10:27AM (#23247175)
There are legitimate reasons for port scanning, but I'm not sure most websites out there are using it for noble purposes. I guess browsers could allow it based on explicit permission from the user, just like it's already done for microphone and camera.
Re:Why Is This Website Port Scanning Me? by souterrain on Wednesday May 20, 2020 @10:33AM (#23247266)
Port scanning from a user’s browser is effectively sneaking behind a user’s firewall. The only legitimate reasons I can envision are security research, and this, to me, is such a small edge case that I’m not sure such access is ever warranted.

I’d be all for a user notification that says “fnord.com wants to access 192.168.0.10 on tcp/443, which seems to be a web server on your home/work network. Are you sure you want to allow this?” I’d want to see this for each new access request, such that port scanning would not be a use case that was supported.

Sure, have an about:config toggle to shut this off, with appropriate warnings.

Re:Why Is This Website Port Scanning Me? by kchr on Wednesday May 20, 2020 @12:17PM (#23248644)
This. It could even have a "remember my choice for this domain/subdomain".
Re:Why Is This Website Port Scanning Me? by 101404 on Thursday May 21, 2020 @04:38AM (#23256129)
I wonder if there is a browser add-on for that...?
Re:Why Is This Website Port Scanning Me? by pantalaimon on Wednesday May 20, 2020 @05:03PM (#23251784)
Yea this is very surprising. I run a file server in my local network. There is no access control on it because it’s behind my router’s firewall, but everyone in the LAN can access it.

I find it very surprising that now any random website can access it with no oversight. Why worry about spectre and meltdown when such blatant backdoors are implemented in browsers?!

Re:Why Is This Website Port Scanning Me? by dreamcompiler on Wednesday May 20, 2020 @11:09PM (#23254461)
Does your file server speak HTTP? If so you might have a problem. If not, it sounds like it's inaccessible to this attack, except to discover that it exists.
Re:Why Is This Website Port Scanning Me? by zrobotics on Wednesday May 20, 2020 @10:38AM (#23247335)
I'm curious, what would be a good reason to do this? I'm not creative enough to think of anything this enables a site to do that isn't malicious. If I'm running a service on localhost, and that service needs to communicate with the site I'm browsing, surely I could just direct that service to communicate with the site itself.

For instance, if I'm running a local chat application and need it to communicate with the web version, why does the website need to be able to port scan to accomplish this? I can think of other ways to accomplish this that are a lot more secure.

Re:Why Is This Website Port Scanning Me? by tlb on Wednesday May 20, 2020 @10:46AM (#23247459)
Ubiquiti routers have a fairly magical browser SPA that can run on their domain and talk to local routers. It involves webrtc connections to local addresses.

But I think if same-origin were enforced more strictly, they could have found another way.

Re:Why Is This Website Port Scanning Me? by Macha on Wednesday May 20, 2020 @12:38PM (#23248923)
Huh, I never looked but always assumed this was proxying through the controller.
Re:Why Is This Website Port Scanning Me? by tlb on Wednesday May 20, 2020 @01:33PM (#23249531)
It does this most of the time, either through the cloud or direct to the controller. But during setup of the first device on a network it does something direct from the browser to get it connected to the cloud.
Re:Why Is This Website Port Scanning Me? by SmallPeePeeMan on Wednesday May 20, 2020 @11:03AM (#23247681)
How is this different than the admin page for any other router brand? (SPA does not seem relevant to this discussion)
Re:Why Is This Website Port Scanning Me? by chrisshroba on Wednesday May 20, 2020 @04:52PM (#23251657)
I'm not defending this use case, but one example I can think of is that Spotify runs a local server so that websites you access can control it, e.g. if you are on Billboard looking at top music charts, clicking on a song could start the song in Spotify, and even embed a player in the web browser, without you needing to be signed into Spotify in your browser.

Here's an interesting tangential article about how they get around obstacles with SSL certs for localhost: https://letsencrypt.org/docs/certificates-for-localhost/

Re:Why Is This Website Port Scanning Me? by efokschaner on Wednesday May 20, 2020 @03:09PM (#23250547)
This might be banks trying to detect compromised users. Many "tech support" scams aim to get remote desktop access to users PC's and then have them log in to their bank while scammers are connected. I could see how banks looking for remote access software could be a useful heuristic in fighting this problem.
Re:Why Is This Website Port Scanning Me? by AnIdiotOnTheNet on Wednesday May 20, 2020 @11:03AM (#23247697)
Synology uses it to find your unconfigured device on the network for first time setup.
Re:Why Is This Website Port Scanning Me? by codezero on Wednesday May 20, 2020 @02:47PM (#23250328)
Here's my hypothesis: it's to detect bots.

Your bot is running a redis server locally, it allows local connections, because it's just a bot, boom.

Taking it a bit further, if we have really smart people involved: the timing of the attempted connections/rejections tell you something about the system that you can use to detect bots/scrapers.

Another example of this being used in the past is to scan for chrome extensions that scrape site content as well. I believe LinkedIn might have gotten hit hard for trying something similar but they were using extension URLs not localhost. Some extensions do spin up localhost services though.

Re:Why Is This Website Port Scanning Me? by asudosandwich on Wednesday May 20, 2020 @10:34AM (#23247284)
>> There are legitimate reasons for port scanning

Such as?

Re:Why Is This Website Port Scanning Me? by iso1631 on Thursday May 21, 2020 @07:59AM (#23257339)
Without context people might get the wrong end of the stick. There are legitimate reasons to use nmap on your own equipment, sure.

A port scanner running on a webpage without the users knowlege is never legitimate.

So the question is what legitimate reason is there for a port scanner running in a web browser with the users knowledge?

Re:Why Is This Website Port Scanning Me? by jimmaswell on Wednesday May 20, 2020 @10:50AM (#23247504)
IRC servers detect open proxies that way.
Re:Why Is This Website Port Scanning Me? by jorams on Wednesday May 20, 2020 @11:23AM (#23247975)
IRC servers don't run in a browser. Instead they scan ports from the outside, which is not a problem. Anything they find is open to the entire internet anyway.
Re:Why Is This Website Port Scanning Me? by bjt2n3904 on Wednesday May 20, 2020 @10:55AM (#23247566)
You run a network, and want to run a security audit. You need to know what devices are operating on it, and what services they are offering.

I don't get upset if someone opens and closes a socket to my VPS to see if something's there. My VPS is exposed to the internet. If a socket opens, it should be secure anyways. There's the chance nginx has an unknown zero day, but if I wanted to avoid that, I'd firewall it.

Things are a little less nice if you open a socket and start sending data to see what's there, assuming the server doesn't respond with a banner.

Re:Why Is This Website Port Scanning Me? by pdonis on Wednesday May 20, 2020 @11:55AM (#23248384)
> You run a network

That might be a reason for you to port scan your network.

It is not a reason for your website to port scan my network. Especially since your website running inside my browser is inside my firewall.

> and want to run a security audit

Then you use tools designed to run security audits. You don't open a huge security hole in everybody's browser just so you can use a browser to run a security audit.

Re:Why Is This Website Port Scanning Me? by cgranier on Wednesday May 20, 2020 @11:22AM (#23247963)
But that's a very different use case than having a website you visit portscan your computer (which I believe is what the user above you is referring to.

There's really no legitimate reason for eBay, or any other website, to portscan your computer. There's nothing there needed for browsing their website.

Re:Why Is This Website Port Scanning Me? by jschwartzi on Wednesday May 20, 2020 @11:20AM (#23247936)
What about port scanning your service before you've secured it during development? At some point we have to be able to trust the network we're on. It's ludicrous to expect everything to be configured correctly and securely right from the start especially if you're developing the thing being scanned while it's being scanned. I'd much rather websites not be able to scan my home or office network than have to treat that network like I treat the Internet.
Re:Why Is This Website Port Scanning Me? by ohazi on Wednesday May 20, 2020 @03:59PM (#23251074)
> I don't get upset if someone opens and closes a socket to my VPS to see if something's there. My VPS is exposed to the internet.

That's not what's happening here.

My laptop is not exposed to the public internet because it's behind a firewall / NAT. This is like going to my house, plugging a device into an Ethernet port on my router, and scanning my internal network from inside my network.

Except instead of them planting a device, all they have to do is get you to navigate to their webpage. They're getting your laptop to do the port scanning for them, and in so doing, they get access to your internal network. The problem isn't port scanning, the problem is NAT busting.

Re:Why Is This Website Port Scanning Me? by _bxg1 on Wednesday May 20, 2020 @11:03AM (#23247683)
Yes, it's very similar to CORS. They just need to block all localhost requests from non-localhost pages. Maybe carve out an exception for when the dev tools are open.
Re:Why Is This Website Port Scanning Me? by alex_duf on Wednesday May 20, 2020 @10:17AM (#23247039)
Agreed, or at least disabling localhost and 192.168.0.1 and whatever that is in IPV6
Re:Why Is This Website Port Scanning Me? by pantalaimon on Wednesday May 20, 2020 @04:56PM (#23251694)
You will usually have a public address with IPv6
Re:Why Is This Website Port Scanning Me? by n0tam3m3 on Wednesday May 20, 2020 @10:19AM (#23247078)
The company may be interested in whether they want to grant access to the user to access to their systems. Does the user shoulder any responsibility?
Re:Why Is This Website Port Scanning Me? by imglorp on Wednesday May 20, 2020 @10:26AM (#23247165)
No, absolutely not.

It shouldn't matter what malware is on a client device as long as the client has authenticated; the server/company/ebay should be protecting their API from abuse at the API layer, not the client layer.

Re:Why Is This Website Port Scanning Me? by souterrain on Wednesday May 20, 2020 @10:38AM (#23247334)
I think what you’re saying is the user might be an employee on some internal trusted company network. The employer should have control of that browser (and entire endpoint), otherwise the network should likely not be considered trusted. So, in this case, no, the user shouldn’t have the ability to authorize this; the administrator of that browser should.

Know your network.

Re:Why Is This Website Port Scanning Me? by 3fe9a03ccd14ca5 on Wednesday May 20, 2020 @04:17PM (#23251253)
Consent.