---
title: "PATH hijacking"
date: 2024-06-19
draft: false
---

Take for example this program that backs up all files. It uses `tar` to do so. 
![](/img/Pasted image 20240618201710.png)

![](/img/Pasted image 20240618201724.png)

We can run `export PATH=/dev/shm:$PATH`
so that the first place `tar` is looked for in the `$PATH` would be `/dev/shm`
![](/img/Pasted image 20240618201906.png)
from here, we can make a lil nasty lil sexy ass lil vulnerable `tar` program that doesn't actually do tar at all :) and root runs it :) 
![](/img/Pasted image 20240618202043.png)
![](/img/Pasted image 20240618202111.png)


