CVE-2019-17019
Firefox < 72 on Windows allows Python files served as text/plain to be executed instead of opened (security vulnerability)
- CVSS 8.8
- CWE-116: Improper Encoding or Escaping of Output
- Input Validation and Sanitization
- Local
When Python was installed on Windows, a python file being served with the MIME type of text/plain could be executed by Python instead of being opened as a text file when the Open option was selected upon download. *Note: this issue only occurs on Windows. Other operating systems are unaffected.*. This vulnerability affects Firefox < 72.
- CVSS base score
- 8.8
- Published
- 2020-01-08
- OWASP
- A05 Security Misconfiguration
- Orthogonal defect classification
- Function
- Code defect classification
- Incorrect Functionality
- Category
- Input Validation and Sanitization
- Subcategory
- Insecure Parsing or Deserialization
- Accessibility scope
- Local
- Impact
- Arbitrary Code Execution
- Affected component
- Python
- Fixed by upgrading
- Yes
Solution
Update Firefox to version 72 or higher.
Vulnerable code sample
import os
import mimetypes
from flask import Flask, send_file, request, abort
app = Flask(__name__)
@app.route('/download/<path:filename>')
def download_file(filename):
# Determine the MIME type
mime_type, _ = mimetypes.guess_type(filename)
# Serve the file with its actual MIME type, including .py files
try:
return send_file(filename, mimetype=mime_type, as_attachment=True)
except FileNotFoundError:
abort(404)
if __name__ == '__main__':
app.run()Patched code sample
import os
import mimetypes
from flask import Flask, send_file, request, abort
app = Flask(__name__)
@app.route('/download/<path:filename>')
def download_file(filename):
# Determine the MIME type
mime_type, _ = mimetypes.guess_type(filename)
# Prevent execution of .py files by serving them with a safe MIME type
if filename.endswith('.py'):
mime_type = 'application/octet-stream' # Change to a non-executable type
try:
return send_file(filename, mimetype=mime_type, as_attachment=True)
except FileNotFoundError:
abort(404)
if __name__ == '__main__':
app.run()Cite this entry
@misc{vaitp:cve201917019,
title = {{Firefox < 72 on Windows allows Python files served as text/plain to be executed instead of opened (security vulnerability)}},
author = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
year = {2020},
note = {VAITP Python Vulnerability Dataset, entry CVE-2019-17019},
howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2019-17019/}}
}
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 ::
