Last modified: 2014-02-07 20:03:03 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 T62339, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 60339 - Reported RCE in djvu thumbnailing
Reported RCE in djvu thumbnailing
Status: RESOLVED FIXED
Product: MediaWiki
Classification: Unclassified
File management (Other open bugs)
unspecified
All All
: Immediate critical (vote)
: ---
Assigned To: Nobody - You can work on this!
:
Depends on:
Blocks: 60519
  Show dependency treegraph
 
Reported: 2014-01-22 14:26 UTC by Chris Steipp
Modified: 2014-02-07 20:03 UTC (History)
18 users (show)

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


Attachments
intval the page parameter (816 bytes, patch)
2014-01-22 14:35 UTC, Chris Steipp
Details
Escape shell arguments (1.32 KB, patch)
2014-01-22 18:22 UTC, Tim Starling
Details
Clean up related escaping issues (5.39 KB, patch)
2014-01-22 19:27 UTC, Tim Starling
Details
PDF Handler - wmf10 (1.47 KB, patch)
2014-01-27 21:09 UTC, Chris Steipp
Details
PDF Handler - wmf11 (1.50 KB, patch)
2014-01-27 21:10 UTC, Chris Steipp
Details
Core REL1_22 (7.19 KB, patch)
2014-01-28 00:14 UTC, Chris Steipp
Details
Core REL1_21 (7.22 KB, patch)
2014-01-28 03:13 UTC, Chris Steipp
Details
Core REL1_19 (6.66 KB, patch)
2014-01-28 03:19 UTC, Chris Steipp
Details

Description Chris Steipp 2014-01-22 14:26:00 UTC
Created attachment 14358 [details]
PoC from checkpoint

This was sent to security@mediawiki.org a few days ago, and I just got it last night. This morning I got the encrypted PoC from them. Obviously this is very serious.

Shell meta characters can be passed in the page parameter to the thumb.php.

This fix is trivial, I've just tested and confirmed it fixes the issue on my local dev. I'll upload a patch to the cluster and deploy it.


>>>

Chris,
The OTRS system wouldn't let me forward this to security@wikimedia.org since that used to be an OTRS address.

Ryan // User:Rjd0060

---- Forwarded message from Shahar Tal <shahartal@checkpoint.com> ---

From: Shahar Tal <shahartal@checkpoint.com>
To: "security@mediawiki.org" <security@mediawiki.org>
Cc: Netanel Rubin <netanelr@checkpoint.com>, Inbar Raz <inbarr@checkpoint.com>
Subject: Remote code execution via incorrectly sanitized parameter
Date: 2014-01-19 12:23:54

> Hi, my name is Shahar Tal, I lead a security research team with Check Point's
> Malware & Security Research group.
>
> I am writing this to inform you of a critical RCE vulnerability that was
> identified in core MediaWiki by Netanel Rubin - a researcher in my team.
>
> The vulnerability enables unrestricted command injection via an incorrectly
> sanitized parameter.
> We have verified this vulnerability exists with default installations as long as a
> certain (not uncommon) setting is enabled, as is on wikimedia.org (see attached
> screenshot for verification).
>
> Note that it is our policy to follow responsible disclosure etiquette, and while
> we do eventually intend to make the vulnerability details public - we strongly
> prefer it would be done in full coordination and only after a fix has been made
> available.
>
> We would like to submit the details privately to the responsible parties, as well
> as suggest a fix, please contact me for further coordination.
>
> Regards,
>
> Shahar TalAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
> Check Point Software Technologies | * +972-77-775-8352 | M +972-545-888887 | *
> shahartal@checkpoint.com<mailto:shahartal@checkpoint.com>
>
>
>
>
---- End forwarded message ---
Comment 1 Chris Steipp 2014-01-22 14:35:49 UTC
Created attachment 14359 [details]
intval the page parameter

Deployed onto the cluster, due to severity:

14:34 logmsgbot: csteipp synchronized php-1.23wmf10/includes/media 'bug60339'
14:33 logmsgbot: csteipp synchronized php-1.23wmf11/includes/media 'bug60339'
Comment 2 Chris Steipp 2014-01-22 14:48:07 UTC
Adding Shahar, the reporter.

