> For the complete documentation index, see [llms.txt](https://kunalwalavalkar.gitbook.io/write-ups/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://kunalwalavalkar.gitbook.io/write-ups/portswigger-labs/server-side-topics/path-traversal/file-path-traversal-validation-of-file-extension-with-null-byte-bypass.md).

# File path traversal, validation of file extension with null byte bypass

<figure><img src="https://1586847736-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FtSZ40gLWhBDTzPEgHsVB%2Fuploads%2FrIgHJYVMKvMZKZ8QTXml%2F1.png?alt=media&amp;token=bccda266-85e7-48d2-a469-7ca2168d1228" 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%2F5pjg3nZCEjebgNjbInwI%2F2.png?alt=media&amp;token=86496a62-4856-478e-ba2a-c4c011a14858" 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%2Frqu8HiLR0AZQJdwv8Z2U%2F3.png?alt=media&amp;token=890cdda5-60c1-4aad-bf42-c97544c572c8" 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%2Fnt49u6LXd9e9I876r41W%2F4.png?alt=media&amp;token=5c9e4349-7529-4f36-8137-ab6217925cae" alt=""><figcaption></figcaption></figure>

The server expects a `.png` file extension. We can use `%00` characters before the extension so that our string gets terminated before the extension

```
../../../etc/passwd%00.png
```

<figure><img src="https://1586847736-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FtSZ40gLWhBDTzPEgHsVB%2Fuploads%2FkCo5LucAQk82KsW1iPgX%2F5.png?alt=media&amp;token=65e04f31-5f27-4c30-907d-9dc6564156cb" 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%2FjfSGeyVcH4yTITcbzPWx%2F6.png?alt=media&amp;token=25f11a04-ad0c-453d-bb6c-aa635112386b" alt=""><figcaption></figcaption></figure>
