VAITP Dataset

← Back to the dataset

CVE-2024-45189

Path traversal in Mage AI allows file leakage for "Viewer" role users.

  • CVSS 6.5
  • CWE-22
  • Information Leakage
  • Remote

Mage AI allows remote users with the "Viewer" role to leak arbitrary files from the Mage server due to a path traversal in the "Git Content" request

CVSS base score
6.5
Published
2024-08-23
OWASP
A05 Security Misconfiguration
Orthogonal defect classification
Checking
Code defect classification
Incorrect Functionality
Category
Information Leakage
Subcategory
Path Traversal
Accessibility scope
Remote
Impact
Information Disclosure

Solution

Upgrade Mage AI to the latest version that addresses the path traversal vulnerability.

Vulnerable code sample

from flask import Flask, request

app = Flask(__name__)

@app.route('/git_content', methods=['GET'])
def git_content():
    user_role = request.args.get('role')
    if user_role != 'Viewer':
        return "Forbidden", 403

    requested_file = request.args.get('file')

    try:
        with open(requested_file, 'r') as file:
            content = file.read()
        return content, 200
    except FileNotFoundError:
        return "Not Found", 404

if __name__ == '__main__':
    app.run()

Patched code sample

import os
from flask import Flask, request, abort

app = Flask(__name__)

@app.route('/git_content', methods=['GET'])
def git_content():
    user_role = request.args.get('role')
    if user_role != 'Viewer':
        abort(403)

    requested_file = request.args.get('file')

    base_path = '/base/directory/'
    path = os.path.normpath(os.path.join(base_path, requested_file))

    if not path.startswith(base_path):
        abort(400)

    try:
        with open(path, 'r') as file:
            content = file.read()
        return content, 200
    except FileNotFoundError:
        abort(404)

if __name__ == '__main__':
    app.run()

Payload

/git_content?role=Viewer&file=../../../../etc/passwd

Cite this entry

@misc{vaitp:cve202445189,
  title        = {{Path traversal in Mage AI allows file leakage for "Viewer" role users.}},
  author       = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
  year         = {2024},
  note         = {VAITP Python Vulnerability Dataset, entry CVE-2024-45189},
  howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2024-45189/}}
}
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 ::