News for hackers. Stuff that matters.
Re:Dear Linux, Privileged Ports Must Die by antimeme on Thursday September 01, 2022 @01:36AM (#32672408)
This article is nonsense. Privileged ports are a security feature. They have literally nothing to do with mainframes. On multi-user systems, they're incredibly important because they give external clients confidence that the services provided on them are authorized by the system and not just by any user -- some of whom may not be as trustworthy as others. Most systems in this era of cheap hardware are single user, BUT NOT ALL SYSTEMS. It's fine for Windows and Mac OS to do without them and it's fine to configure your own Linux system to disable them if that's what you want, but it's completely insane to argue that they're a security flaw because some people work around them using insecure practices. There are plenty of secure ways to work around them, most obviously by USING A NON-PRIVILEGED PORT. Start your service on port 8080, for example, and give out a URL like http://example.com:8080/path. It's really that simple. Take the time to understand the actual purpose of a feature before urging others to abolish it.
Re:Dear Linux, Privileged Ports Must Die by ttiurani on Thursday September 01, 2022 @06:08AM (#32674309)
> Most systems in this era of cheap hardware are single user, BUT NOT ALL SYSTEMS

OP quite clearly argues that multi-user systems can still have the old behavior if they so choose with explicit configuration. OP makes an argument about what should be the sensible default in 2022, and who should do explicit configuration.

I think the point that nowadays easy single user linux configuration should be preferred over multi-user configurations is good.

IMO distros could make this easy by turning privileged ports into an (advanced) installation question. Then the clearly single-user-focused distros would default to 80, and the more server-oriented or conservative distros would default to the current behavior, but both could do which ever.

> Start your service on port 8080, for example.

In the era of Let's Encrypt, this is really about 80 and 443. The background for the OP is probably to host "normal" sites on single user hardware.

If you were to give out to non-technical users addresses like "http://example.org:8080" which then transform into "https://example.org:8443", that's just horrible UX. Those kinds of numbers in the URL probably also look to many people like someone is trying to hack them. Furthermore addresses are also communicated word-of-mouth "go to example dot org".

So no, using unprivileged ports is not an actual workaround for the use cases OP is referring to.

Re:Dear Linux, Privileged Ports Must Die by antimeme on Thursday September 01, 2022 @12:01PM (#32678365)
Stop pretending that non-technical users want to run web servers. That's just not a thing. What you're actually arguing is that some technical users are so important that making them tweak a default setting is too much to ask, but others are so insignificant that pulling the rug out from under them after decades of practice is perfectly reasonable. I disagree.

Do you not grasp WHY Let's Encrypt requires port 80 (for one particular challenge type)? Think about that for just one second. Okay I'll spell it out for you: the convention that ports under 1024 are privileged gives Let's Encrypt some confidence that privileged ports runs services sanctioned by the system administrator and not some tenant -- which is exactly the point I was making. So thanks for providing more support for my argument, I guess?

And while we're at it, can we stop pretending you care about user experience? You can't even be bothered to type those two words! You cite no studies and make no technical arguments. All you're offering is the claim that the default you prefer "should be preferred" based on your intuition.

I probably shouldn't even dignify your claim that people think port numbers in URLs mean they're being attacked with a response, but I'll bite. Do you have even a shred of evidence for this claim or did you just make it up on the spot? Obviously the latter, but if even if it were true the solution would be to educate people about what port numbers mean. Unless you want to argue that any feature of any internet service some people are confused about should be abolished? I guess we'll have to shut the entire internet down.

Changing the port number is a perfectly reasonable solution for many use cases, but it's far from the only option. Alternatives include CAP_NET_BIND_SERVICE, net.ipv4.ip_unprivileged_port_start, port mapping in containers and many more. Pick your favorite and stop wasting everyone's time.

Re:Dear Linux, Privileged Ports Must Die by throwaway09223 on Thursday September 01, 2022 @07:26AM (#32674868)
I think you're missing the fact that in your scenario services are started with explicit privileges by init. This has nothing to do with unprivileged login users.

Back in the day, init ran as root. Init ran services as root, and services were responsible for becoming another user if they didn't need root after binding a port. It was a very simple interface.

Nowadays we have much more complicated interfaces and as a result more flexibility. Init (now systemd) must still run as root, but we can tell the component that executes a service to drop privileges before the service is started. These privileges are also more granular: Root is no longer needed to bind to a low port: We only have to grant the CAP_NET_BIND capability, rather than running as a root user.

On top of this we now have network namespaces and containers, so services might be granted their own interfaces visible only to that service, with specific permissions tailored to only that service.

If you are running a persistent webserver you do not need to worry about whether or not unprivileged users can bind to port 443. The webserver is managed by init and the permissions granted to services are explicit and granular -- and typically all this is configured by the distro by default.

Re:Dear Linux, Privileged Ports Must Die by foldr on Thursday September 01, 2022 @09:44AM (#32676130)
>The webserver is managed by init and the permissions granted to services are explicit and granular -- and typically all this is configured by the distro by default.

Only if you're using a web server that's prepackaged by the distro.

Re:Dear Linux, Privileged Ports Must Die by ehutch79 on Thursday September 01, 2022 @11:18AM (#32677620)
If you're installing third party services, and exposing them to the internet, or even local networks, it's not out of line to expect you to know what you're doing. At least enough to turn off the 'dont shoot yourself in the foot' protections
Re:Dear Linux, Privileged Ports Must Die by foldr on Thursday September 01, 2022 @11:29AM (#32677802)
People who "don't know what they're doing" will just disable SELinux if it's too difficult to configure the policy that they want. It's better to make security policies easy to configure correctly so that more people do it correctly.

Also, what does "third party" really mean in this context? I am neither the author of the Linux distro that I'm using nor the web server that I want to use. It's all third party software from my point of view.

Re:Dear Linux, Privileged Ports Must Die by ehutch79 on Wednesday September 07, 2022 @10:44AM (#32751313)
You need some level of expertise to turn off selinux, or even know what it is. They know what they're doing enough to know the consequences if they can turn it off.

By third party, i mean stuff not in the distro. It's extra effort to install something else. You're likely to have at least a link to docs in your face when you went and got the binaries.

Re:Dear Linux, Privileged Ports Must Die by throwaway09223 on Thursday September 01, 2022 @03:53PM (#32682149)
Every casual user is using a distro packaged version. That's why distros exist.

If you're doing your own packaging then presumably you know how to invoke the server by creating a service file for systemd.

Re:Dear Linux, Privileged Ports Must Die by foldr on Friday September 02, 2022 @03:03AM (#32687531)
I don't think this is true in general. For example, in one instance I wanted to use caddy, which wasn't packaged for CentOS at the time. I don't think I had trouble getting it to run as a non-root user, but getting it to work with SELinux was a big PITA.

The Linux community seems to have a pervasive "if you're doing X then you should be able to Y" kind of attitude. But sometimes you just need to do X, and you know what you know.

Re:Dear Linux, Privileged Ports Must Die by throwaway09223 on Friday September 02, 2022 @09:12AM (#32690314)
That's totally unrelated to the topic of how services are invoked.

SELinux is indeed a PITA. I usually just turn it off.

Your complaint about the community says more about you than about the community. It's certainly not true as a rule.

Re:Dear Linux, Privileged Ports Must Die by foldr on Thursday September 01, 2022 @05:43AM (#32674134)
This was covered in the article, albeit a little sarcastically:

>And for the three folks in Finland who administer multi-user Linux instances and rely on privileged ports for their mainframe-era security properties, they can always run sysctl and set their port limit to 1024 as it was before.

If you wanted to block non-root users binding certain ports, you'd still be able to do so. It just doesn't make sense to have this as the default anymore, as it tends to cause more security issues that it prevents.

Re:Dear Linux, Privileged Ports Must Die by antimeme on Thursday September 01, 2022 @12:27PM (#32678804)
Not a LITTLE sarcastically, no.

No one has yet provided evidence that privileged ports create even a single security issue. While there's lots of huffing and puffing in the original article (including someone confusing privileged ports with IP based authentication, which is effectively dead), the closest it gets is to say that dropping privileges in a server is a pain. And then they go on to show off a one line configuration change that would disable privileged ports system wide. So do that if it makes sense for you.

What doesn't make sense would be to abandon decades of practice that real people (more than three in Finland, actually) rely upon because some people are too lazy to make a trivial change to their systems. And let's get real: 99.9% of people are never going to want to run a web server on their computers. You're just arguing that your portion of that 0.1% -- let's be a LITTLE sarcastic and call them five penguins in Antarctica! -- are more important than the rest.

Re:Dear Linux, Privileged Ports Must Die by foldr on Thursday September 01, 2022 @01:27PM (#32679861)
If the best you can say for the current defaults is that they're easy to change, then it's probably time to change the defaults.

The article doesn't just say that dropping privileges is a 'pain', but points out that a security model based on binding a port as root (or another specially privileged user) and then dropping privileges has been a persistent source of security issues. The article links to several detailed explanations of this (e.g. https://wibblement.blogspot.com/2021/11/the-persistent-idioc..., https://www.staldal.nu/tech/2007/10/31/why-can-only-root-lis...).

The one-line configuration change also doesn't work well if the service is executed via an interpreter or VM. Authbind also has its edge cases: https://www.reddit.com/r/golang/comments/cqlpnq/comment/ewyl...

Re:Dear Linux, Privileged Ports Must Die by _nalply on Thursday September 01, 2022 @02:03AM (#32672570)
You mean that you don't want all users who can login on your system to start something that listens on a port below 1024. I can understand that.
Re:Dear Linux, Privileged Ports Must Die by threatripper on Thursday September 01, 2022 @02:07AM (#32672599)
One example I can think of is a local server handling some sensitive stuff. E.g. a webserver for a CNC machine that takes a password to log in. If that webserver is offline another user could start their own webserver with a fake login prompt. Other users who go to http://localhost as usual would not notice.
Re:Dear Linux, Privileged Ports Must Die by bArray on Thursday September 01, 2022 @10:18AM (#32676549)
> It's fine for Windows and Mac OS to do without them and it's fine to configure your own Linux system to disable them if that's what you want, but it's completely insane to argue that they're a security flaw because some people work around them using insecure practices.

I guess we will also be making distros with `sudo` without a password to stop some people writing insecure scripts that try to pass it via plaintext stdin. This should be default for _every_ Linux system because some Linux server admins copy insecure code from StackOverflow. /s

Re:Dear Linux, Privileged Ports Must Die by mattpallissard on Friday September 02, 2022 @02:49PM (#32694439)
Agreed. In the HPC and research space large multi user systems are still king.

It's quite common for users to stand up their own versions of privileged services on unprivileged ports. Bad actors aside, this prevents users from accidentally mimicking a service that would effectively break shared resources. These are nice guardrails.

Security and guardrails should be optional, but it should be opt out, not opt in.

Re:Dear Linux, Privileged Ports Must Die by nailer on Thursday September 01, 2022 @03:20AM (#32673090)
Can we just make socket permissions like files?

chown mike /dev/tcp/80

Re:Dear Linux, Privileged Ports Must Die by _ph_ on Thursday September 01, 2022 @03:51AM (#32673314)
Right, that's the way it should be done for ports that try to listen to non-local connections. That would actually strongly increase security, as non-privileged ports can be abused a lot too.
Re:Dear Linux, Privileged Ports Must Die by benob on Thursday September 01, 2022 @02:58AM (#32672955)
Could the os restrict a range of ports to a non-root user?

That would cover your concerns, wouldn't it?

Re:Dear Linux, Privileged Ports Must Die by INTPenis on Thursday September 01, 2022 @03:03AM (#32672983)
They did, it's called 1025-65535. This is literally ancient tech. There are more modern (and perhaps more granular) ways to do it today with cgroups and nftables I'm sure.

I myself am an avid SElinux user and I know for sure you can restrict ports to user roles there.

Re:Dear Linux, Privileged Ports Must Die by BossingAround on Thursday September 01, 2022 @09:43AM (#32676113)
What resources did you use to get into SELinux? I am an SELinux user, but it's more like "I can debug it and make it work without turning it off".
Re:Dear Linux, Privileged Ports Must Die by INTPenis on Thursday September 01, 2022 @11:24AM (#32677726)
I have the book SElinux by example which is still very relevant.

But these days I'd say you can get all the same info online[1].

1. https://github.com/SELinuxProject/selinux-notebook

Re:Dear Linux, Privileged Ports Must Die by im3w1l on Thursday September 01, 2022 @02:36AM (#32672788)
Now anyone can snipe 8080 and steal the url you "gave out". How is that secure?
Re:Dear Linux, Privileged Ports Must Die by antimeme on Thursday September 01, 2022 @12:12PM (#32678555)
Did you... actually read the article this comment responded to? Or even the comment you're replying to? The original article proposed making all ports non-privileged because most systems serve a single user in practice. Are you really going to argue that changing the port to 8080 is insecure because someone could snipe it but making all ports non-privileged is better because... now someone can snipe 80 as well?
Re:Dear Linux, Privileged Ports Must Die by im3w1l on Thursday September 01, 2022 @03:54PM (#32682157)
I agree with the article that privileged ports is a bad idea. I disagree that making them free for all, or using a free-for-all port is a good solution. You propose it as a simple solution but it has many issues.