The vulnerability is a local privilege escalation in the theshit command-line tool. It occurs when the tool is run with elevated privileges (e.g., using sudo). The application's fix command re-executes a previous command, but it fails to drop the elevated privileges before doing so. This allows a local user to execute arbitrary commands as root.
The analysis of the patch commit 5293957b119e55212dce2c6dcbaf1d7eb794602a reveals the root cause. The function theshit::fix::get_command_output in src/fix.rs was responsible for executing the command. This function directly used std::process::Command without any privilege management, causing the command to inherit the elevated privileges of the main process. The function theshit::fix::fix_command is the public function that calls this vulnerable get_command_output function.
The patch addresses this by removing the vulnerable get_command_output function and introducing a new module src/fix/output.rs. The new get_command_output function in this module now includes logic to detect if the application is running with elevated privileges (e.g., sudo, doas, or SUID bit). If so, it uses libc::setuid and libc::setgid within a pre_exec hook to drop privileges to the original user before executing the command, thus mitigating the vulnerability.