Skip to content
KitploitKITPLOIT
ToolsBlog
Submit
ToolsBlog
Submit

Hacking, PenTest, and Cybersecurity Tools for Your Security Arsenal!

Kitploit is a directory of hacking, cybersecurity, and pentesting tools. Discover the latest project updates to find vulnerabilities, analyze systems, automate testing, and strengthen your security.

··Feeds·Contact·Privacy·© 2026 Kitploit

Tool Directory

Categories

View all categories
Loading categories
Tools/GitHubGitHub/saina15/cve-2020-14343-lab
Vulnerability ScannersContainer SecurityDynamic Analysis (Sandboxing)Vulnerability AnalysisExploitationSecurity VirtualizationPenetration TestingPapers & ResearchLearning & EducationLabs & Practice
GitHubsaina15/cve-2020-14343-lab
11 day agoNot yet reviewed

cve-2020-14343-lab

Controlled vulnerability research and reproduction lab for CVE-2020-14343 in PyYAML

View Repository

Most Popular

View all →

Discover the most used tools by our community.

Explore all tools

Browse our collection of tools

View all tools →
Share

CVE-2020-14343 – PyYAML Unsafe YAML Loading Lab

1. Project Overview

This project demonstrates CVE-2020-14343 in a controlled and isolated Docker environment.

The lab contains two environments:

  • A vulnerable environment using PyYAML 5.3.1
  • A patched environment using PyYAML 5.4 and yaml.safe_load()

The lab demonstrates the complete vulnerability lifecycle:

  1. Deploy the vulnerable application.
  2. Identify the vulnerable PyYAML version.
  3. Reproduce the vulnerability using a controlled YAML payload.
  4. Detect the vulnerable version using an automated script.
  5. Upgrade to the fixed version.
  6. Test the same payload against the patched application.
  7. Verify that the malicious YAML is rejected.

The reproduction payload used in this lab is intentionally harmless and only prints a test marker.

2. CVE Information

PropertyDetails
CVECVE-2020-14343
ProductPyYAML
Affected versionsVersions before 5.4
Fixed version5.4
Vulnerability typeImproper Input Validation (CWE-20)
SeverityCritical
Attack surfaceYAML input processed using vulnerable loading functionality

Root Cause

The vulnerability occurs when untrusted YAML input is processed using vulnerable PyYAML loading functionality.

PyYAML versions before 5.4 allowed specially crafted YAML tags, including Python-specific tags such as:

root@kitploit:~
!!python/object/new

to reach object construction functionality when FullLoader was used.

A malicious YAML document can therefore cause unintended Python code execution.

The issue was related to an incomplete fix for an earlier PyYAML vulnerability.

PyYAML 5.4 fixed CVE-2020-14343 by moving arbitrary Python tags to UnsafeLoader.

For applications processing untrusted YAML, this lab also uses yaml.safe_load() as a secure loading approach.

3. Lab Architecture

The lab contains two isolated Docker services:

root@kitploit:~
                         Host Machine
                              |
                 +------------+------------+
                 |                         |
                 v                         v
          Vulnerable App             Patched App
          localhost:5000             localhost:5001
                 |                         |
            PyYAML 5.3.1             PyYAML 5.4
            FullLoader               SafeLoader
                 |                         |
                 v                         v
          Payload executes          Payload rejected

Services

ServiceHost PortContainer PortPyYAMLPurpose
vulnerable500050005.3.1Vulnerable environment
patched500150005.4Remediated environment

4. Repository Structure

root@kitploit:~
cve-2020-14343-lab/
│
├── vulnerable/
│   ├── app.py
│   ├── Dockerfile
│   └── requirements.txt
│
├── patched/
│   ├── app.py
│   ├── Dockerfile
│   └── requirements.txt
│
├── exploit/
│   └── reproduce.py
│
├── detection/
│   └── detect.py
│
├── docker-compose.yml
└── README.md

Directory Description

File/DirectoryPurpose
vulnerable/app.pyFlask application using vulnerable YAML loading
vulnerable/DockerfileBuilds the vulnerable Docker image
vulnerable/requirements.txtPins PyYAML to 5.3.1
patched/app.pyFlask application using secure YAML loading
patched/DockerfileBuilds the patched Docker image
patched/requirements.txtPins PyYAML to 5.4
exploit/reproduce.pyReproduces the vulnerability using a controlled payload
detection/detect.pyChecks the PyYAML version inside a Docker container
docker-compose.ymlBuilds and runs both environments

