News for hackers. Stuff that matters.
Re:Some Differences Between macOS and Common Unix Systems by Brian_K_White on Friday December 25, 2020 @10:35AM (#25537015)
The main problem isn't really that it doesn't require sudo.

If it installed as a user into your home dir, that would be fine.

Changing a shared system-wide path or installing shared system-wide files owned by a user is so fundamentally borked that you should immediately reject anything offered by anyone who suggested to do that.

But the masses of users who made it popular didn't know that and there were/are a lot of them, and the reason it's wrong won't bite many people because their macbooks only have one user account, and so you have a zillion people who didn't know they were getting bad advice and doing a broken thing, and if you tell them now, they don't see it because they've been doing it wrong for years and their house didn't burn down, and they vastly outnumber the people who unserstand the problem and would never have designed something so broken in the first place, and so it just stays both incorrect and the standard.

Re:Some Differences Between macOS and Common Unix Systems by nemothekid on Friday December 25, 2020 @01:54PM (#25538259)
>Changing a shared system-wide path or installing shared system-wide files owned by a user is so fundamentally borked that you should immediately reject anything offered by anyone who suggested to do that.

I don't think that's fair to the homebrew developers. They chose a justifiable tradeoff - as you said most mac systems are single user systems and their design offers better protection to a far larger group of users. When you run `brew install ffmpeg` you are running an arbitrary ruby script from Homebrew git repo and it's probably better that it doesn't run as root. I can't see how that is bad advice; I'd argue that the opposite - sticking to "tradition" despite the changing the landscape of how personal devices have changed security is the broken mindset.

I'm sure most macOS users are far more concerned about an arbitrary script exfiltrating their keychain than some contrived multi-user setup where another user installs a keylogger in the system path.

Re:Some Differences Between macOS and Common Unix Systems by Brian_K_White on Sunday December 27, 2020 @04:41PM (#25554510)
"contrived" is not an excuse for doing something wrong.

All programming, heck all system design of any form, programming, mechanical hardware, legal process, is made of ensuring that situations are handled, including both the obvious ones you thought of and the ones you didn't think of.

All "corner cases" could be described as "contrived", yet they happen a million times an hour.

"Contrived" is a contrived rationale to ignore something you should not ignore for mere convenience.

"contrived" is just a silly and empty accusation, and no argument.

If you are in a conversation where the subject deals in probabilities or percentages, then you can talk about liklihood. Having say 1% of customers fail to navigate a subway map is better than having 8% fail. And some contrived example problem like the map needs to be only in shades of green because what if you're colorblind... the contrived nature of the problem matters because the problem deals in percentages where 99% is better than 92%.

But in system design (such as application programming or os design, especially the lowest most basic security aspects, things are only possible or not-possible. There is no "likely" and no "contrived". If you can "contrive" an example that invalidates a design, then you have invalidated the design, period.

If you cannot contrive an example, then you still have not proven the design, merely you have failed to IN-validate it, yet.

The /Applications directory is not equivalent to the /usr/local tree, or any other part of the system.

The /Applications dir itself is owned by root, and a user may not change it to be owned by theirself, and a user may only write within it because they are a member of the "admin" group. Until recently, the homebrew installer actually changed the ownership of /usr/local itself (or created it, I don't remember if it maybe didn't exist by default and was created by brew sometimes) rather than just some of the stuff under it. They only changed when forced to, when Apple started more actively protecting system components from modification a couple years ago. If it's ok for shared system components to be owned by joe random user, then why did Apple start protecting /usr/local? For that matter why can't joe random user replace /bin/cp with his own copy, or the kernel?

/usr/local/bin/mycp is (or rather should be, and is on sane sysyems) just as much a protected part of the system as /bin/cp. It's only different in that it's locally added to this machine and didn't come on the install cd, and may have different behavior than other parts of the system expect etc. But it's not "steve's" either. A "mycp" owned by "steve" should only exist in /home/steve (or /Users/steve on mac).

If brew installed everything in /Applications/Brew.app that would be ok too, because then it would be just doing what other apps do, and because /Applications is a special case which has extra handling by other means than merely the traditional unix file ownerships.

That would still be mildly broken because it would mean that all users could use the brew binaries and other assets, but only the installing user could modify them. That is fine for most apps which do not modify their internal contents, but brew is essentially a whole system itself, and it's contents are modified during normal use. A theoretical Brew.app is not like Calculator.app

So, the only sane way to do it is to install as the user somewhere within the users own domain (their home dir) or install in a system-wide shared place and require sudo for any "brew update" or "make install".

If it were all owned by a special user and/or group "brew" (not whatever random user happened to do the install), that would be sane too, but not necessary.

Re:Some Differences Between macOS and Common Unix Systems by bigbubba on Friday December 25, 2020 @11:49AM (#25537467)
Can you spoonfeed me here? If ~/bin is in my PATH and is writable to my user, what is the problem with /usr/local/bin being the same on my personal computer with a single human user?
Re:Some Differences Between macOS and Common Unix Systems by theamk on Friday December 25, 2020 @09:42PM (#25540909)
Base case (those are true AFAIK):

- /usr/local/bin is in a "system-wide" default PATH, (and it is even in front of /bin !)

- There is an important service, like Time Machine, which needs root access for important actions -- for example, to erase previous backups

- There could be a vulnerability in an application which gets data from the internet -- for the sake of example, let's say it is "foo file viewer". This can be exploited for code execution.

---

Case 1: Packages in ~/bin, /usr/local/bin is read-only:

A user wants to look at a "foo file" from the internet. The file is malicious, it exploits "foo viewer" and gets local execution. It is a cryptolocker, so it encrypts all the user documents.

The malware has installed trojaned "~/bin/sudo" wrapper, but since the user does not use "sudo" that often, it did not have a change to get executed. And none of the system services look into user's "~/bin".

A week later, user notices that a document is encrypted. But the time machine backups are still OK. They reformat their machine, and then use time machine backup to restore the documents. Day is saved!

---

Case 2: Packages in usr/local/bin:

A user wants to look at a "foo file" from the internet. The file is malicious, it exploits "foo viewer" and gets local execution. It is a cryptolocker, so it encrypts all the user documents.

The malware has installed a bunch of trojaned binaries, including "/usr/local/bin/touch" binary. Unfortunately, there is a LaunchDaemon which runs the script periodically which contains the line "touch /some/file". That is run as root, so in a short time, the malware gets root access. And it immediately used this access to disable time machine and delete all the backups.

A week later, user notices that a document is encrypted. And the time machine backups are gone, too. Oh no! the documents are lost unless they pay the ransom!

---

You might notice that some people may consider the scenario unrealistic: What if the user uses command line a lot, and is used to running "sudo"? What if a malware social engineers user by popping up a fake dialog asking for user password? Are there other privilege escalation methods? How often does this happen anyway?

You should make your own decisions, but hopefully you at least see what the people are concerned about.

Re:Some Differences Between macOS and Common Unix Systems by pram on Friday December 25, 2020 @05:16PM (#25539458)
That is exactly how installing an application in MacOS always works. When you run an installer for a native app, and it goes into /Applications, it's owned by the user who installed it. What Homebrew is doing isn't functionally different, other than /usr/local is in your PATH I guess?
Re:Some Differences Between macOS and Common Unix Systems by tsimionescu on Friday December 25, 2020 @12:09PM (#25537595)
Since Unix doesn't (traditionally at least) offer any access control mechanism more granular than a User, it was only natural that you'd get a lot of "system users" that are required for all sorts of operations but are not in any way associated with human users.

And now, since you have so many system users and almost always a single human user, you start wanting to install programs that will be used by both yourself and those system users, and it would be extremely problematic to go writing into 10 different bin/ and lib/ folders to install the same thing for 10 users.

Not to mention, a lot of software you want to install also runs some daemons or manages some system settings, and obviously requires root access to do so, but mag run into problems if it is not installed for root.