Last modified: 2012-09-18 17:25:01 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 T41180, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 39180 - Edit tokens shown in frames using api
Edit tokens shown in frames using api
Status: RESOLVED FIXED
Product: MediaWiki
Classification: Unclassified
API (Other open bugs)
1.19.1
All All
: Low normal (vote)
: 1.19.x release
Assigned To: Nobody - You can work on this!
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2012-08-08 22:31 UTC by Chris Steipp
Modified: 2012-09-18 17:25 UTC (History)
8 users (show)

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


Attachments
Add x-frame-options: DENY to api pages (421 bytes, patch)
2012-08-14 00:03 UTC, Chris Steipp
Details

Description Chris Steipp 2012-08-08 22:31:53 UTC
Using some ui redressing like [1], our edit token can be stolen when it's shown on api result pages. 

It would be good to respect $wgEditPageFrameOptions on api result pages that show an edit token, if possible.

[1] - http://blog.kotowicz.net/2011/07/cross-domain-content-extraction-with.html
Comment 1 Roan Kattouw 2012-08-09 18:29:06 UTC
(In reply to comment #0)
> Using some ui redressing like [1], our edit token can be stolen when it's shown
> on api result pages. 
> 
> It would be good to respect $wgEditPageFrameOptions on api result pages that
> show an edit token, if possible.
> 
Why wouldn't we just go all the way and set X-Frame-Options: disallow (or whatever the most restrictive setting is) on all API responses? I don't think there's ever a good reason to load API responses in iframes unless you're trying to creatively circumvent same origin restrictions.
Comment 2 Chris Steipp 2012-08-10 00:52:12 UTC
Even better. I'll do that.
Comment 3 Chris Steipp 2012-08-14 00:03:30 UTC
Created attachment 10961 [details]
Add x-frame-options: DENY to api pages

Simple patch to deny framing api responses. This will not prevent using the api within an iframe (tested in firefox/chrome) only iframing a direct api result.

Is this a big enough change that we would want a $wgBreakFramesApi, that defaults to true?
Comment 4 Chris Steipp 2012-08-17 19:28:58 UTC
Patch added in gerrit. I decided to use a $wg variable so it can be disabled (in case there's someone using the api in an iframe), but it's enabled by default.

https://gerrit.wikimedia.org/r/#/c/20472/
Comment 5 Bawolff (Brian Wolff) 2012-08-31 16:19:29 UTC
(In reply to comment #4)
> Patch added in gerrit. I decided to use a $wg variable so it can be disabled
> (in case there's someone using the api in an iframe), but it's enabled by
> default.
> 
> https://gerrit.wikimedia.org/r/#/c/20472/

For the record, I was using the api output in an iframe.... (As part of a js thing to allow people to double click on a word, and get the wiktionary definition using the xslt parameter of the API)
Comment 6 Bawolff (Brian Wolff) 2012-08-31 18:04:25 UTC
> 
> For the record, I was using the api output in an iframe.... (As part of a js
> thing to allow people to double click on a word, and get the wiktionary
> definition using the xslt parameter of the API)

Specifically I was embedding things like https://en.wiktionary.org/w/api.php?action=parse&redirects&prop=text&format=xml&xslt=MediaWiki:extractFirst.xsl&page=double-click&lang=en&count=1&showWord=bold in iframes when people double clicked words. (OTOH I stopped maintaining said thingy several years ago on account of it being such a kludge, so I'm not even sure if anyone uses that)

Could we perhaps make the x-frame-options: deny, only go on things that would be prevented from doing format=json&callback=foo - after all, anything that could be gleaned from this attack could be much more easily done if one is allowed to do json-with-callback.
Comment 7 Fut.Perf. 2012-09-18 16:08:21 UTC
This has also broken the file upload script used at en-WP (https://en.wikipedia.org/wiki/Wikipedia:File_Upload_Wizard). Correct me if I'm wrong, but it was my impression that directing API output to an IFrame was pretty much a standard strategy in scripting file uploads. How else is one supposed to do it?
Comment 8 Chris Steipp 2012-09-18 17:14:41 UTC
Fut.Perf, is this the same issue issue as Bug 39877?
Comment 9 Fut.Perf. 2012-09-18 17:25:01 UTC
@Chris Steipp: yes, looks like it (i.e. it seems to be the same technical problem, though we're talking about two different upload scripts – the en-wp wizard is not the same thing as the Commons wizard.) Thanks for pointing this out.

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


Navigation
Links