Live data from Hacker News

Moved ~/.local/share/steam. Ran steam. It deleted everything owned by user

github.com

51–60 of 280 posts

Re: Moved ~/.local/share/steam. Ran steam. It deleted everything owned by user

#51
This seems like yet another good example of why robust application-level access control would be a helpful thing to build into modern operating systems, in addition to the typical user-based controls. This may have been both a rookie mistake and a regrettable failure of code review processes, but in any case it simply shouldn’t be possible for an application running on a modern system to wipe out all user data without warning in such a sweeping way.

I have often made this argument in the context of sandboxing communications software like browsers and e-mail clients, where it is relatively unusual to need access to local files except for their own data. In that context, restricting access to other parts of the filesystem unless explicitly approved would be a useful defence against security vulnerabilities being exploited by data from remote sources. It’s hard to encrypt someone’s data and hold it for ransom or to upload sensitive documents if your malware-infected process gets killed the moment it starts poking around where it has no business being.

More generally, I see no reason that we shouldn’t limit applications’ access to any system by default, following the basic security principle of least privilege. We have useful access control lists based on concepts of ownership by users and groups and reserving different parts of the filesystem for different people. Why can’t we also have something analogous where different files or other system resources are only accessible to applications that have been approved for that access?

Re: Moved ~/.local/share/steam. Ran steam. It deleted everything owned by user

#52

Earlier quoted context omitted.

You're too kind :) Granted, part of the blame lies in the archaic Unix security model which doesn't sandbox applications. But ANY line containing "rm -rf" should be reviewed by the most senior dev in the company, or at least one who actually understands shell scripting. It has such a terrible failure mode, there's no excuse not to. ( Especially when the dev to blame knew that it's "Scary!".)

Interesting: https://github.com/search?q=rm+-rf&type=Code&utf8=%E2%9C%93

Are you trying to make me have an aneurism? :)

Re: Moved ~/.local/share/steam. Ran steam. It deleted everything owned by user

#53

   rm -rf "$STEAMROOT/"*
This is why serious bash scripts use

   set -u # trap uses of unset variables
Won't help with deliberately blank ones, of course.

Scripting languages in which all variables are defined if you so much as breathe their names are such a scourge ...

I did this once in a build script. It wiped out all of /usr/lib. Of course, it was running as root! That machine was saved by a sysadmin who had a similar installation; we copied some libs from his machine and everything was cool.

Re: Moved ~/.local/share/steam. Ran steam. It deleted everything owned by user

#54
Many of the comments mentioned this should have been caught in the code review. I suspect they don't perform code reviews.

Makes me wonder, is there a tool, system, service for auditing how many 'pair of eyes' have reviewed a given line of code. This would be hard to determine, but could be useful. I am envisioning a heatmap bar or overlay that indicates the number of reviews a line of code has received.

Re: Moved ~/.local/share/steam. Ran steam. It deleted everything owned by user

#55
post #21

Earlier quoted context omitted.

Gotta question why they used -f.

So the script wouldn't pause and ask for user input during normal operation.

But why would the script prompt for user input unless something was awry? Presumably they control the contents of $STEAMROOT, so I don't see why rm -r should prompt unless it's about to do the wrong thing.

Re: Moved ~/.local/share/steam. Ran steam. It deleted everything owned by user

#56
post #21
post #3

Here's the offending shell script code: # figure out the absolute path to the script being run a bit # non-obvious, the ${0%/*} pulls the path out of $0, cd's into the # specified directory, then uses $PWD to figure out where that # directory lives - and all this in a subshell, so we don't affect # $PWD STEAMROOT="$(cd "${0%/*}" && echo $PWD)" [...] # Scary! rm -rf "$STEAMROOT/"* The programmer knew the danger and di…

Gotta question why they used -f.

If all one is in the habit of using with a particular command is some single letter flags glommed together like that then it's possible to forget that they're actually separate flags.

Re: Moved ~/.local/share/steam. Ran steam. It deleted everything owned by user

#57
post #19

Something like this with Steam happened to my friend not too long ago. It was very saddening because he literally lost years of files (including personal projects) and salvaged what he could. That was with the Steam Beta and I caught Steam doing this myself (after he told me what happened). I was lucky to stop the script and switched out of the beta. At the time he reported this to Valve themselves and said they were…

That is quite frustrating, and consumer vendors should be mindful of creating life-changing experiences.

Also: backups. I know it sounds cliche, but look, if it has a mechanical hard drive, the manufacturer could have slightly mis-calibrated one of the mechanical assemblies, and this could have happened because the nature of digital storage is that it is essentially ephemeral.

Protect yourself from things outside your control. You don't need the most sophisticated solution, just an external usb drive.

Re: Moved ~/.local/share/steam. Ran steam. It deleted everything owned by user

#58
post #11

I don't want to blame anyone, but maybe there should be foolproof default security measures that prevent something like this from happening. For example rm -rf called on a home, documents, music, photos etc. directory could require an additional confirmation, perhaps through a GUI.

There are, it's called users, and groups, and file permissions. Applications like steam should really be running under a separate user so they can't write to personal files (and maybe just have read permissions). But of course proper application isolation and file permissions is something few people do correctly on their personal machines, let alone know about. Window managers don't make it any easier, and I put a lo…

It seems like the direction Linux is going (albeit slowly) is to use selinux instead of different users for this type of isolation.

Re: Moved ~/.local/share/steam. Ran steam. It deleted everything owned by user

#59

Earlier quoted context omitted.

There are, it's called users, and groups, and file permissions. Applications like steam should really be running under a separate user so they can't write to personal files (and maybe just have read permissions). But of course proper application isolation and file permissions is something few people do correctly on their personal machines, let alone know about. Window managers don't make it any easier, and I put a lo…

should get better once systemd has steam integration

[deleted]

Re: Moved ~/.local/share/steam. Ran steam. It deleted everything owned by user

#60
post #8

The biggest lesson here is that backing up your files is extremely important. Both local backups and remote backups. I like the 3-2-1 rule: At least three copies, In two different formats, with one of those copies off-site. Software is written by humans who will undoubtably miss a corner case and not think of every possible environment.

>In two different formats

What does this mean?

Post reply on HN