Vagrant VMware Fusion Privilege Escalation
Hashicorp's vagrant plugin for vmware fusion uses a product called Ruby Encoder to protect their proprietary ruby code. It does this by turning the ruby code into bytecode and executing it directly. Unfortunately the execution chain necessary for this to work is not safe. After installing the plugin, the first time you 'vagrant up' any vagrant file using vmware fusion it will create some files in ~/.vagrant.d/gems/2.2.5/gems/vagrant-vmware-fusion-4.0.18/bin. The first one is an encoded ruby script, the others are 'sudo helper' binaries for the different platforms supported by the plugin. Of these sudo helpers, the one that corresponds to your platform will be made suid root when vagrant up is run. Unfortunately the helper calls the ruby script with system('ruby <script path>') - i.e. it doesn't verify the path to the ruby script and it doesn't scrub the PATH variable either. We can easily exploit this to get root.