Laravel Valet 2.0.3 – Local Privilege Escalation (macOS)
Laravel Valet v1.1.4 to v2.0.3 is vulnerable to local privilege escalation on macOS. This bug got introduced when the sudoers files got added around commit b22c60dacab55ffe2dc4585bc88cd58623ec1f40. When the valet command is installed, composer will symlink the `valet` command to /usr/local/bin. This 'command' is writable by the user that installed it. Running `valet install`, will start the install routine. The very first action taken is to stop nginx (quietly?) with `sudo` which will prompt the user for the sudo password in the command line. From here (and in fact from any point where the valet tool uses sudo) the command can execute further commands as root without any further interaction needed by the user. With this 'sudo' access, the installer does it thing, and eventually installs two new sudoers rules for homebrew and valet. The problem with the sudoers rules now is the fact that a user controlled script (rememeber the valet command is writable to my user?) is allowed to be run with root privileges. More conveniently, without a password. So, to trivially privesc using this flaw, simply edit the `valet` command and drop `/bin/bash` in there.