The analysis is based on the provided vulnerability description and a publicly available proof-of-concept. The vulnerability is a classic session fixation attack within Moodle's OAuth2 authentication mechanism. The root cause is the system's failure to create a new session for a user upon successful login, instead reusing the session identifier (sesskey) provided in the login URL.
The exploitation process, as detailed in the PoC, begins with the attacker directing the victim to a specially crafted URL pointing to auth/oauth2/login.php. This URL contains a sesskey obtained from an unauthenticated session initiated by the attacker. This script, auth/oauth2/login.php, is therefore the primary entry point for the vulnerability.
After the victim authenticates with the OAuth2 provider, the callback process in Moodle is initiated. During this phase, the core_auth\api::set_user_session function is called to associate the authenticated user with the current session. Because the session ID was not regenerated after authentication, this function effectively logs the victim into the session controlled by the attacker.
Identifying a precise patch is challenging because the vulnerability affected an end-of-life version (3.11.x) and was addressed in a new major version (4.0.0). Such upgrades often involve substantial code refactoring, meaning the fix is likely part of a larger rewrite of the authentication system rather than a simple, targeted patch. The identified functions are based on the clear evidence from the PoC and a logical analysis of the session fixation workflow in Moodle's architecture.