Skip to content

Fix missing sesskey validation on state-changing admin endpoints - #3371

Open
Patryk Mroczko (patmr7) wants to merge 1 commit into
MOODLE_502_STABLEfrom
wip-133982-m502
Open

Fix missing sesskey validation on state-changing admin endpoints#3371
Patryk Mroczko (patmr7) wants to merge 1 commit into
MOODLE_502_STABLEfrom
wip-133982-m502

Conversation

@patmr7

Copy link
Copy Markdown
Collaborator

No description provided.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR strengthens CSRF protections in the Microsoft 365 Moodle integration by enforcing sesskey validation on several state-changing admin endpoints and ensuring the initiating URLs include a sesskey where needed.

Changes:

  • Added require_sesskey() checks to multiple state-changing actions (e.g., cohort sync deletion, user match queue clearing, Teams connection operations, maintenance cleanup, and user connection actions).
  • Updated admin/action URLs to include sesskey => sesskey() so the new sesskey requirements can be satisfied when actions are triggered via links/AJAX.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
local/o365/cohortsync.php Requires sesskey for the delete action that removes cohort sync mappings.
local/o365/classes/page/acp.php Enforces sesskey checks on multiple ACP state-changing modes and adds sesskey to several action URLs.
local/o365/classes/form/cohortsync.php Adds sesskey to the “delete mapping” URL used by the cohort sync UI.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread local/o365/classes/page/acp.php Outdated

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

Suppressed comments (1)

local/o365/classes/page/acp.php:1961

  • mode_maintenance_cleandeltatoken() now enforces require_sesskey(), but the navbar link built later in this method uses ['mode' => 'cleandeltatoken'] (missing the maintenance_ prefix) and does not include sesskey. Clicking that breadcrumb will route to the wrong mode and/or fail sesskey validation.
        require_sesskey();


// Clear delta token.
$toolurl = new url($this->url, ['mode' => 'maintenance_cleandeltatoken']);
$toolurl = new url($this->url, ['mode' => 'maintenance_cleandeltatoken', 'sesskey' => sesskey()]);

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants