Page MenuHomePhabricator

Cache pollution after a revert causing autoblocks on WMCS ranges
Closed, ResolvedPublicSecurity

Description

I'm making this task after the problem has already been solved as a record just in case there are any similar issues in the future. Its private for now in case there are other affected wikis that we haven't noticed yet; Security-Team this should be ok to publish by your clinic meeting on Monday unless you have other reasons to keep this private.

A patch renaming the MediaWiki:Autoblock_whitelist page was deployed on Wednesday during the train and was rolled back on Thursday due to an unrelated issue. A user moved the interface page to the new name on Commons about a day after the initial deploy, just before the train was rolled back. When the patch was reverted on the train rollback, the original name was no longer available until it was re-created about 12 hours later.

After reports from Toolforge users about autoblocks I started investigating and realized that due to caching in DatabaseBlock::isWhitelistedFromAutoblocks the version without the old (and at that point only working) exemption list page was being cached, effectively removing its effects completely.

@Urbanecm cleared those caches on commonswiki like seen below:

>>> \MediaWiki\Block\DatabaseBlock::isWhitelistedFromAutoblocks("172.16.7.167")
=> false
>>> $cache = \MediaWiki\MediaWikiServices::getInstance()->getMainWANObjectCache();
=> WANObjectCache {#527}
>>> $key = $cache->makeKey( 'ip-autoblock', 'whitelist' )
=> "commonswiki:ip-autoblock:whitelist"
>>> $cache->get($key)
=> [
     "",
   ]
>>> $cache->delete($key)
=> true
>>> $cache->get($key)
=> false
>>> \MediaWiki\Block\DatabaseBlock::isWhitelistedFromAutoblocks("172.16.7.167")
=> true

(for anyone wondering, 172.16.7.167 is a Toolforge bastion)

He also removed commonswiki autoblock #405016 with a maintenance script to remove the already-present autoblock.

Details

Author Affiliation
Wikimedia Communities

Event Timeline

taavi assigned this task to Urbanecm.

While it was noticed within a WMCS ip range first, I believe this affects everything utilizing the exemption ranges (https://commons.wikimedia.org/wiki/MediaWiki:Block-autoblock-exemptionlist).

I just checked autoblocks for other autoblocked IPs on commonswiki from that list, and found none. The clear of the cache should be enough I think.

This comment was removed by Urbanecm.
sbassett subscribed.

@Majavah @Urbanecm -

Thanks for investigating and getting this fixed. Unless someone has an issue with exposing a toolforge IP (can't imagine anyone would), we should be able to make this public next week. Thankfully this appears to be a case where something broke and, while technically making things more secure, it introduced a Vuln-DoS for those on various exemption lists for an extended period of time.

Unless someone has an issue with exposing a toolforge IP (can't imagine anyone would)

The IP in the description is a private address, and even if it wasn't, public WMF IP addresses are public information anyways, so publishing should be fine.

Urbanecm changed the visibility from "Custom Policy" to "Public (No Login Required)".Mar 31 2021, 2:10 PM
Urbanecm changed the edit policy from "Custom Policy" to "All Users".

Task published, no need to keep this private anymore.