VAITP Dataset

← Back to the dataset

CVE-2025-47942

Open edX allows unauthorized download of `python_lib.zip`, exposing grading code/answers.

  • CVSS 5.3
  • CWE-862
  • Configuration Issues
  • Remote

The Open edX Platform is a learning management platform. Prior to commit 6740e75c0fdc7ba095baf88e9f5e4f3e15cfd8ba, edxapp has no built-in protection against downloading the python_lib.zip asset from courses, which is a concern since it often contains custom grading code or answers to course problems. This potentially affects any course using custom Python-graded problem blocks. The openedx/configuration repo has had a patch since 2016 in the form of an nginx rule, but this was only intended as a temporary mitigation. As the configuration repo has been deprecated and we have not been able to locate any similar protection in Tutor, it is likely that most deployments have no protection against python_lib.zip being downloaded. The recommended mitigation, implemented in commit 6740e75c0fdc7ba095baf88e9f5e4f3e15cfd8ba, restricts python_lib.zip downloads to just the course team and site staff/superusers.

CVSS base score
5.3
Published
2025-05-21
OWASP
A05 Security Misconfiguration
Orthogonal defect classification
Interface
Code defect classification
Missing Functionality
Category
Configuration Issues
Subcategory
Insecure Direct Object References (IDOR)
Accessibility scope
Remote
Impact
Information Disclosure
Affected component
edxapp
Fixed by upgrading
Yes

Solution

Upgrade to a version containing commit 6740e75c0fdc7ba095baf88e9f5e4f3e15cfd8ba or later.

Vulnerable code sample

import os
import zipfile
from flask import Flask, send_file, abort, request

app = Flask(__name__)

COURSE_DIR = 'courses'  # Directory where course content is stored

def is_user_authorized(course_id):
    """
    Simulates authorization check.  BEFORE the fix, this is always True.
    This is the CORE of the vulnerability.  In a real system, this would involve
    checking user roles against a database or authentication system.  But pre-fix,
    it's trivially bypassed because it does *nothing*.

    In a realistic Open edX environment, this might look something like checking 
    if the user is authenticated and belongs to the course team or is a staff member.
    """
    # BEFORE the fix, everyone is "authorized".
    return True  # This is the vulnerability!



@app.route('/courses/<course_id>/python_lib.zip')
def download_python_lib(course_id):
    """
    Serves the python_lib.zip file for a given course.
    """

    if not is_user_authorized(course_id):
        abort(403)  # Forbidden - user not authorized
    
    filepath = os.path.join(COURSE_DIR, course_id, 'python_lib.zip')

    if not os.path.exists(filepath):
        abort(404)  # Not Found - file doesn't exist

    return send_file(filepath, as_attachment=True)


if __name__ == '__main__':
    # Create a dummy course and python_lib.zip for testing.
    os.makedirs(os.path.join(COURSE_DIR, 'test_course'), exist_ok=True)
    
    # Create a dummy python_lib.zip (don't put sensitive info here!)
    with zipfile.ZipFile(os.path.join(COURSE_DIR, 'test_course', 'python_lib.zip'), 'w') as zf:
        zf.writestr('dummy_grading_code.py', 'def grade(submission):\n  return 100  # Always pass!')

    app.run(debug=True)

Patched code sample

from functools import wraps
from django.core.exceptions import PermissionDenied
from django.contrib.auth.decorators import user_passes_test

def is_course_team_member(user, course_id):
    """
    Checks if a user is a member of the course team or a staff/superuser.
    This is a simplified example.  In a real Open edX environment, this
    would likely involve querying a course access/permissions model.
    """
    # Replace this with actual logic to determine course team membership.
    # This is a placeholder!
    # For example, you might check if the user is in a group associated with the course.
    # Or, you might consult a specific course authorization table.
    # This example just always allows the user if they are staff.
    return user.is_staff  #  Replace with real logic!

def course_team_only(course_id_func):
    """
    Decorator to restrict access to views to course team members and staff.

    Args:
        course_id_func: A function that takes request as input and returns the course_id
    """
    def decorator(view_func):
        @wraps(view_func)
        def _wrapped_view(request, *args, **kwargs):
            course_id = course_id_func(request, *args, **kwargs)
            if is_course_team_member(request.user, course_id):
                return view_func(request, *args, **kwargs)
            else:
                raise PermissionDenied

        return _wrapped_view

    return decorator


# Example Usage (Illustrative)

def get_course_id_from_request(request, *args, **kwargs):
    # Extract the course_id from the request.
    # This could be in the URL, POST data, or elsewhere.
    # Replace this with the actual logic to extract the course_id from the request.
    # Example assuming the course_id is in the URL as 'course_id':
    return kwargs.get('course_id')



@course_team_only(get_course_id_from_request)
def download_python_lib(request, course_id):
    """
    View to serve the python_lib.zip file, protected by course team access.
    """
    # In a real implementation:
    # 1. Verify the course_id is valid.
    # 2. Construct the path to the python_lib.zip file (be careful about security!).
    # 3. Serve the file using Django's `FileResponse` or `HttpResponse`.

    # Placeholder - Replace with actual file serving logic
    return HttpResponse("python_lib.zip content (protected)", content_type="application/zip")


# Another way to implement. (Using user_passes_test directly)

def check_course_team(user, course_id):
    return is_course_team_member(user, course_id)

def get_course_id_direct(request, course_id):
    return course_id

@user_passes_test(lambda u, course_id: check_course_team(u, course_id=course_id), login_url='/login/')
def download_python_lib_direct(request, course_id):
    """
    View to serve the python_lib.zip file, protected by course team access.
    using the user_passes_test decorator directly
    """
    # Placeholder - Replace with actual file serving logic
    return HttpResponse("python_lib.zip content (protected - direct)", content_type="application/zip")

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.

  • Merge commit from fork (openedx/edx-platform)
    openedx/core/djangoapps/contentserver/views.py, openedx/core/djangoapps/contentserver/views.py · is_user_authorized, openedx/core/djangoapps/contentserver/views.py · process_request, openedx/core/djangoapps/contentserver/views.py · set_caching_headers, openedx/core/lib/xblock_serializer/utils.py, openedx/core/lib/xblock_serializer/utils.py · get_python_lib_zip_if_using, xmodule/util/sandboxing.py, xmodule/util/sandboxing.py · get_python_lib_zip

Cite this entry

@misc{vaitp:cve202547942,
  title        = {{Open edX allows unauthorized download of `python_lib.zip`, exposing grading code/answers.}},
  author       = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
  year         = {2025},
  note         = {VAITP Python Vulnerability Dataset, entry CVE-2025-47942},
  howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2025-47942/}}
}

Download this entry as JSON Download the whole dataset

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 ::

Before you use the VAITP AI models

Please read and accept the following disclaimer:

By choosing "I understand and accept", you acknowledge that you understand and agree to these terms.