5. Prerequisites

The following software is required:

  • Docker Desktop
  • Docker Compose
  • Python 3.x
  • Git

Docker Desktop must be running before starting the lab.

The vulnerable application is intentionally exposed only on the local machine through Docker port mappings.

6. Lab Setup

Step 1: Start the Lab

From the project root directory, run:

root@kitploit:~
docker compose up --build -d

Step 2: Verify the Containers

Run:

root@kitploit:~
docker compose ps

Both services should show Up.

Step 3: Verify the Vulnerable Application

Open:

root@kitploit:~
http://127.0.0.1:5000

Expected response:

root@kitploit:~
{
  "message": "CVE-2020-14343 vulnerable YAML parser"
}

Step 4: Verify the Patched Application

Open:

root@kitploit:~
http://127.0.0.1:5001

Expected response:

root@kitploit:~
{
  "message": "CVE-2020-14343 patched YAML parser"
}

7. Starting, Stopping and Rebuilding the Lab

Start

root@kitploit:~
docker compose up -d

Stop

root@kitploit:~
docker compose down

Build and Start

root@kitploit:~
docker compose up --build -d

Check Running Services

root@kitploit:~
docker compose ps

View Vulnerable Application Logs

root@kitploit:~
docker logs cve-vulnerable

View Patched Application Logs

root@kitploit:~
docker logs cve-patched

8. Vulnerability Reproduction

The vulnerable application exposes a /parse endpoint that accepts YAML input.

The vulnerable environment uses:

  • PyYAML 5.3.1
  • yaml.FullLoader

The reproduction script is located at:

root@kitploit:~
exploit/reproduce.py

Run the Exploit

The vulnerable application is available at:

root@kitploit:~
http://127.0.0.1:5000/parse

Run:

root@kitploit:~
python exploit/reproduce.py

The script sends a controlled YAML payload containing a Python-specific YAML tag.

Expected Result

In the vulnerable environment, the payload is accepted and the application returns an HTTP 200 response.

The controlled test marker:

root@kitploit:~
CVE-2020-14343-TEST

is executed inside the vulnerable application container.

The execution can be verified using:

root@kitploit:~
docker logs cve-vulnerable

Expected log output includes:

root@kitploit:~
CVE-2020-14343-TEST

This demonstrates code execution through the vulnerable YAML loading behavior.

Safety

The reproduction payload is intentionally harmless. It only prints a test marker and does not modify the host system, access credentials, access sensitive data, interact with external systems, or perform destructive actions.

9. Vulnerability Detection

The detection script is located at:

root@kitploit:~
detection/detect.py

The script checks the PyYAML version installed inside the specified Docker container.

The fixed version is:

root@kitploit:~
5.4

Detect the Vulnerable Environment

Run:

root@kitploit:~
python detection/detect.py cve-vulnerable

Expected result:

root@kitploit:~
PyYAML installed version: 5.3.1
Fixed version: 5.4
STATUS: VULNERABLE
Reason: PyYAML version is older than 5.4.

Detect the Patched Environment

Run:

root@kitploit:~
python detection/detect.py cve-patched

Expected result:

root@kitploit:~
PyYAML installed version: 5.4
Fixed version: 5.4
STATUS: PATCHED
Reason: PyYAML version is 5.4 or newer.

Detection Logic

root@kitploit:~
Docker Container
       |
       v
   docker exec
       |
       v
  Import PyYAML
       |
       v
Read yaml.__version__
       |
       v
 Compare with 5.4
       |
       +----------------------+
       |                      |
     < 5.4                  >= 5.4
       |                      |
       v                      v
  VULNERABLE                PATCHED

The script queries the installed PyYAML version from the target container.

10. Remediation

The vulnerable environment uses:

root@kitploit:~
PyYAML==5.3.1

The patched environment uses:

root@kitploit:~
PyYAML==5.4

The patched application also uses:

root@kitploit:~
yaml.safe_load(yaml_input)

