macOS: search system directories before /usr/local/bin for binaries#1790
macOS: search system directories before /usr/local/bin for binaries#1790damianrickard wants to merge 1 commit into
Conversation
|
Thank you for reporting this, the homebrew issue warrant such change. But I have one reservation: the added comment says the other platforms already keep Could you please adjust that comment and commit wording to make the statement macOS specific? With this wording fixed, I can merge it. |
On macOS, Process::FindSystemBinary() searched /usr/local/bin first, so a
user-writable /usr/local/bin (the default on Homebrew installs) could
shadow system tools.
This resolver is also used to locate privileged binaries during privilege
elevation: CoreService.cpp resolves "sudo" (and "true") through it both
when probing for an active sudo session and when launching the elevated
helper, and the admin password is written to that sudo process's stdin.
On a typical Homebrew install /usr/local is owned by the (non-root) user,
so a planted /usr/local/bin/sudo would be selected ahead of /usr/bin/sudo
and could capture the admin password, leading to privilege escalation.
Reorder the macOS list to {/usr/bin, /bin, /usr/sbin, /sbin,
/usr/local/bin} so system locations always win. The binaries actually
resolved through this function on macOS (sudo, true, fsck, the terminal
helper used for filesystem checks and its dependencies, and non-APFS
formatters) live in system directories, so /usr/local/bin is kept only as
a last-resort fallback and can no longer shadow them. (diskutil, hdiutil
and newfs_apfs are invoked via absolute paths and were never affected.)
c0a3c38 to
31f9e69
Compare
|
Thanks, both points are fair. You're right that the Linux branch searches I've also corrected the affected-binary list: Force-pushed the single-commit update. |
Summary
On macOS,
Process::FindSystemBinary()searched/usr/local/binfirst, so a user-writable/usr/local/bin(the default on Homebrew installs) could shadow tools in the system directories.This resolver is also used to locate privileged binaries during privilege elevation.
CoreService.cppresolvessudo(andtrue) through it both when probing for an active sudo session and when launching the elevated helper, and the admin password is written to that sudo process's stdin.On a typical Homebrew install
/usr/localis owned by the (non-root) user, so a planted/usr/local/bin/sudowould be selected ahead of/usr/bin/sudoand could capture the admin password, leading to privilege escalation.Fix
Reorder the macOS search list so system locations always win:
/usr/local/binis kept only as a last-resort fallback and can no longer shadow the system tools.Affected resolver users
The binaries actually resolved through
FindSystemBinary()on macOS aresudo,true,fsck, the terminal helper used for filesystem checks (and its dependencies), and non-APFS formatters — all of which live in system directories.diskutil,hdiutil, andnewfs_apfsare invoked via absolute paths and were never affected by the search order; they're mentioned only as context for what VeraCrypt runs on macOS.Notes
Build/build_veracrypt_macosx.sh -b -f.