CVE-2021-40978 is a high-severity (CVSS 7.5) Path Traversal vulnerability in mkdocs. 1 public exploit reference exists, so weaponization risk is real. A fix is available for mkdocs — see the affected versions and patch details below.
Directory traversal in mkdocs
Exploitation Status
Proof-of-concept exploit code exists
- CISA’s SSVC triage found public proof-of-concept exploit code for this CVE, though no confirmed active exploitation.
Exploitation and automatability from CISA’s SSVC triage for CVE-2021-40978.
EPSS Exploitation Probability
Probability of exploitation in the next 30 days, from FIRST.org EPSS.
How urgent is this, really
CVE-2021-40978 by exploitation likelihood (EPSS) against impact (CVSS). Outside the shaded patch-first corner.
Where this sits among everything scored
Of 385,738 CVEs with a current EPSS score, this one falls in the 10–50% band (highlighted). Counts from FIRST.org, log-scaled.
Real-World Exposure
mkdocsReal-time download stats are indexed for npm and PyPI packages. This vulnerability affects PyPI packages — download data is not available via public APIs for these ecosystems.
Description
The mkdocs 1.2.2 built-in dev-server allows directory traversal using the port 8000, enabling remote exploitation to obtain :sensitive information. NOTE: the vendor has disputed this as described in https://github.com/mkdocs/mkdocs/issues/2601.] and https://github.com/nisdn/CVE-2021-40978/issues/1
Affected Packages
| Ecosystem | Package | Vulnerable range | Fix |
|---|---|---|---|
| 🐍PyPI | mkdocs | ≥ 1.2.2&&< 1.2.3 | 1.2.3pip install --upgrade 'mkdocs==1.2.3' |
Affected Products
mkdocsmkdocsResearch use only. For defensive security, authorized penetration testing, and academic research only. Never execute exploit code against systems without explicit written authorization.
Detection & mitigation playbook
Open-source dependencyDetect
Scan your dependency tree (package-lock.json, pnpm-lock.yaml, requirements.txt, go.sum, etc.) for mkdocs, including transitive dependencies — a direct dependency you never call can still pull in a vulnerable version.
Fix
Update mkdocs to 1.2.3 or later, then make sure no transitive (indirect) dependency still pins the vulnerable range — O3 confirms CVE-2021-40978 is resolved across your whole dependency graph.
Workarounds
Resolve every user-supplied path to its canonical form and reject anything that escapes the intended directory, and run the component under an account that has no read or write access outside the directory it legitimately serves.
How to detect CVE-2021-40978
A community-maintained Nuclei template exists for this CVE. You can scan for it directly:
nuclei -id cve-2021-40978 -u https://target- Template
- MKdocs 1.2.2 - Directory Traversal
- Severity
- high
- Impact
- An attacker can read or modify sensitive files on the server, potentially leading to unauthorized access, data leakage, or system compromise.
- Remediation
- Upgrade MKdocs to version 1.2.3 or later to fix the directory traversal vulnerability.
Template by ProjectDiscovery nuclei-templates (pikpikcu), MIT licensed. View the full template. Scan only systems you are authorised to test.
Frequently Asked Questions
Is CVE-2021-40978 in your dependencies?
Find it across PyPI, including transitive dependencies.