CVE-2024-34701 (PHP, published 2024-05-14T15:39Z)
Description: value: CreateWiki is Miraheze's MediaWiki extension for requesting & creating wikis. It is possible for users to be considered as the requester of a specific wiki request if their local user ID on any wiki in a wiki farm matches the local ID of the requester at the wiki where the wiki request was made. This allows them to go to that request entry's on Special:RequestWikiQueue on the wiki where their local user ID matches and take any actions that the wiki requester is allowed to take from there.

Commit 02e0f298f8d35155c39aa74193cb7b867432c5b8 fixes the issue. Important note about the fix: This vulnerability has been fixed by disabling access to the REST API and special pages outside of the wiki configured as the "global wiki" in `$wgCreateWikiGlobalWiki` in a user's MediaWiki settings.

As a workaround, it is possible to disable the special pages outside of one's own global wiki by doing something similar to `miraheze/mw-config` commit e5664995fbb8644f9a80b450b4326194f20f9ddc that is adapted to one's own setup. As for the REST API, before the fix, there wasn't any REST endpoint that allowed one to make writes. Regardless, it is possible to also disable it outside of the global wiki by using `$wgCreateWikiDisableRESTAPI` and `$wgConf` in the configuration for one's own wiki farm..
Severity: nan (CVSS v3 base score: )
Weakness: NVD-CWE-noinfo \u2014 Insufficient Information
There is insufficient information about the issue to classify it; details are unkown or unspecified.
Repository: https://github.com/miraheze/CreateWiki
Files changed:
includes/CreateWiki/SpecialCreateWiki.php
includes/EntryPointUtils.php
includes/RequestWiki/Handler/RestWikiRequest.php
includes/RequestWiki/Handler/RestWikiRequestsByUser.php
includes/RequestWiki/SpecialRequestWiki.php
includes/RequestWiki/SpecialRequestWikiQueue.php
includes/RestUtils.php
tests/phpunit/SpecialRequestWikiTest.php
Commit message: T12011: Disable the special pages and API outside of the global wiki (#519)

https://issue-tracker.miraheze.org/T12011

Vulnerable code:
		if ( $this->config->get( 'CreateWikiDisableRESTAPI' ) ) {
			return $this->getResponseFactory()->createLocalizedHttpError( 403, new MessageValue( 'createwiki-rest-disabled' ) );
		}
		if ( $this->config->get( 'CreateWikiDisableRESTAPI' ) ) {
			return $this->getResponseFactory()->createLocalizedHttpError( 403, new MessageValue( 'createwiki-rest-disabled' ) );
		}

Fixed code:
use Miraheze\CreateWiki\EntryPointUtils;
	public function execute( $par ) {
		if ( !EntryPointUtils::currentWikiIsGlobalWiki() ) {
			return $this->getOutput()->addHTML(
				Html::errorBox( $this->msg( 'createwiki-wikinotglobalwiki' )->escaped() )
			);
		}

		parent::execute( $par );
	}

<?php
namespace Miraheze\CreateWiki;

use MediaWiki\MediaWikiServices;
use MediaWiki\WikiMap\WikiMap;

class EntryPointUtils {

	public static function currentWikiIsGlobalWiki(): bool {
		$config = MediaWikiServices::getInstance()->getConfigFactory()->makeConfig( 'CreateWiki' );
		if ( $config->get( 'CreateWikiGlobalWiki' ) === WikiMap::getCurrentWikiId() ) {
			return true;
		} else {
			return false;
		}
	}
}
use Miraheze\CreateWiki\RestUtils;
		RestUtils::checkEnv();
use Miraheze\CreateWiki\RestUtils;
		RestUtils::checkEnv();
use Miraheze\CreateWiki\EntryPointUtils;
		if ( !EntryPointUtils::currentWikiIsGlobalWiki() ) {
			return $this->getOutput()->addHTML(
				Html::errorBox( $this->msg( 'createwiki-wikinotglobalwiki' )->escaped() )
			);
		}

use Html;
use Miraheze\CreateWiki\EntryPointUtils;
		if ( !EntryPointUtils::currentWikiIsGlobalWiki() ) {
			return $this->getOutput()->addHTML(
				Html::errorBox( $this->msg( 'createwiki-wikinotglobalwiki' )->escaped() )
			);
		}

<?php

namespace Miraheze\CreateWiki;

use MediaWiki\MediaWikiServices;
use MediaWiki\Rest\LocalizedHttpException;
use Miraheze\CreateWiki\EntryPointUtils;
use Wikimedia\Message\MessageValue;

class RestUtils {

	/*
	 * Called from the REST handlers, checks that the current wiki is the global wiki and that the REST API is not disabled
	 */
	public static function checkEnv() {
		if ( !EntryPointUtils::currentWikiIsGlobalWiki() ) {
			throw new LocalizedHttpException( new MessageValue( 'createwiki-wikinotglobalwiki' ), 403 );
		}
		$config = MediaWikiServices::getInstance()->getConfigFactory()->makeConfig( 'CreateWiki' );
		if ( $config->get( 'CreateWikiDisableRESTAPI' ) ) {
			throw new LocalizedHttpException( new MessageValue( 'createwiki-rest-disabled' ), 403 );
		}
	}
}
use MediaWiki\WikiMap\WikiMap;
		$this->setMwGlobals( 'wgCreateWikiGlobalWiki', WikiMap::getCurrentWikiId() );
		$this->setMwGlobals( 'wgCreateWikiGlobalWiki', WikiMap::getCurrentWikiId() );