News for hackers. Stuff that matters.
Re:Abusing Ubuntu 24.04 features for root privilege escalation by samlinnfer on Thursday November 14, 2024 @07:47AM (#42135691)
24.04 also ships with a footgun that keeps PasswordAuthentication enabled even if you edit /etc/ssh/sshd_config. It adds a /etc/ssh/sshd_config.d/50-cloud-init.conf that force overrides any PasswordAuthentication settings you have configured in /etc/ssh/sshd_config.

See here: https://news.ycombinator.com/item?id=42133181

Re:Abusing Ubuntu 24.04 features for root privilege escalation by MortyWaves on Thursday November 14, 2024 @08:19AM (#42135901)
Now I definitely feel glad that I decided on moving back to Debian for servers.
Re:Abusing Ubuntu 24.04 features for root privilege escalation by amelius on Thursday November 14, 2024 @08:37AM (#42136030)
Does anyone know how to turn off auto updates on Ubuntu 22?

I thought I fixed it, but apparently not. It is driving me crazy.

Re:Abusing Ubuntu 24.04 features for root privilege escalation by HumanOstrich on Thursday November 14, 2024 @10:52AM (#42137427)
Hey I think you might have replied to the wrong thread or post. This thread/post has nothing to do with Ubuntu 22 updates.
Re:Abusing Ubuntu 24.04 features for root privilege escalation by HumanOstrich on Thursday November 14, 2024 @11:08AM (#42137583)
Err, why? Nothing is actually broken with Ubuntu 24.04. The issue GP is describing is just a lack of understanding of how config files have worked on Linux for decades.
Re:Abusing Ubuntu 24.04 features for root privilege escalation by Brian_K_White on Thursday November 14, 2024 @12:00PM (#42138223)
Actually ubuntu and/or some cloud integrator is violating principle of least suprise, which predates by even more decades and applies everywhere not just in a computer operating system.

Having /etc/ssh/sshd_config not do what it appears to do is inexcusable, however that comes about.

Even if the fix is no more than structuring the file a little differently so there are parts both before and after the .d loading, and comments that say what overrides what, and all the actual config files and default behavior are still the same.

Re:Abusing Ubuntu 24.04 features for root privilege escalation by HumanOstrich on Thursday November 14, 2024 @12:52PM (#42138960)
That's just not how it works, and it never has. One of the main purposes of the .d files is to avoid modifying the distro's sshd_config file, so you don't have to resolve conflicts during an OS upgrade. Commenting your overrides in the sshd_config? That's backwards.

Downstream distros sometimes want to override the default settings. That's what .d is for. It doesn't violate the dogma "principle of least surprise", especially if you run `man sshd_config` and learn the first thing about sshd's config files.

Re:Abusing Ubuntu 24.04 features for root privilege escalation by Brian_K_White on Thursday November 14, 2024 @08:24PM (#42143101)
Child,

"That's just not how it works" Incorrect.

"dogma "principle of least surprise"" That is not dogma, it is a principle. It's right there in the name.

Dogma might be the understanding that the principle of least suprise is a valid principle.

But this suggests you don't subscribe to this silly "dogma" eh?

Re:Abusing Ubuntu 24.04 features for root privilege escalation by HumanOstrich on Thursday November 14, 2024 @11:34PM (#42143994)
Child? Do you condescend based on principle or dogma? ¯\_(ツ)_/¯
Re:Abusing Ubuntu 24.04 features for root privilege escalation by Brian_K_White on Friday November 15, 2024 @11:25AM (#42148358)
Well, I don't know anyone else who scoffs at that.

I also don't know anyone else who would assume that others don't know "how this has always worked" except someone who only learned themselves last week and think they know a lot now.

I didn't say anything about adding comments as an end user. My point about comments was that least suprise could be resolved trivially without even changing the existing desired behavior, by nothing more than the OS shipping a default sshd_config that was structured so that it clearly had a section that will be overridden, and a section that will override, which requires nothing more than a few comments.

Re:Abusing Ubuntu 24.04 features for root privilege escalation by HumanOstrich on Friday November 15, 2024 @02:54PM (#42150264)
There isn't a comment specifically saying that including more config files can override values, so I'll give you that. However, it does have comments explaining exactly how to override default values. It looks like what the OP of this thread is attempting should work unless they messed up something else.

I'm looking at a couple sshd_config files on my servers, and the Include directive for the overrides is the first non-comment line in the file.

Having that Include be first means that changing any settings in the sshd_config file will override anything set by sshd_config.d/* files.

What in the heck are these people doing to break their config? There really is no legitimate issue here.

Re:Abusing Ubuntu 24.04 features for root privilege escalation by DaSHacka on Thursday November 14, 2024 @11:25AM (#42137793)
Any sufficiently poorly constructed system is indistinguishable from a legitimate vulnerability.

You shouldn't need to edit an undocumented file that's force enabling an insecure authentication method in the first place.

"You're using it wrong" doesn't change the fact that the defaults are poor and likely to ultimately cause more devices to be improperly configured than if it was left as sysadmins and end-users expect.

Re:Abusing Ubuntu 24.04 features for root privilege escalation by HumanOstrich on Thursday November 14, 2024 @11:45AM (#42138020)
They likely chose the option to enable password-based SSH authentication during installation [1], or it's a cloud service that provisions servers with a password.

I've been looking for info about whether it's force-enabled with a vanilla install where the user doesn't actually choose for it to be enabled. I'm happy to be educated here.

[1]: https://askubuntu.com/a/1440509

Re:Abusing Ubuntu 24.04 features for root privilege escalation by gazunklenut on Thursday November 14, 2024 @08:28AM (#42135966)
Pretty sure this exists on Debian too
Re:Abusing Ubuntu 24.04 features for root privilege escalation by yjftsjthsd-h on Thursday November 14, 2024 @08:57AM (#42136168)
I believe I've seen cloud vendors configure out that way, but I don't think it's an actual Debian default.
Re:Abusing Ubuntu 24.04 features for root privilege escalation by poizan42 on Thursday November 14, 2024 @08:30AM (#42135981)
Nope, not on my system: https://i.imgur.com/1qCLXXZ.png
Re:Abusing Ubuntu 24.04 features for root privilege escalation by HumanOstrich on Thursday November 14, 2024 @10:42AM (#42137307)
Great, now you can start putting your customizations in that directory instead of the OS-managed /etc/ssh/sshd_config blob. That's why the `.d/` convention exists.
Re:Abusing Ubuntu 24.04 features for root privilege escalation by normie3000 on Thursday November 14, 2024 @10:46AM (#42137354)
What does .d imply?
Re:Abusing Ubuntu 24.04 features for root privilege escalation by HumanOstrich on Thursday November 14, 2024 @10:50AM (#42137405)
I had to look up the info because I wasn't sure really, so I appreciate the direct question. It means 'directory' or 'conf.d pattern'. So you have your config file, and the config directory that contains "parts" of the config to be merged with the main one to provide customizations/overrides.
Re:Abusing Ubuntu 24.04 features for root privilege escalation by MrResearcher on Friday November 15, 2024 @05:29PM (#42151963)
Damn, you really got me scared there for a second. Just re-checked by Debian 12 systems on AWS, I don't have any files residing in *.d directories. So I confirm that if you used the official AWS Debian image, you wouldn't get it.

And if you downloaded and installed the authentic Debian 12 image from debian.org, you don't get it either. Must be a Ubuntu thingy.

Re:Abusing Ubuntu 24.04 features for root privilege escalation by vbezhenar on Thursday November 14, 2024 @12:47PM (#42138877)
It works identically for debian. Just today I configured debian server with cloud-init and it created absolutely the same file.
Re:Abusing Ubuntu 24.04 features for root privilege escalation by homebrewer on Thursday November 14, 2024 @10:13AM (#42136935)
The proposed solution is bad, the file will be restored by the package manager at some point. Always prefix your override files with '99-' or 'zz-', this would have prevented the problem.
Re:Abusing Ubuntu 24.04 features for root privilege escalation by wahern on Thursday November 14, 2024 @09:10PM (#42143342)
For OpenSSH configuration the first directive controls, not the last. So if you want to set an option make sure your include filename comes lexically earlier, not later. This is why the Include directive is at the top of distro-installed /etc/ssh/sshd_config. You can verify your server configuration using `sshd -T`, and a client configuration using `ssh -G`; they dump the resolved configuration to stdout.
Re:Abusing Ubuntu 24.04 features for root privilege escalation by HumanOstrich on Thursday November 14, 2024 @10:46AM (#42137356)
A better practice is to use the `.d/` convention as intended - so you can have overrides and customizations without having to edit the OS-managed /etc/ssh/sshd_config file and fight it if an OS upgrade changes it.

Edit: It's not really a mistake on Ubuntu's part, and is common in other distros for overriding upstream defaults[1].

[1]: https://askubuntu.com/a/1516347

Re:Abusing Ubuntu 24.04 features for root privilege escalation by Fire-Dragon-DoL on Friday November 15, 2024 @04:16PM (#42151185)
There is a bug with that where you cannot "redefine" the ftp command used (I think it was that, or the group declaration), so in the end I had to edit the configuration manually either way
Re:Abusing Ubuntu 24.04 features for root privilege escalation by charliebwrites on Thursday November 14, 2024 @10:52AM (#42137430)
Is this true for Ubuntu Server 24 as well?

Was thinking of upgrading but not if I can’t configure SSH to be key only

Re:Abusing Ubuntu 24.04 features for root privilege escalation by HumanOstrich on Thursday November 14, 2024 @11:06AM (#42137570)
There is nothing broken with Ubuntu, just people not understanding how configuration files work in Linux, choosing to enable password auth in SSH during installation, or using a cloud provider that provisions instances with passwords and overrides the default.
Re:Abusing Ubuntu 24.04 features for root privilege escalation by lathiat on Thursday November 14, 2024 @09:00PM (#42143299)
You can still configure it to be key only, you just need to put your own override as a file in /etc/ssh/sshd_config.d/ rather than /etc/ssh/sshd_config. The files are read ins order, so your filename needs to sort after the 50-cloud-init.conf file.

This would work: echo "PasswordAuthentication no" > /etc/ssh/sshd_config.d/60-password-auth.conf

Re:Abusing Ubuntu 24.04 features for root privilege escalation by speleding on Friday November 15, 2024 @11:58AM (#42148662)
With sshd configuration the first option is the one that sticks, so you need to make sure it sorts BEFORE the 50-cloud-init.conf file.
Re:Abusing Ubuntu 24.04 features for root privilege escalation by SoftTalker on Thursday November 14, 2024 @11:45AM (#42138026)
I don't have /etc/ssh/sshd_config.d/50-cloud-init.conf on my ubuntu 24.04 machines. What creates it? Is it a clean-install vs. upgrade difference perhaps?
Re:Abusing Ubuntu 24.04 features for root privilege escalation by HumanOstrich on Thursday November 14, 2024 @11:46AM (#42138038)
Unfortunately, one possibility is the user chose "enable SSH password authentication" during the install [1]. Or it's a cloud instance from a provider that provisions instances with a password.

[1]: https://askubuntu.com/a/1440509

Re:Abusing Ubuntu 24.04 features for root privilege escalation by vbezhenar on Thursday November 14, 2024 @12:45PM (#42138854)
This file is created when the server is provisioned with cloud-init. For example when you use https://cloud-images.ubuntu.com/ as a template image to create your VM. For these cases you would need to supply cloud-init config via separate means (openstack user-data or just secondary mounted ISO) and cloud-init would perform post-install tasks like configuring users, passwords, ssh keys, etc. If you just install your machine from ISO, cloud-init is not used.

I guess that many hosters will use cloud-init for their VPS offerings "under-the-hood". Usually they'll generate password and mail it to you, so obviously ssh password should be allowed for this case.

Re:Abusing Ubuntu 24.04 features for root privilege escalation by d0mine on Thursday November 14, 2024 @04:14PM (#42141291)
It is Ubuntu issue, it is cloud-init issue. You can get the same result on other distros provisioned by cloud-init.
Re:Abusing Ubuntu 24.04 features for root privilege escalation by xarope on Thursday November 14, 2024 @10:31PM (#42143739)
omg I just disabled this on a major server that was just upgraded to 24.04.

Had to check my other VMs. Luckily most of them are debian or 22.04 (for now).

Re:Abusing Ubuntu 24.04 features for root privilege escalation by yrro on Saturday November 16, 2024 @01:17PM (#42157981)
Am I crazy or have people lost the ability to read documentation?
Re:Abusing Ubuntu 24.04 features for root privilege escalation by yrro on Saturday November 16, 2024 @03:23PM (#42158994)