Page MenuHomePhabricator

Weird anoneditwarning output when adding an external link
Closed, ResolvedPublicSecurity

Description

I was trying to make https://www.mediawiki.org/w/index.php?title=Security%2FSOP%2FSecurity_Preview&type=revision&diff=4830043&oldid=4830041 logged out (didn't notice that I was), and when I hit save, I was presented with a captcha fair enough), but it had a weird block of information in it...

Capture.PNG (1×3 px, 510 KB)

Details

Risk Rating
Medium
Author Affiliation
WMF Technology Dept

Event Timeline

In EditPage:

				$returntoquery = array_diff_key(
					$this->context->getRequest()->getValues(),
					[ 'title' => true, 'returnto' => true, 'returntoquery' => true ]
				);
				$out->wrapWikiMsg(
					"<div id='mw-anon-edit-warning' class='warningbox'>\n$1\n</div>",
					[ 'anoneditwarning',
						// Log-in link
						SpecialPage::getTitleFor( 'Userlogin' )->getFullURL( [
							'returnto' => $this->getTitle()->getPrefixedDBkey(),
							'returntoquery' => wfArrayToCgi( $returntoquery ),
						] ),
						// Sign-up link
						SpecialPage::getTitleFor( 'CreateAccount' )->getFullURL( [
							'returnto' => $this->getTitle()->getPrefixedDBkey(),
							'returntoquery' => wfArrayToCgi( $returntoquery ),
						] )
					]
				);

$returntoquery should use WebRequest::getQueryValues() instead of trying to embed all POST values in the URL too.

I'm guessing this may be a dupe... And probably doesn't need to be a security bug; I just filed it as such I didn't have to worry too much what params were actually in the pasted text

It seems that this is no longer reproducible (as far as I can tell, we only display this message when the form has not been POST-ed now), but it would still be nice to change this code, to avoid this bad pattern being copied elsewhere. (e.g. T309907)

@sbassett There's no security issue here, could you please make this task public?

sbassett triaged this task as Medium priority.Sat, Nov 16, 5:16 PM
sbassett changed Author Affiliation from N/A to WMF Technology Dept.
sbassett changed the visibility from "Custom Policy" to "Public (No Login Required)".
sbassett changed the edit policy from "Custom Policy" to "All Users".
sbassett changed Risk Rating from N/A to Medium.
sbassett added a subscriber: gerritbot.

Change #1091844 merged by jenkins-bot:

[mediawiki/core@master] Don't copy POST query params when generating link/redirect URLs

https://gerrit.wikimedia.org/r/1091844

matmarex claimed this task.
matmarex removed a project: Patch-For-Review.