Summary
An Insecure Direct Object Reference (IDOR) vulnerability in Chamilo LMS allows authenticated users to manipulate the user parameter in the /api/course_rel_users endpoint to enroll arbitrary accounts into any course.
Because the backend fails to verify that the requester is authorized to act on behalf of the referenced user ID, attackers can tamper with user-course relationships and grant unintended access to course materials.
Affected context
This vulnerability affects Chamilo LMS deployments that expose the /api/course_rel_users endpoint and rely on it for managing course enrollments.
It manifests when the server trusts the user identifier provided in the request body without cross-checking that the authenticated caller is the same user or has explicit privilege (e.g., admin, teacher) to manage that user's enrollments.
Any authenticated account with access to this API can potentially abuse the weakness, regardless of their intended role, as long as the endpoint is reachable and no additional server-side checks are enforced.
Exploit preconditions
- Attack surface: HTTP API endpoint
/api/course_rel_userson the Chamilo LMS server. - Required access: Valid authenticated session to the LMS; no elevated admin role is required if the endpoint is broadly accessible.
- Trigger point: Sending a crafted request body to
/api/course_rel_userswhere theuserfield is replaced with the ID of a different target account and the course identifier points to any desired course. - Why exploitation is possible: The backend uses the client-supplied
userID as the authoritative subject of the enrollment operation without verifying ownership or permission, leading to a direct object reference that is not protected by proper authorization checks.
Why this happens
The underlying issue is a classic Insecure Direct Object Reference (CWE-639).
The API accepts a direct identifier (user ID) for the subject of the enrollment and assumes it is valid and authorized when issued by any authenticated caller.
Instead of deriving the acting user's identity from the session and enforcing role-based authorization on whose enrollments can be modified, the code trusts client-controlled identifiers, allowing one user to act on behalf of others.
This pattern emerges when access control is implemented only at the authentication level (logged in vs. not logged in) and not at the object level (which specific user or resource the caller may modify).
Potential impact
- Attackers can enroll arbitrary users into courses they did not request or consent to join.
- Unauthorized users may gain access to restricted course content and learning materials.
- Instructors' or administrators' intended enrollment workflows and prerequisites can be bypassed.
- Audit trails and course participation records can be manipulated, undermining platform integrity.
- Misuse could impact grading, certification, or compliance processes tied to course completion.
General mitigation guidance
Effective mitigation centers on enforcing strict, server-side authorization around object identifiers in API calls:
- Derive the acting user's identity from the authenticated session or token rather than trusting
userIDs in the request body for sensitive operations. - Implement object-level access control checks to verify that the caller is either the same user whose enrollment is being modified or has an appropriate role (e.g., admin, course manager) for that target user and course.
- Treat all client-provided identifiers as untrusted and validate them against the caller's permissions before performing changes to user-course relationships.
- Centralize authorization logic in reusable policy helpers to ensure consistent checks across all endpoints that manage enrollments and user relationships.
- Apply the principle of least privilege so that standard learner accounts cannot programmatically manage enrollments for other users.
How teams detect issues like this
Detection efforts can focus on both code and runtime behavior:
- Static analysis and review: Look for API handlers that:
- Accept user or account IDs in request bodies or query parameters.
- Perform updates to enrollment or relationship tables without checking that the authenticated user matches the referenced user or has specific role-based permissions.
- Code review signals: Endpoints that modify
course_rel_usersor similar tables should: - Use session-derived user IDs.
- Invoke centralized authorization checks or policy engines before writes.
- Runtime monitoring: Analyze logs for patterns where a single account frequently enrolls other accounts into many courses, especially where the acting account does not have an administrative role.
- Automated tools: Identity and access control linters, API contract analyzers, or custom SAST rules can help flag direct object references where user identifiers from requests are used without accompanying permission checks.

