Live data from Hacker News

Pwning your web server the easy way or why exposing –/.ssh/ is a bad idea

0day.work

11–20 of 60 posts

Re: Pwning your web server the easy way or why exposing –/.ssh/ is a bad idea

#11
post #7

You really have to go out of your way to make the www-data user available through ssh, weird some do this.

I can tell you exactly how it happened: someone thought that this was the most expedient way to do something they wanted to do, they unfortunately had rights to do it, and they just did it without considering for a minute the consequences. Happens all the time.

Re: Pwning your web server the easy way or why exposing –/.ssh/ is a bad idea

#12

The files in ~/.ssh are usually initialized with restrictive permissions, so how do they end up getting exposed? The only way I can think off-the-bat is that someone absent-mindedly commits them to their git dotfiles and ends up copying them over to another machine when they do a `git clone` command.

> so how do they end up getting exposed?

the author cites "allowing developers to connect to the host with the www-data user", and this is a very specific form of incompetence.

www-data is the name commonly used by debian and debian-based distros to run apache and other http servers. it's literally, just designed to run the executable, not to upload new version of webpages or anything.

there are countless ways to avoid this pitfall, the simplest that comes to my mind is creating another user for uploading stuff and adding such user to the www-data group.

at the end of the day... meh. people might start a campaign about how not to use the www-data or something else, but not-very-techy people will find another way to misuse a webserver.

Re: Pwning your web server the easy way or why exposing –/.ssh/ is a bad idea

#13

This is what I have learned in many years of work: people who know systems should be let to handle those systems. This is what happens when a developer is left to do the work that a system administrator should be trained to do - not all are -. For a developer, in most cases, "just works" is the end goal, when referring to systems. Not "how it works", and what are the implications of making it work like this. This rea…

Sys admins are dead. I have GKE now via a reliable Terraform module. None of my production instances can be logged onto.

Re: Pwning your web server the easy way or why exposing –/.ssh/ is a bad idea

#14
The www-data user (or whatever the web server is running as) should not own any files that are served by the web server. The user should not be able to log in either (its shell should be /bin/false or something similar).

Use an entirely different user for file ownership.

Re: Pwning your web server the easy way or why exposing –/.ssh/ is a bad idea

#16

TL;DR: Antipattern: pointing web server config to any files based in /home.

Not just that. Even if you don't make that mistake, having servers ssh into other hosts and leaving keys on them for this purpose means if one machine is compromised, others can be too. And they can use known_hosts to discover which ones.

Re: Pwning your web server the easy way or why exposing –/.ssh/ is a bad idea

#17

This is what I have learned in many years of work: people who know systems should be let to handle those systems. This is what happens when a developer is left to do the work that a system administrator should be trained to do - not all are -. For a developer, in most cases, "just works" is the end goal, when referring to systems. Not "how it works", and what are the implications of making it work like this. This rea…

I would disagree: The problem is developers (and users in general, but their lack of formal training is an excuse) being comfortable using interfaces and abstractions they don't fully understand.

Note that the result of this might sound like it makes the idea of a professional system administrator invalid but that's not true: I think the better SAs of the past had a thorough understanding of what their tools did and many of probably even modified them, this contrasts the current situation where people are poking things in PAS GUIs and accidentally running up huge bills.

Re: Pwning your web server the easy way or why exposing –/.ssh/ is a bad idea

#20

This is what I have learned in many years of work: people who know systems should be let to handle those systems. This is what happens when a developer is left to do the work that a system administrator should be trained to do - not all are -. For a developer, in most cases, "just works" is the end goal, when referring to systems. Not "how it works", and what are the implications of making it work like this. This rea…

Sys admins are dead. I have GKE now via a reliable Terraform module. None of my production instances can be logged onto.

Are you sure about that?
Post reply on HN