instead of:

root@kitploit:~
yaml.load(yaml_input, Loader=yaml.FullLoader)

Remediation Steps

  1. Upgrade PyYAML to version 5.4 or later.
  2. Avoid unsafe YAML loading behavior when processing untrusted input.
  3. Use yaml.safe_load() when the application only requires standard YAML data types.
  4. Rebuild the Docker image.
  5. Restart the patched application.
  6. Run the detection script again.
  7. Re-run the reproduction payload against the patched application.

11. Post-Remediation Verification

The same exploit payload is tested against the patched application.

The patched application runs on:

root@kitploit:~
http://127.0.0.1:5001/parse

Run:

root@kitploit:~
python exploit/reproduce.py http://127.0.0.1:5001/parse

Observed result in this lab:

root@kitploit:~
HTTP Status: 400
Server Response:
{"message":"could not determine a constructor for the tag 'tag:yaml.org,2002:python/object/new:tuple' ...","status":"error"}

The Python-specific YAML tag is rejected by the patched application.

The controlled test marker is not executed in the patched application.

Before vs After

TestVulnerable EnvironmentPatched Environment
PyYAML version5.3.15.4
DetectionVULNERABLEPATCHED
Exploit requestHTTP 200HTTP 400
Python-specific YAML tagAcceptedRejected
Test marker executionObserved in container logsNot executed

12. Troubleshooting

Docker Daemon Is Not Running

Make sure Docker Desktop is running and verify:

root@kitploit:~
docker version

Container Name Conflict

Check:

root@kitploit:~
docker ps -a

Remove old containers if required:

root@kitploit:~
docker rm cve-vulnerable cve-patched

Then:

root@kitploit:~
docker compose up --build -d

Check Container Status

root@kitploit:~
docker compose ps

Check Application Logs

root@kitploit:~
docker logs cve-vulnerable
docker logs cve-patched

Rebuild After Changing Dependencies

root@kitploit:~
docker compose up --build -d

For a clean rebuild:

root@kitploit:~
docker compose build --no-cache
docker compose up -d

13. Limitations

This project is a controlled proof-of-concept lab and does not represent a production deployment.

Limitations include:

  • The vulnerable application is intentionally simplified.
  • The lab uses a harmless proof-of-concept payload.
  • No real credentials or sensitive data are used.
  • The application is designed for local testing.
  • The detection mechanism focuses on the installed PyYAML version.
  • Version-based detection alone does not prove whether a real application is exploitable; application behavior and YAML loading configuration must also be considered.
  • The lab does not attempt exploitation against external or unauthorized systems.

14. Evidence

The following evidence should be captured for the project submission:

  1. Docker Compose showing both containers running.
  2. Vulnerable application responding on port 5000.
  3. Patched application responding on port 5001.
  4. Vulnerable version detection showing PyYAML 5.3.1 and STATUS: VULNERABLE.
  5. Vulnerable exploit execution and the CVE-2020-14343-TEST marker in Docker logs.
  6. Patched version detection showing PyYAML 5.4 and STATUS: PATCHED.
  7. Same exploit against the patched application returning HTTP 400.
  8. Patched application error showing rejection of the Python-specific YAML tag.

Screenshots can be stored in:

root@kitploit:~
screenshots/

15. References

  • GitHub Advisory Database – CVE-2020-14343 / GHSA-8q59-q68h-6hv4
  • PyYAML CHANGES – PyYAML 5.4 release notes
  • PyYAML Wiki – YAML loading and SafeLoader guidance
  • PyYAML Issue #420 – FullLoader and code execution discussion
  • National Vulnerability Database – CVE records related to PyYAML

All reproduction code and documentation in this repository were developed specifically for this lab.

16. Conclusion

This lab demonstrates CVE-2020-14343 from identification through remediation.

The vulnerable environment uses PyYAML 5.3.1 and demonstrates controlled code execution through a crafted YAML payload.

The detection script identifies the vulnerable dependency version.

The remediated environment upgrades PyYAML to 5.4 and uses yaml.safe_load() for processing untrusted YAML.

The same reproduction payload is then rejected by the patched application, providing before-and-after evidence of remediation.

The entire environment can be reproduced using Docker Compose.

Download Tool