Shahar, as I mentioned in email too, I'd like to confirm that we don't have similar issues elsewhere in our image handling, and then we'll release this as a security release in the next few business days.
Comment 3 Shahar Tal 2014-01-22 15:02:02 UTC
FYI, This has been assigned CVE-2014-1610.
Comment 4 Tim Starling 2014-01-22 18:22:51 UTC
Created attachment 14361 [details]
Escape shell arguments

Escape as well as validate, per usual coding style.
Comment 5 Tim Starling 2014-01-22 18:38:12 UTC
Confirmed the vulnerability and tested the fix.
Comment 6 Tim Starling 2014-01-22 19:06:19 UTC
I checked all wfShellExec()/wfShellExecWithStderr() calls in includes/media:

BitmapHandler::transformImageMagick() should probably escape variables derived from string literals, such as $quality, on the basis that they may come from user input in the future. array_map('wfEscapeShellArg', array_merge(...)) could be used for argument assembly instead of string concatenation.

BitmapHandler::transformCustom() lacks escaping of $params['physicalHeight'] and $params['physicalWidth'].

BitmapHandler::rotate() depends on the "%" operator converting a string to a number, which seems a bit dodgy.
Comment 7 Tim Starling 2014-01-22 19:27:49 UTC
Created attachment 14364 [details]
Clean up related escaping issues

Something like this untested patch.
Comment 9 Chris Steipp 2014-01-27 21:09:55 UTC
Created attachment 14383 [details]
PDF Handler - wmf10

PDF Handler was also vulnerable after the last set of patches. These have been deployed on the Cluster. In wmf11, there was a change to remove the 2>&1, so there are versions of this patch for both wmf10 and wmf11.
Comment 10 Chris Steipp 2014-01-27 21:10:18 UTC
Created attachment 14384 [details]
PDF Handler - wmf11
Comment 11 Chris Steipp 2014-01-27 22:05:00 UTC
I've done some testing on Tim's patches, and deployed them on the cluster. Adding Bawolff in case he sees anything odd in file uploads or thumbnailing.
Comment 12 Chris Steipp 2014-01-28 00:14:21 UTC
Created attachment 14389 [details]
Core REL1_22

Backport for 1_22
Comment 13 Chris Steipp 2014-01-28 02:34:50 UTC
Adding early access partners.

We are planning to release these patches as part of 1.22.2 tomorrow (Tuesday Jan 28th).
Comment 14 Chris Steipp 2014-01-28 03:13:34 UTC
Created attachment 14392 [details]
Core REL1_21
Comment 15 Chris Steipp 2014-01-28 03:19:30 UTC
Created attachment 14393 [details]
Core REL1_19
Comment 16 Gerrit Notification Bot 2014-01-28 21:38:17 UTC
Change 110069 had a related patch set uploaded by CSteipp:
SECURITY: Sanitize shell command args

https://gerrit.wikimedia.org/r/110069
Comment 17 Gerrit Notification Bot 2014-01-28 21:39:24 UTC
Change 110071 had a related patch set uploaded by CSteipp:
SECURITY: Sanitize shell command args

https://gerrit.wikimedia.org/r/110071
Comment 18 Gerrit Notification Bot 2014-01-28 21:40:18 UTC
Change 110074 had a related patch set uploaded by CSteipp:
Sanitize shell command args

https://gerrit.wikimedia.org/r/110074
Comment 19 Gerrit Notification Bot 2014-01-28 21:44:38 UTC
Change 110080 had a related patch set uploaded by CSteipp:
SECURITY: Escape all shell arguments

https://gerrit.wikimedia.org/r/110080
Comment 20 Gerrit Notification Bot 2014-01-28 21:45:32 UTC
Change 110081 had a related patch set uploaded by CSteipp:
SECURITY: Escape all shell arguments

https://gerrit.wikimedia.org/r/110081
Comment 21 Gerrit Notification Bot 2014-01-28 21:46:11 UTC
Change 110082 had a related patch set uploaded by CSteipp:
SECURITY: Escape all shell arguments

