Summary
Pyramid static view path traversal up one directory
Workarounds
Use a version of Python 3 that is not affected. Downgrade to Python 3.10 series temporarily, or wait till Python 3.11.5 is released and upgrade to the latest version of Python 3.11 series.
References
- https://owasp.org/www-community/attacks/Path_Traversal
- VN: JVN#41113329
- TN: JPCERT#93311166
Thanks
- Masashi Yamane of LAC Co., Ltd
Impact
This impacts users of Python 3.11 that are using a Pyramid static view with a full filesystem path and have a index.html file that is located exactly one directory above the location of the static view's file system path. No further path traversal exists, and the only file that could be disclosed accidentally is index.html.
Example:
config.add_static_view(name='static', path='/usr/src/app/static', cache_max_age=0)
And directory tree:
/usr/src/app \
| - static \
| - file.css
| - index.html
| - ...
| - index.html <-- (this file could be disclosed with this bug)
Input manipulates file paths to reach files outside the intended directory, such as configuration or credential files. Typical impact: unauthorized file read or write outside the intended directory.
CVE-2023-40587 has a CVSS score of 5.3 (Medium). The vector is network-reachable, no privileges required, and no user interaction. A CVSS score reflects the worst-case severity of the vulnerability, not your specific exposure. Whether this affects your application depends on whether the vulnerable code is present and reachable in your environment. A fixed version is available (2.0.2); upgrading removes the vulnerable code path.
Affected versions
Security releases
Kodem intelligence
Severity tells you how bad this could be in the worst case. It does not tell you whether you are exposed. Exploitability and impact are functions of runtime truth: whether the vulnerable code is present, reachable, and actually executes in your application. A vulnerable package can sit in your dependency tree and never run.
Kodem, an Intelligent Application Security platform, uses runtime intelligence to reveal which vulnerabilities actually execute in production, so teams prioritize the ones that genuinely matter. Kodem's runtime-powered SCA identifies whether this CVE is reachable in your applications.
Already deployed Kodem?
See it in your environmentNew to Kodem? Get a demo →Remediation advice
Pyramid now will reject any path that contains a null-byte out of caution. While valid in directory/file names, we would strongly consider it a mistake to use null-bytes in naming files/directories.
Secondly, Python 3.11, and 3.12 has fixed the underlying issue in os.path.normpath to no longer truncate on the first 0x00 found, returning the behavior to pre-3.11 Python, un an as of yet unreleased version, see:
At the time the following Python versions are not fixed:
- Python 3.11.0 to 3.11.4
- Python 3.12.0a1 to 3.12.0rc1
Fixes will be available in: Python 3.12.0rc2 or 3.11.5.
Please note that release candidates of Python are not production ready and should not be used for production workloads.
Frequently Asked Questions
- What is CVE-2023-40587? CVE-2023-40587 is a medium-severity path traversal vulnerability in pyramid (pip), affecting versions >= 2.0.0, < 2.0.2. It is fixed in 2.0.2. Input manipulates file paths to reach files outside the intended directory, such as configuration or credential files.
- How severe is CVE-2023-40587? CVE-2023-40587 has a CVSS score of 5.3 (Medium). This score reflects the worst-case severity of the vulnerability, not your specific exposure. Whether it represents real risk in your environment depends on whether the vulnerable code is present and reachable.
- Which versions of pyramid are affected by CVE-2023-40587? pyramid (pip) versions >= 2.0.0, < 2.0.2 is affected.
- Is there a fix for CVE-2023-40587? Yes. CVE-2023-40587 is fixed in 2.0.2. Upgrade to this version or later.
- Is CVE-2023-40587 exploitable, and should I be worried? Whether CVE-2023-40587 is exploitable in your environment depends on whether the vulnerable code is present and reachable. A CVSS score is a worst-case rating; it does not account for your specific deployment, configuration, or usage patterns. Kodem, an Intelligent Application Security platform, uses runtime intelligence to show which vulnerabilities actually execute in production, so you can focus on the ones that represent real risk. Get a demo
- What actually determines whether CVE-2023-40587 is exploitable, and how bad it is? Exploitability and impact are not fixed properties of a CVE. They depend on runtime truth: whether the vulnerable code is present, reachable, and actually executes in your application. A high CVSS score on a dependency that never runs is not the same as real risk. Kodem, an Intelligent Application Security platform, uses runtime intelligence to reveal which vulnerabilities actually execute in production, so teams prioritize the ones that genuinely matter.
- How do I fix CVE-2023-40587? Upgrade
pyramidto 2.0.2 or later.