# File path traversal, validation of start of path

<figure><img src="https://1586847736-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FtSZ40gLWhBDTzPEgHsVB%2Fuploads%2F1pdbYvZBAC4Y7UvLDKk4%2F1.png?alt=media&#x26;token=f3e83379-558d-4f38-807a-e16f8276afd4" alt=""><figcaption></figcaption></figure>

Let's access the image through the browser.

<figure><img src="https://1586847736-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FtSZ40gLWhBDTzPEgHsVB%2Fuploads%2Fq2kd9V0zRBCs67x1DxYY%2F2.png?alt=media&#x26;token=54a5b92e-c9b4-4ec9-a354-da0f733d3796" alt=""><figcaption></figcaption></figure>

We can now intercept this request in Burp Suite using the `Proxy`.

<figure><img src="https://1586847736-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FtSZ40gLWhBDTzPEgHsVB%2Fuploads%2FkbBmzUplIybLAsGPAxqU%2F3.png?alt=media&#x26;token=47ef7013-c96c-4168-8d2c-c1d3a21a3bd3" alt=""><figcaption></figcaption></figure>

Now, we can forward the request to the `Repeater` to makes changes in it.

Let's change the `filename` parameter to the following and forward the request:

```
/etc/passwd
```

<figure><img src="https://1586847736-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FtSZ40gLWhBDTzPEgHsVB%2Fuploads%2FE36205qRx5Uwj0OWpOyT%2F4.png?alt=media&#x26;token=fc050e40-6da3-4d1b-b285-37600477549c" alt=""><figcaption></figcaption></figure>

The server requires the user-supplied filename to start with `/var/www/images`.

```
/var/www/images/../../../etc/passwd
```

<figure><img src="https://1586847736-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FtSZ40gLWhBDTzPEgHsVB%2Fuploads%2FCbQWeih00JmWk4or5nsd%2F5.png?alt=media&#x26;token=654435aa-6f21-48a7-96e1-552a72c67c22" alt=""><figcaption></figcaption></figure>

We have successfully solved the lab.

<figure><img src="https://1586847736-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FtSZ40gLWhBDTzPEgHsVB%2Fuploads%2Fyr9B8SHYGQHRLeew4Sxt%2F6.png?alt=media&#x26;token=ec20fcbd-7134-4155-ac49-04664f66a98d" alt=""><figcaption></figcaption></figure>