https://gerrit.wikimedia.org/r/110082
Comment 22 Gerrit Notification Bot 2014-01-28 21:53:23 UTC
Change 110080 merged by jenkins-bot:
SECURITY: Escape all shell arguments

https://gerrit.wikimedia.org/r/110080
Comment 23 Gerrit Notification Bot 2014-01-28 21:53:31 UTC
Change 110081 merged by jenkins-bot:
SECURITY: Escape all shell arguments

https://gerrit.wikimedia.org/r/110081
Comment 24 Gerrit Notification Bot 2014-01-28 21:54:21 UTC
Change 110082 merged by jenkins-bot:
SECURITY: Escape all shell arguments

https://gerrit.wikimedia.org/r/110082
Comment 25 Chris Steipp 2014-01-28 21:56:20 UTC
Clarification from the release announcement. Checkpoint did mention PdfHandler in their original PoC. Internal review found an additional vector not prevented by their proposed fix.
Comment 26 Gerrit Notification Bot 2014-01-28 22:02:45 UTC
Change 110071 merged by jenkins-bot:
SECURITY: Sanitize shell command args

https://gerrit.wikimedia.org/r/110071
Comment 27 Gerrit Notification Bot 2014-01-28 22:02:52 UTC
Change 110074 merged by jenkins-bot:
Sanitize shell command args

https://gerrit.wikimedia.org/r/110074
Comment 28 Gerrit Notification Bot 2014-01-28 22:14:18 UTC
Change 110069 merged by jenkins-bot:
SECURITY: Sanitize shell command args

https://gerrit.wikimedia.org/r/110069
Comment 29 Bartosz Dziewoński 2014-01-29 15:56:41 UTC
(Attachment 14358 [details] from comment 0 is still private, is that intended?)
Comment 30 Chris Steipp 2014-01-29 18:03:48 UTC
(In reply to comment #29)
> (Attachment 14358 [details] from comment 0 is still private, is that
> intended?)

It is. The attachment contains a working PoC for code execution on unpatched wikis, and I'd like to give our users some time to patch before making that part public. Additionally, Checkpoint dind't intend for that to be public, so it hasn't bean approved by their PR people and the researcher asked me to keep it private.

Once it seems like most wikis have patches, I'll at least make the exploit public, so we have a negative example that developers can see and prevent in the future.
Comment 31 Gerrit Notification Bot 2014-01-29 18:27:12 UTC
Change 110215 had a related patch set uploaded by CSteipp:
SECURITY: Sanitize shell command args

https://gerrit.wikimedia.org/r/110215
Comment 32 Gerrit Notification Bot 2014-01-29 18:31:40 UTC
Change 110215 merged by jenkins-bot:
SECURITY: Sanitize shell command args

https://gerrit.wikimedia.org/r/110215
Comment 33 Gerrit Notification Bot 2014-01-30 19:23:47 UTC
Change 110423 had a related patch set uploaded by CSteipp:
SECURITY: Escape all shell arguments

https://gerrit.wikimedia.org/r/110423
Comment 34 Gerrit Notification Bot 2014-01-30 19:24:30 UTC
Change 110423 merged by jenkins-bot:
SECURITY: Escape all shell arguments

https://gerrit.wikimedia.org/r/110423
Comment 35 Gerrit Notification Bot 2014-01-30 19:25:16 UTC
Change 110424 had a related patch set uploaded by Reedy:
SECURITY: Escape all shell arguments

https://gerrit.wikimedia.org/r/110424
Comment 36 Gerrit Notification Bot 2014-01-30 19:25:40 UTC
Change 110425 had a related patch set uploaded by Reedy:
SECURITY: Escape all shell arguments

https://gerrit.wikimedia.org/r/110425
Comment 37 Gerrit Notification Bot 2014-01-30 19:32:27 UTC
Change 110424 merged by jenkins-bot:
SECURITY: Escape all shell arguments

https://gerrit.wikimedia.org/r/110424
Comment 38 Gerrit Notification Bot 2014-01-30 19:32:32 UTC
Change 110425 merged by jenkins-bot:
SECURITY: Escape all shell arguments

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

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


Navigation
Links