Skip to content

security: requireCourseReadAccess grants any authenticated user course read access #154

Open

Description

@rubenvdlinde

Summary

requireCourseReadAccess() in the MCP tool provider performs no real per-course authorization. After rejecting anonymous/empty-UID callers it ends with a tautological return $userId !== '', so any authenticated (non-empty-UID) user passes the course read-access gate regardless of enrolment or role.

Location

  • File: lib/Mcp/ScholiqToolProvider.php
  • Method: requireCourseReadAccess() — lines ~489-509
  • Callers: gate is checked at lines ~227 (listCourses) and ~351 (getCourseDetails) via if ($this->requireCourseReadAccess() === false) { ... }

Observed behavior

private function requireCourseReadAccess(): bool
{
    $user = $this->userSession->getUser();
    if ($user === null) {
        return false;
    }

    $userId = $user->getUID();
    if ($userId === '') {
        return false;
    }

    if ($this->groupManager->isAdmin($userId) === true) {
        return true;
    }

    // Authenticated non-admin user: allowed at the provider boundary;
    // OpenRegister RBAC inside ObjectService scopes the actual rows.
    return $userId !== '';

}//end requireCourseReadAccess()

The final return $userId !== '' is always true at that point (an empty $userId already returned false above), so it is a no-op gate.

Impact

OWASP A01:2021 broken access control. The MCP tools listCourses and getCourseDetails expose course data to any authenticated user, independent of enrolment or role. The inline comment relies on OpenRegister RBAC inside ObjectService to scope rows, but the provider-level gate itself enforces nothing beyond "is logged in".

Suggested fix

Replace the tautology with a real per-course access check — e.g. an enrolment lookup or course-role lookup for the resolved $userId — or, if row-level RBAC truly is the intended boundary, rename/repurpose the method and document that it is only an authentication check (not authorization), and confirm the downstream ObjectService calls actually scope by user.

Source PR

PR #153 (reverse-spec ai-companion-tools)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingsecurity

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions