CVE-2023-31143
Mage-ai versions 0.8.34 to 0.8.71, with user authentication enabled, have unauthorized terminal access
- CVSS 9.8
- CWE-306 Missing Authentication for Critical Function
- Authentication, Authorization, and Session Management
- Remote
mage-ai is an open-source data pipeline tool for transforming and integrating data. Those who use Mage starting in version 0.8.34 and prior to 0.8.72 with user authentication enabled may be affected by a vulnerability. The terminal could be accessed by users who are not signed in or do not have editor permissions. Version 0.8.72 contains a fix for this issue.
- CVSS base score
- 9.8
- Published
- 2023-05-09
- OWASP
- A01 Broken Access Control
- Orthogonal defect classification
- Function
- Code defect classification
- Incorrect Functionality
- Category
- Authentication, Authorization, and Session Management
- Subcategory
- Insecure Authentication Mechanisms
- Accessibility scope
- Remote
- Impact
- Unauthorized Access
- Affected component
- mage-ai
- Fixed by upgrading
- Yes
Solution
Update Mage to version 0.8.72 or higher.
Vulnerable code sample
from flask import Flask, request, session
app = Flask(__name__)
app.secret_key = 'your_secret_key'
@app.route('/terminal', methods=['GET'])
def terminal():
# No authentication check, allowing access to anyone
return "Welcome to the terminal!"
if __name__ == '__main__':
app.run()Patched code sample
from flask import Flask, request, abort, session
app = Flask(__name__)
app.secret_key = 'your_secret_key'
def is_authenticated():
return 'user_id' in session and session['user_id'] is not None
@app.route('/terminal', methods=['GET'])
def terminal():
if not is_authenticated():
abort(403) # Forbidden access if not authenticated
# Proceed with terminal access for authenticated users
return "Welcome to the terminal!"
if __name__ == '__main__':
app.run()Published fix
Public sources link this CVE to the changes below. The code samples above were generated to illustrate the defect; these links lead to the code the project actually changed.
- [dy] Fix terminal user authentication (#2586) (mage-ai/mage-ai)
mage_ai/server/terminal_server.py,mage_ai/server/terminal_server.py · TerminalWebsocketServer.open
Cite this entry
@misc{vaitp:cve202331143,
title = {{Mage-ai versions 0.8.34 to 0.8.71, with user authentication enabled, have unauthorized terminal access}},
author = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
year = {2023},
note = {VAITP Python Vulnerability Dataset, entry CVE-2023-31143},
howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2023-31143/}}
}
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 ::
