Last modified: 2014-11-20 17:56:24 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T68776, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 66776 - API output containing <cross-domain-policy> is corrupted in non-XML formats
API output containing <cross-domain-policy> is corrupted in non-XML formats
Status: RESOLVED FIXED
Product: MediaWiki
Classification: Unclassified
API (Other open bugs)
1.24rc
All All
: Normal normal (vote)
: ---
Assigned To: Nobody - You can work on this!
https://www.mediawiki.org/w/api.php?a...
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2014-06-18 11:38 UTC by Kevin Israel (PleaseStand)
Modified: 2014-11-20 17:56 UTC (History)
6 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments
Patch to work around wfMangleFlashPolicy, if we're not going to just get rid of it (2.54 KB, patch)
2014-11-18 19:37 UTC, Brad Jorsch
Details

Description Kevin Israel (PleaseStand) 2014-06-18 11:38:46 UTC
The wfMangleFlashPolicy() function in OutputHandler.php corrupts API output containing "<cross-domain-policy>" by replacing the string with "<NOT-cross-domain-policy>".

https://www.mediawiki.org/w/api.php?action=query&format=json&titles=%3Ccross-domain-policy%3E

https://en.wikipedia.org/w/index.php?title=User:PleaseStand/Sandbox&diff=540155307&oldid=540154194

In 2007, wfMangleFlashPolicy() was added in r19996. About a year later, Adobe addressed the vulnerability in Flash Player, and six years have since passed.

According to Adobe's website, by default Flash Player 10 only allows crossdomain.xml at the root ("master-only" meta-policy). So it may be possible simply to remove the check, which already fails to work on many PHP configurations (e.g. output_buffering = 4096 from the sample php.ini files). There is also an "X-Permitted-Cross-Domain-Policies" header that can be sent.

https://www.adobe.com/devnet/flashplayer/articles/fplayer9_security.edu.html

Alternatively, ApiFormatJson could be changed to hex-escape < and > (by removing the FormatJson::XMLMETA_OK flag), though that would do nothing to fix the other (deprecated?) non-XML output formats (e.g. PHP), action=raw, and so on.
Comment 1 Brad Jorsch 2014-06-18 15:06:26 UTC
If Chris is ok with killing wfMangleFlashPolicy(), IMO that'd be the best fix.

Otherwise I'd rather add a more targeted mangling in ApiFormatJson instead of just removing the FormatJson::XMLMETA_OK flag.
Comment 2 Chris Steipp 2014-06-18 20:38:11 UTC
I think I'd prefer to leave the option for mangling in, even if it's behind a feature flag. I'll try to test out a couple of scenarios to confirm exactly which versions of flash could be affected.

TIL: the mangling doesn't happen for anyone who has output buffering enabled on their webserver (since ob_get_level will not be 0 in WebStart.php). So I would guess a lot of non-WMF wikis aren't even using it.
Comment 3 Brad Jorsch 2014-11-18 19:37:34 UTC
Created attachment 17162 [details]
Patch to work around wfMangleFlashPolicy, if we're not going to just get rid of it
Comment 4 Gerrit Notification Bot 2014-11-18 21:45:15 UTC
Change 174289 had a related patch set uploaded by CSteipp:
Make calling wfMangleFlashPolicy configurable

https://gerrit.wikimedia.org/r/174289
Comment 5 Brad Jorsch 2014-11-19 16:49:19 UTC
(In reply to Gerrit Notification Bot from comment #4)
> Change 174289 had a related patch set uploaded by CSteipp:
> Make calling wfMangleFlashPolicy configurable
> 
> https://gerrit.wikimedia.org/r/174289

After this change, we'd want to adjust the includes/api/ApiFormatPhp.php bit in my patch to check the new global too (via $this->getConfig()). The ApiFormatJson part is fine to do unconditionally since the replacement there makes no functional difference.
Comment 6 Gerrit Notification Bot 2014-11-19 20:14:06 UTC
Change 174289 merged by jenkins-bot:
Make calling wfMangleFlashPolicy configurable

https://gerrit.wikimedia.org/r/174289
Comment 7 Gerrit Notification Bot 2014-11-19 20:17:42 UTC
Change 174496 had a related patch set uploaded by Anomie:
API: Work around wfMangleFlashPolicy()

https://gerrit.wikimedia.org/r/174496
Comment 8 Brad Jorsch 2014-11-19 20:20:02 UTC
Comment on attachment 17162 [details]
Patch to work around wfMangleFlashPolicy, if we're not going to just get rid of it

Because Chris was involved, for some reason I thought this was a security bug so I didn't put the patch in Gerrit. D'oh.
Comment 9 Gerrit Notification Bot 2014-11-20 17:13:47 UTC
Change 174496 merged by jenkins-bot:
API: Work around wfMangleFlashPolicy()

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

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links