CVE-2022-31575
GitHub repository duducosmos/livro_python: Absolute path traversal via Flask send_file
- CVSS 9.3
- CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')
- Input Validation and Sanitization
- Remote
The duducosmos/livro_python repository through 2018-06-06 on GitHub allows absolute path traversal because the Flask send_file function is used unsafely.
- CVSS base score
- 9.3
- Published
- 2022-07-11
- OWASP
- A01 Broken Access Control
- Orthogonal defect classification
- Interface
- Code defect classification
- Incorrect Interface
- Category
- Input Validation and Sanitization
- Subcategory
- Path Traversal
- Accessibility scope
- Remote
- Impact
- Information Disclosure
- Fixed by upgrading
- Yes
Solution
Fix by updating Flask and the duducosmos/livro_python repository to the latest versions
Vulnerable code sample
from flask import Flask, send_file
app = Flask(__name__)
@app.route('/download/<path:filename>')
def download_file(filename):
return send_file(filename)
if __name__ == '__main__':
app.run()Patched code sample
from flask import Flask, send_file, abort, join, send_from_directory
import os
app = Flask(__name__)
@app.route('/download/<path:filename>')
def download_file(filename):
directory = '/path/to/directory'
path = join(directory, filename)
if os.path.isfile(path):
return send_file(path)
else:
abort(404)
if __name__ == '__main__':
app.run()Cite this entry
@misc{vaitp:cve202231575,
title = {{GitHub repository duducosmos/livro_python: Absolute path traversal via Flask send_file}},
author = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
year = {2022},
note = {VAITP Python Vulnerability Dataset, entry CVE-2022-31575},
howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2022-31575/}}
}
Introducing the "VAITP dataset": a specialized repository of Python vulnerabilities and patches, meticulously compiled for the use of the security research community. As Python's prominence grows, understanding and addressing potential security vulnerabilities become crucial. Crafted by and for the cybersecurity community, this dataset offers a valuable resource for researchers, analysts, and developers to analyze and mitigate the security risks associated with Python. Through the comprehensive exploration of vulnerabilities and corresponding patches, the VAITP dataset fosters a safer and more resilient Python ecosystem, encouraging collaborative advancements in programming security.
The supreme art of war is to subdue the enemy without fighting.
Sun Tzu – “The Art of War”
:: Shaping the future through research and ingenuity ::
