Skip to content

Commit

Permalink
SECURITY: Prevent blocked users from purging pages
Browse files Browse the repository at this point in the history
CVE-2021-35197

Bug: T280226
Change-Id: Id783618e885998cddf45a4cfc7b2c19fd0c7e9f5
  • Loading branch information
reedy committed Jun 23, 2021
1 parent d262673 commit 7fc84bb
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
1 change: 1 addition & 0 deletions RELEASE-NOTES-1.36
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ THIS IS NOT A RELEASE YET
* (T235554) Disable DEFER_SET_LENGTH_AND_FLUSH headers to avoid HTTP errors.
* (T278579) Don't send headers on ob_end_clean().
* (T285287) MultiHttpClient: Replace PHP version check with defined().
* (T280226, CVE-2021-35197) SECURITY: Prevent blocked users from purging pages.

== MediaWiki 1.36.0 ==

Expand Down
4 changes: 0 additions & 4 deletions includes/actions/PurgeAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,6 @@ public function getName() {
return 'purge';
}

public function requiresUnblock() {
return false;
}

public function getDescription() {
return '';
}
Expand Down
9 changes: 8 additions & 1 deletion includes/api/ApiPurge.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,14 @@ class ApiPurge extends ApiBase {
* Purges the cache of a page
*/
public function execute() {
$user = $this->getUser();

// Fail early if the user is sitewide blocked.
$block = $user->getBlock();
if ( $block && $block->isSitewide() ) {
$this->dieBlocked( $block );
}

$params = $this->extractRequestParams();

$continuationManager = new ApiContinuationManager( $this, [], [] );
Expand All @@ -42,7 +50,6 @@ public function execute() {
$pageSet->execute();

$result = $pageSet->getInvalidTitlesAndRevisions();
$user = $this->getUser();

foreach ( $pageSet->getGoodTitles() as $title ) {
$r = [];
Expand Down

0 comments on commit 7fc84bb

Please sign in to comment.