Reedy [Sun, 2 Apr 2017 19:02:11 +0000 (2 20:02 +0100)]
Bump $wgVersion and finalise RELEASE-NOTES for 1.23.16
Change-Id: Id932eee0a5acb1ef9c61f5633d38b6d2074db593
Signed-off-by: Chad Horohoe <chadh@wikimedia.org>
Brian Wolff [Mon, 13 Jun 2016 07:07:48 +0000 (13 03:07 -0400)]
SECURITY: Do not allow users to undelete a page they can't edit or create
If the page exists, it only checks edit rights, otherwise it
checks both edit and create rights.
This would only matter on wikis that have a non-default rights
configuration where there are users with undelete rights but a
restriction level enabled that prevents them from creating/editing
pages (or they otherwise aren't allowed to edit/create)
It should be noted that the error messages aren't used in the
normal UI currently, but they could be in the future, and
extensions could potentially be using them (The backend functions
return them, but the UI functions in Special:Undelete ignore
them)
Bug: T108138
Change-Id: I164b80534cf89e0afca264e9de07431484af8508
Signed-off-by: Chad Horohoe <chadh@wikimedia.org>
Brian Wolff [Fri, 11 Mar 2016 01:08:06 +0000 (10 20:08 -0500)]
SECURITY: Always normalize link url before adding to ParserOutput
Move link normalization directly into addExternalLink() method,
since you always need to do it - having it separate is just
inviting people to forget to normalize a link.
Additionally, links weren't properly registered for <gallery>.
This was somewhat unnoticed, as the call to recursiveTagParse()
would register free links, but it wouldn't work for example with
protocol relative links.
Issue originally reported by MZMcBride.
Bug: T48143
Change-Id: I557fb3b433ef9d618097b6ba4eacc6bada250ca2
Signed-off-by: Chad Horohoe <chadh@wikimedia.org>
Brian Wolff [Mon, 28 Nov 2016 23:34:24 +0000 (28 23:34 +0000)]
SECURITY: Whitelist DTD declaration in SVG
Only allow ENTITY declarations inside the doctype internal
subset. Do not allow parameter entities, recursive entity
references are entity values longer than 255 bytes, or
external entity references. Filter external doctype subset
to only allow the standard svg doctypes.
This prevents someone bypassing filter by using default
attribute values in internal dtd subset. No browser loads
the external dtd subset that I could find, but whitelist
just to be safe anyways.
Issue reported by Cassiogomes11.
Bug: T151735
Change-Id: I7cb4690f759ad97e70e06e560978b6207d84c446
Signed-off-by: Chad Horohoe <chadh@wikimedia.org>
Brian Wolff [Mon, 13 Mar 2017 21:20:02 +0000 (13 21:20 +0000)]
SECURITY: Escape wikitext content model/format in message
Escape wikitext in model= and format= url parameter to
edit page. This goes along with
1c788944 to help prevent
XSS for wikis with $wgRawHtml = true; set.
Bug: T156184
Change-Id: Ifcaa2ccf05a2a691d0b150e2f7e0e765db25fc7f
Signed-off-by: Chad Horohoe <chadh@wikimedia.org>
Bartosz Dziewoński [Mon, 7 Nov 2016 19:10:21 +0000 (7 20:10 +0100)]
SECURITY: SpecialWatchlist: Check CSRF token when using "Mark all pages visited"
Bug: T150044
Change-Id: I7f75cab4ceb4a2c320af210fad15956b70c29661
Signed-off-by: Chad Horohoe <chadh@wikimedia.org>
Brad Jorsch [Thu, 18 Aug 2016 17:37:05 +0000 (18 13:37 -0400)]
SECURITY: API: Don't log "sensitive" parameters
Stuff like passwords and CSRF tokens shouldn't be in the logs.
The fact of being sensitive is intentionally separated from the need to
be in the POST body because, for example, the wltoken parameter to
ApiQueryWatchlist needs to be in the query string to serve its purpose
but still shouldn't be logged.
Bug: T125177
Change-Id: I1d61f4dcf792d77401ee2e2988b1afcb2a2ad58f
Signed-off-by: Chad Horohoe <chadh@wikimedia.org>
Brian Wolff [Mon, 26 Sep 2016 10:40:30 +0000 (26 10:40 +0000)]
SECURITY: XSS in search if $wgAdvancedSearchHighlighting = true;
In the non-default configuration where $wgAdvancedSearchHighlighting
is set to true, there is an XSS vulnerability as HTML tags are
not properly escaped if the tag spans multiple search results
Issue introduced in
abf726ea0 (MediaWiki 1.13 and above).
Bug: T144845
Change-Id: I2db7888d591b97f1a01bfd3b7567ce6f169874d3
Signed-off-by: Chad Horohoe <chadh@wikimedia.org>
Reedy [Sun, 19 Mar 2017 21:26:26 +0000 (19 21:26 +0000)]
SECURITY: Do not directly redirect to interwikis, but use splash page
Directly redirecting based on a url paramter might potentially
be used in a phishing attack to confuse users.
Bug: T109140
Bug: T122209
Change-Id: I6c604439320fa876719933cc7f3a3ff04fb1a6ad
Signed-off-by: Chad Horohoe <chadh@wikimedia.org>
Reedy [Wed, 5 Apr 2017 20:46:50 +0000 (5 20:46 +0000)]
Merge "API: Insist authn parameters be in the POST body" into REL1_23
Brian Wolff [Wed, 5 Apr 2017 19:10:04 +0000 (5 19:10 +0000)]
Fix phpunit test added in
57efcafa8a3a64f
ObjectFactory wasn't added until 1.25
Change-Id: I865d40029608534a8eceffa66fb10ad17aa865ac
Brad Jorsch [Thu, 18 Aug 2016 17:36:11 +0000 (18 13:36 -0400)]
API: Insist authn parameters be in the POST body
Passwords should always be submitted in the POST body, not in the query
string. Thus, a warning will now be returned if the password for
action=login.
Change-Id: Ifb2c684bb28c9acc004be2b0c2fef839eb7624aa
Brian Wolff [Mon, 6 Feb 2017 03:00:39 +0000 (6 03:00 +0000)]
SECURITY: Disable <html> tag on system messages despite $wgRawHtml = true;
System messages may take parameters from untrusted sources. This
may include taking parameters from urls given by unauthenticated
users even if the wiki is a read-only wiki. Allowing <html> tags
in such a context seems like an accident waiting to happen.
Bug: T156184
Change-Id: I661f482986d319cf41da1d3e7b20a0f028a42e90
csteipp [Wed, 11 Jun 2014 23:29:33 +0000 (11 16:29 -0700)]
Disallow css attr() with url type
CSS3 seems like it will extend the attr() function which can interpret
attribute as different types, including 'url', which "...is interpreted
as a quoted string within the ‘url()’ notation."
Currently no browsers support this syntax yet, so submitting this
as a normal non-security patch.
Bug: T68404
Change-Id: Icdae989764754c985a9292d62efae7cc47009df5
Paladox [Sun, 11 Sep 2016 17:43:04 +0000 (11 17:43 +0000)]
Add missing global $wgUseXVO to RawAction.php
Bug: T136129
Change-Id: Id89bb33b05743322882cabc7a7f021bc689cb9bf
jenkins-bot [Thu, 1 Sep 2016 22:50:54 +0000 (1 22:50 +0000)]
Merge "Followup
af6d9aba: $search is a string, not an object" into REL1_23
Chad Horohoe [Mon, 22 Aug 2016 19:17:02 +0000 (22 12:17 -0700)]
1.23.15: Release notes and bump version number
Change-Id: I1135455897919db0894d859692679e072a6b1aa4
Brad Jorsch [Thu, 7 Jul 2016 13:40:57 +0000 (7 09:40 -0400)]
SECURITY: API: Generate head items in the context of the given title
$context->getOutput() returns an OutputPage tied to the main
RequestContext at the root of the chain, not to the modified context
we're actually using.
Bug: T139565
Change-Id: Ie086d7f2ad3f7b5f50e3a2f83b1680e760b85e5e
Brian Wolff [Wed, 8 Jun 2016 02:35:15 +0000 (7 22:35 -0400)]
SECURITY: XSS in unclosed internal links
rawurldecode was being run on unclosed internal links
which could allow an attacker to insert arbitrary
html into the page.
See also related: r13302
Bug: T137264
Change-Id: I4e112a9e918df9fe78b62c311939239b483a21f5
Brian Wolff [Wed, 20 Apr 2016 17:41:20 +0000 (20 13:41 -0400)]
SECURITY: Escape '<' and ']]>' in inline <style> blocks
This is to prevent people from closing the <style> tag, and
then doing arbitrary js-y things. In particular, this is needed
for when previewing user css pages.
This does not escape '>' since its used as the child selector
in css, and generally speaking, '>' is safe inside the contents
of elements.
Bug: T133147
Change-Id: If024398d7bd4b578ad7f8c74367787f5b19eb9d7
Brian Wolff [Wed, 20 Apr 2016 17:56:18 +0000 (20 13:56 -0400)]
SECURITY: Require login to preview user CSS pages
Anon users have predictable edit tokens, hence someone could
force an anon to execute arbitrary CSS by means of a CSRF.
Bug: T133147
Change-Id: I442b2b46cadb967aaa1f35648eff183fc7eaa475
Brian Wolff [Mon, 18 Apr 2016 16:45:56 +0000 (18 12:45 -0400)]
SECURITY: Do not allow undeleting a revdel'd file if its top file
This prevents admins being able to view suppressed files, by simply
deleting them, and then undeleting only the file revision that they
want to view.
This dates back to r43288. Unclear if it was intentional.
Bug: T132926
Change-Id: Ib767de853a37099305db20529378fa756ee1bdfe
Brian Wolff [Wed, 29 Jun 2016 14:45:25 +0000 (29 10:45 -0400)]
SECURITY: Make $wgBlockDisablesLogin also restrict logged in permissions
Does both Title and user related methods, so it catches things that only
call $wgUser->isAllowed( 'read' ), as well as giving a nicer error message
for things that use $title->userCan().
Otherwise, the user can still do stuff and read pages if they have an
ongoing session.
Issue reported by Multichill
Bug: T129738
Change-Id: Ic929a385fa81c27cbc6ac3a0862f51190d3ae993
Brian Wolff [Tue, 19 Apr 2016 14:25:43 +0000 (19 10:25 -0400)]
SECURITY: Make blocks log users out if $wgBlockDisablesLogin
Issue originally reported by Multichill
Bug: T129738
Change-Id: Iddc58e504297c60f6d3ca99f21034fe7c5cf9801
Daniel Kinzler [Mon, 13 Jun 2016 08:01:43 +0000 (13 04:01 -0400)]
SECURITY: Check read permission when loading page content in ApiParse.
Prevents leaking page contents for extensions that deny read rights
to certain pages via a userCan hook, but still allow the user to
have read rights in general.
Issue originally reported by Tobias
Bug: T115333
Change-Id: I19f5c2583393794cff802a70af7ccf43c2fed85c
Chad Horohoe [Tue, 15 Apr 2014 18:50:10 +0000 (15 11:50 -0700)]
Followup
af6d9aba: $search is a string, not an object
Reusing variables means you end up turning a string to an object
and then confuse yourself by trying to pass it as a string again.
Change-Id: I82b5ca65864099c180d915055c43e6839bd4f4a2
(cherry picked from commit
1078340188890738f9abd73f95291d3348e2f71a)
Brian Wolff [Wed, 20 Apr 2016 17:22:51 +0000 (20 13:22 -0400)]
Remove support for $wgWellFormedXml=false
tl;dr: Having unnessary complexity in security critical code is bad.
* When PHP is built with certain versions of libpcre, can lead to XSS
* Extra options add extra complexity and maintenance burden
** Thus we should only have one html output mode. well formed = false
was already vetoed in T52040, so lets go with WellFormed=true.
* Options which are used by very few people tend to get tested less
* Escaping is an area of code where we should be very conservative
* Having escaping rules depend on making assumptions about which
characters various browsers consider "whitespace" is scary
* $wgWellFormedXml=false has had a negative security impact in the
past (Usually not directly its fault, but has made other bugs
more exploitable)
* Saving a couple bytes (even less bytes after gzip taken into
account) is really not worth it in this context (imho).
Incidentally, this backports the removal of the space before the
closing '/>' of a self-closed tag from
dd2d7d0ffc.
Bug: T57548
Change-Id: I5c922e0980d3f9eb39adb5bb5833e158afda42ed
jenkins-bot [Thu, 11 Aug 2016 00:04:11 +0000 (11 00:04 +0000)]
Merge "Use ipb_id when updating expiry in Block::updateTimestamp()" into REL1_23
Kunal Mehta [Thu, 3 Mar 2016 02:48:08 +0000 (2 18:48 -0800)]
Use ipb_id when updating expiry in Block::updateTimestamp()
If Block::purgeExpired() hasn't been called due to low traffic, already
expired blocks might have their timestamps extended.
Bug: T128695
Change-Id: I21e7dca57bda77a755b54d0e09f340c3f0e75bd6
Paladox [Sat, 24 Oct 2015 11:25:15 +0000 (24 12:25 +0100)]
Set the default database schema to "mediawiki" so as not to break the CLI installer.
Due to changes made to support Microsoft SQL Server, $wgDBmwschema changed its default from
"mediawiki" to null in DefaultSettings.php, as anything else horribly broke every DBMS that did
not use schemas (such as MySQL and SQLite). This change makes it so that the default value can
be properly overridden again by PostgreSQL and Microsoft SQL Server, and also enables the
--dbschema flag to the CLI installer.
Backported to MediaWiki 1.23 from patch Id364306d883e0d494b948854e05f3f79ba7dd6d2
Author of original patch Skizzerz
Also backport I8217b25e903e40ec82be3d700381ff7aea3b481f
Author of that is umherirrender
Bug: T66043
Change-Id: I842dd8e00637cc818b4e29d5bdc2930d8c7ee223
Chad Horohoe [Tue, 19 Jul 2016 18:39:41 +0000 (19 11:39 -0700)]
Remove support for getenv('http_proxy') in MediaWiki
PHP (and other programming languages) are vulnerable to an exploit
when making external requests via a proxy when a client provides a
Proxy header. See https://httpoxy.org/ for more information.
MediaWiki now requires $wgHTTPProxy to be set when attempting to
use a proxy for requests and can no longer rely on http_proxy
environment variables. As it exists, this code is inherently unsafe
on case-insensitive platforms (eg: Windows) and hard to be sure of
for other platforms.
All users using a proxy for MediaWiki and *not* setting $wgHTTPProxy
are advised to do so immediately to mitigate this problem. This will
be required as of the next security release.
All extensions maintained in Git/Gerrit appear to be Doing The Right
Thing and not trying to use getenv('http_proxy') directly. This would
be a bad thing to start doing. Call Http::getProxy() if you need to
manually get a proxy from MW for external requests.
Bug: T140658
Change-Id: I5b782003098a1ddd4f4801bb606d6218741f4972
Brian Wolff [Thu, 30 Jun 2016 22:02:54 +0000 (30 18:02 -0400)]
Fix parser tests. <nowiki> no longer escapes quotes.
Follow-up 35540a
Change-Id: Ib2f41b56e2a90e9f84a874d5e35ecaea7e5b44bb
Max Semenik [Fri, 20 May 2016 19:41:33 +0000 (20 12:41 -0700)]
I iz ugh
Change-Id: I6c2861695e913b2a016ebad7dd89a6474a10dd2d
(cherry picked from commit
fa11b598b4e396f606c2ffe8a4929c24e0f8cf46)
Max Semenik [Fri, 20 May 2016 18:39:37 +0000 (20 11:39 -0700)]
Fix fatal with PHP 5.3
Change-Id: Ia9bd01afefab96eda635744ce72bd4243231264b
(cherry picked from commit
ab868409e57db548a1d46bafa13c5cc496797f9e)
Chad Horohoe [Fri, 20 May 2016 17:15:35 +0000 (20 10:15 -0700)]
Bump to 1.23.14 for tagging
Change-Id: I0e1780d4652da987382ff079beb2eaeeceb98e76
Brian Wolff [Mon, 25 Apr 2016 18:08:46 +0000 (25 14:08 -0400)]
Add rel="noreferrer noopener" when target attribute would open window
noreferrer is used as support for noopener is very limited.
This is to prevent the attack detailed at
https://mathiasbynens.github.io/rel-noopener/ where you can
navigate the parent window, even if the new window is a cross-origin.
Bug: T133507
Change-Id: I6e4ab938861e246ff44048077b94847e303f1859
Signed-off-by: Chad Horohoe <chadh@wikimedia.org>
Brad Jorsch [Sun, 17 Apr 2016 14:32:56 +0000 (17 10:32 -0400)]
SECURITY: Rate limit moves via the API
While rate limiting has been applied to moves via the web UI since rate
limiting was first added, it appears that it was overlooked when ApiMove
was created.
This follows the same model as is followed by the web UI: each
submission to ApiMove is one "hit" for the rate limiter, even though
that submission might result in multiple pages being moved (e.g. the
page, its talk page, and its subpages) depending on the options and user
rights.
Bug: T132874
Change-Id: I564d8bfcc7dd3ad6d92dbbc33519a589697c0d4e
Signed-off-by: Chad Horohoe <chadh@wikimedia.org>
Max Semenik [Fri, 4 Mar 2016 22:41:50 +0000 (4 14:41 -0800)]
SECURITY: Wrap diff generation in PoolCounter
Bug: T130947
Signed-off-by: Chad Horohoe <chadh@wikimedia.org>
Darian Anthony Patrick [Mon, 25 Apr 2016 19:02:02 +0000 (25 12:02 -0700)]
Enforce upper limit on invocations of wfShellExec()
Enforce an upper limit of 100,000 bytes on commands executed via
wfShellExec() to avoid HHVM crash resulting from process spawned with
argument exceeding MAX_ARG_STRLEN, as defined in binfmts.h
Bug: T129506
Signed-off-by: Chad Horohoe <chadh@wikimedia.org>
Brian Wolff [Mon, 9 May 2016 07:51:01 +0000 (9 03:51 -0400)]
Canonicalize usernames before rate limiting logins
Bug: T127114
Change-Id: I020cecf345c6bad4f461b70203f0bd29792de1f8
Signed-off-by: Chad Horohoe <chadh@wikimedia.org>
Chad Horohoe [Tue, 26 Apr 2016 18:24:56 +0000 (26 11:24 -0700)]
Use global cache keys login/create account rate limitting
If you are running multiple wikis, you probably want the rate limit
on one wiki to apply to all wikis
Bug: T126685
Change-Id: Id662742c7af1b26811f5b0aa199176cb9a7658d9
Signed-off-by: Chad Horohoe <chadh@wikimedia.org>
Brad Jorsch [Sun, 31 Jan 2016 20:43:00 +0000 (31 15:43 -0500)]
SECURITY: RawAction: Vary on the usual headers
This avoids edge cases where the user isn't logged in but we still need
varying for proper cache behavior.
Bug: T125283
Change-Id: I43cde3a48371e62a16bda1291b1b51986e60fe4c
Signed-off-by: Chad Horohoe <chadh@wikimedia.org>
Brad Jorsch [Mon, 18 Jan 2016 17:00:41 +0000 (18 12:00 -0500)]
SECURITY: Improve cross-domain-policy mangling
Take into account that the tag might have parameters.
Bug: T123653
Change-Id: Ie9799f5ea45badfb4e7b4be7e7fbc1c35cc86f26
Signed-off-by: Chad Horohoe <chadh@wikimedia.org>
csteipp [Thu, 7 Jan 2016 16:13:16 +0000 (7 08:13 -0800)]
SECURITY: Don't use m modifier when checking link prefix
SVG filter incorrectly used the m modifier when checking if an href
attribute started with 'https?://', incorrectly matching attributes
such as, "javascript:alert(' http://foo')".
Bug: T122653
Change-Id: I41291fff344241cad3171f3e8050de99b62a2296
Signed-off-by: Chad Horohoe <chadh@wikimedia.org>
Brad Jorsch [Mon, 25 Apr 2016 15:21:07 +0000 (25 08:21 -0700)]
SECURITY: Check for mbstring.func_overload at runtime
The installer already checks for this, let's also catch the case when
someone enables this after installation.
Bug: T122807
Change-Id: Ieddbc932f482d52da1688d472f494074c81124b2
Signed-off-by: Chad Horohoe <chadh@wikimedia.org>
Brian Wolff [Wed, 30 Dec 2015 01:55:23 +0000 (29 20:55 -0500)]
Reset wsEditToken on login
Bug: T122056
Change-Id: I03739e942b6c182ed9cbcd0d9615dcd799e8baed
Signed-off-by: Chad Horohoe <chadh@wikimedia.org>
csteipp [Mon, 25 Apr 2016 22:25:18 +0000 (25 15:25 -0700)]
SECURITY: Include quote characters in strip markers so esc in attr
Strip markers get substituted for general html, which means the
substitution text general does not escape quote characters. If
someone can convince MW to put a strip marker in an attribute,
you can get around escaping requirements that way. This patch
adds the characters `"' to the strip marker text. At least one
of these characters should be escaped inside attributes (regardless
of what quote character you use for attributes), thus normal html
escaping will deactivate the strip markers, preventing the
vulnrability.
This will break any extension that escapes input with htmlspecialchars,
to add to html/half parsed html output, but assumes that strip markers
are unmangled. I don't think its very common to do this. The primary
example I found was some core usages of Xml::escapeTagsOnly(). (And
even in that case, it only affected the corner case of being called
via {{#tag:..}})
Bug: T110143
Change-Id: If887065e12026530f36e5f35dd7ab0831d313561
Signed-off-by: Chad Horohoe <chadh@wikimedia.org>
Brian Wolff [Tue, 27 Oct 2015 08:31:00 +0000 (27 02:31 -0600)]
SECURITY: Add class to <a> for patrol links so it can't be spoofed by user
Javascript used to look just for the patrollinks class, which
could be set by the user in order to patrol an arbitrary page.
Requiring the class on the <a> tag prevents the user from setting
it.
Bug: T103239
Change-Id: I13fcc3ce479c0a4a90a6217c2e5244f051eaf862
Signed-off-by: Chad Horohoe <chadh@wikimedia.org>
Brad Jorsch [Fri, 8 May 2015 14:20:30 +0000 (8 10:20 -0400)]
SECURITY: API: Add "standard" header and hook for lacksSameOriginSecurity()
The header is intended for use with XMLHttpRequest when the request
might be part of an XSS. The hook is for extensions that might need to
add additional checks of some sort.
Bug: T98313
Change-Id: I0e5f2d3b29a79a12461dc33c90c812a56810f536
Signed-off-by: Chad Horohoe <chadh@wikimedia.org>
jenkins-bot [Fri, 4 Mar 2016 01:02:24 +0000 (4 01:02 +0000)]
Merge "build: Bump various devDependencies" into REL1_23
James D. Forrester [Fri, 1 May 2015 22:37:14 +0000 (1 15:37 -0700)]
build: Bump various devDependencies
karma-chrome-launcher: 0.1.7 -> 0.1.8
Change-Id: Ieeb6dbcd3e6d9f6f0fb9865d356da462b9b0499b
Kunal Mehta [Thu, 3 Mar 2016 17:32:52 +0000 (3 09:32 -0800)]
sajax: Explicitly specify released under 3-clause BSD license
Bug: T128348
Change-Id: I39f1c1f2319088005099b0ce5f30d1dfb3c27776
Reedy [Sun, 20 Dec 2015 22:06:48 +0000 (20 22:06 +0000)]
Prep 1.23.13
Change-Id: I5080cf9fa699c59ee5d2bb2ae9bbbb09fa262e41
Reedy [Sun, 20 Dec 2015 21:42:20 +0000 (20 21:42 +0000)]
Fix Fatal on various special pages introduced in 1.23.12
Bug: T121892
Change-Id: Ie3d23af7a372fa6a5a23cd861a4d34e42fb08195
Chad Horohoe [Thu, 17 Dec 2015 23:00:41 +0000 (17 15:00 -0800)]
1.23.12: Prep release notes and bump version number
Change-Id: Ide4863e1b864db818f0469ee4367e87318b48b87
Bartosz Dziewoński [Thu, 19 Nov 2015 22:13:13 +0000 (19 17:13 -0500)]
Add $query to JavaScript redirect info
Bug: T109724
Signed-off-by: Chad Horohoe <chadh@wikimedia.org>
Change-Id: I57a8f75067365d3da6388d2f8f7fe95ed5e6f310
csteipp [Mon, 5 Oct 2015 23:58:42 +0000 (5 16:58 -0700)]
SECURITY: Make Special:MyPage and friends fake redirect to prevent info leak
This prevents a malicious person from using external resources on their
website to cause the victim's web browser to load
Special:MyPage -> User:Username, and then looking it up in the page hit
statistics in order to correlate IPs from the malicious person's server
log, with usernames on wiki.
This feature can be disabled with $wgHideIdentifiableRedirects.
Bug: T109724
Signed-off-by: Chad Horohoe <chadh@wikimedia.org>
Change-Id: Ia0e742dc92c77af4832174dfa24c6dcaa6ee80e9
Aaron Schulz [Mon, 24 Aug 2015 20:00:23 +0000 (24 13:00 -0700)]
Fixed some doc errors in tryNormaliseRedirect()
Change-Id: I8f9397d05de1c0bae33497d1f9e3146939599380
Timo Tijhof [Fri, 19 Jun 2015 19:56:36 +0000 (19 20:56 +0100)]
MediaWiki.php: Factor out tryNormaliseRedirect
This is in preparation for fixing T67402, which requires adding
logic inside this condition block. However the to-be-added code
will influences whether or not a redirect should be made.
In case a redirect is not made, it has to fall through to the next
'elseif' handler in MediaWiki::performRequest(), which is not possible
from inside the 'if' block.
Hence, move it out in a separate block and use a boolean return value
to communicate whether the case has been handled.
This also allows us to unit test this thing. Which is desperately
needed. Albeit ugly as it requires lots of mocking.
Change-Id: If3157f2ff1fd3ab2ca20a5d1f550d864ea62c493
Bartosz Dziewoński [Wed, 11 Nov 2015 22:00:31 +0000 (11 23:00 +0100)]
Really validate that $wgArticlePath starts with a slash
The regular expression wasn't entirely correct.
Follow-up to
a4a3d0454069c25a24e2bfe732a665cc6a865878.
Bug: T48998
Change-Id: I08bdf2db20c1c3de55527fc812bcbb55fa23f7bc
JuneHyeon Bae [Sat, 24 May 2014 10:48:02 +0000 (24 19:48 +0900)]
Validates wgArticlePath does start with slash (/).
When relative URL used in $wgArticlePath, and $wgArticlePath does not
start with slash (/), raise FatalError.
Bug: T48998
Change-Id: Ic7cd6f774cff97081f4f35af351161170b4b26eb
Chad Horohoe [Tue, 15 Dec 2015 19:37:21 +0000 (15 11:37 -0800)]
Fix IP::toHex for IPv4 addresses with a double/triple 0 block
Bug: T97897
Signed-off-by: Chad Horohoe <chadh@wikimedia.org>
Change-Id: I5c0a37be42ae2c5091ead487a6d19f6e0dd89b36
Brad Jorsch [Wed, 14 Oct 2015 21:53:09 +0000 (14 17:53 -0400)]
[SECURITY] 0-pad to length in random string generation
Otherwise shorter strings might be generated.
Bug: T115522
Signed-off-by: Chad Horohoe <chadh@wikimedia.org>
Change-Id: I3569218ea840e9de7a3fe458acf474e3dac6d1ab
Roan Kattouw [Fri, 6 Nov 2015 20:55:16 +0000 (6 12:55 -0800)]
SECURITY: Work around CURL insanity breaking POST parameters that start with '@'
CURL has a "feature" where passing array( 'foo' => '@bar' )
in CURLOPT_POSTFIELDS results in the contents of the file named "bar"
being POSTed. This makes it impossible to POST the literal string "@bar",
because array( 'foo' => '%40bar' ) gets double-encoded to foo=%2540bar.
Disable this "feature" by setting CURLOPT_SAFE_UPLOAD to true,
if available. According to the PHP manual, this option became
available in 5.5 and started defaulting to true in 5.6.
However, we support versions as low as 5.3, and this option
doesn't exist at all in 5.6.99-hhvm, which we run in production.
For versions where this option is not available (pre-5.5 versions
and HHVM), serialize POSTFIELDS arrays to strings. This works
around the issue because the '@' "feature" only works
for arrays, not strings, as of PHP 5.2. (We don't support pre-5.2
versions, and I've verified 5.6.99-hhvm behaves this way as well.)
Bug: T118032
Signed-off-by: Chad Horohoe <chadh@wikimedia.org>
Change-Id: I3f996e2eb87c7bd3b94ca9d3cc14a3e12f34f241
Gergő Tisza [Sat, 21 Nov 2015 19:51:02 +0000 (21 11:51 -0800)]
Use hash_equals in User::matchEditToken
There is no point in using hash_equals for the return value if we
do a normal comparison before.
Bug: T119309
Signed-off-by: Chad Horohoe <chadh@wikimedia.org>
Change-Id: Ia44ec5ed492105b27d0fddd845d58d27a29dc072
Ori Livneh [Fri, 4 Dec 2015 19:59:52 +0000 (4 11:59 -0800)]
Don't install a custom error handler for hooks
Installing a custom error handler on every hook invocation has a high overhead,
and does not even correctly achieves what it sets out to achieve, which is to
flag hook function signature errors (and only hook function signature errors).
The "PHP way" is to simply increase the error reporting level for development
environments, which we do already.
Bug: T117553
Change-Id: Iba0138a6d0a0ddf839bc5a36e03cadb012e06f3c
Antoine Musso [Thu, 26 Nov 2015 20:25:03 +0000 (26 21:25 +0100)]
tests: let us select/exclude ParserTests
The MediaWiki test suite is painfully slow and delays merging of
changes. More than half of the time is spent in
ParserTest_Parser⁄parserTests::testParserTest which is the PHPUnit
wrapping class for the parser tests.
This patch let us extract the parser tests so we can run them
independently. By running them parallely with the rest of the tests,
that will speed up the gate processing time.
Mark the MediaWikiParserTest and NewParserTest class as belonging to the
test group 'ParserTests'. Will let us filter them out via PHPUnit
option --exclude-group
Introduce a new PHPUnit test suite 'parsertests' which loads the
MediaWiki core parser tests wrapper 'MediaWikiParserTest' and the suite
which loads the extensions parser tests (ExtensionsParserTestSuite.php).
This way we can run solely the parser tests with:
cd tests/phpunit
php phpunit.php --testsuite ParserTests
Wikimedia CI can then be configure to run two jobs:
A) php phpunit.php --exclude-group ParserTests
B) php phpunit.php --testsuite ParserTests
Bug: T114314
Change-Id: Ie819bab43163995048c073691c4c5d258f797c02
(cherry picked from commit
50c5a9d27d9f254ef95247ce2784de83970532a4)
Chad Horohoe [Fri, 16 Oct 2015 16:21:06 +0000 (16 09:21 -0700)]
Bump version number and add release notes for security release 1.23.11
Change-Id: I0a4a4ee4d887d00a24311efae20c109013c3227a
Darian Anthony Patrick [Wed, 12 Aug 2015 19:47:36 +0000 (12 12:47 -0700)]
Avoid exposure of local path in PNG thumbnails
Bug: T108616
Change-Id: I952068d2d175d71f86dec0dbb92af5a122c05a49
Chad Horohoe [Thu, 15 Oct 2015 20:47:16 +0000 (15 13:47 -0700)]
SECURITY: API: Improve validation in chunked uploading
This fixes a few shortcomings in the chunked uploader:
* Raises an error if offset + chunksize > filesize.
* Enforces a minimum chunk size for non-final chunks.
* Refuses additional chunks after seeing a final chunk.
* Status of a chunked upload in progress is now available with
'checkstatus'.
Bug: T91203
Bug: T91205
Change-Id: I2262db1bc8460616b069c564475d2e4148001768
Chad Horohoe [Thu, 15 Oct 2015 19:48:47 +0000 (15 12:48 -0700)]
SECURITY: Throttle uploads
Add throttle check in ApiUpload and SpecialUpload.
Bug: T91850
Change-Id: If33cc99f304aab2486507c7500b4abb06b6b5d70
Jeff Janes [Wed, 18 Feb 2015 03:56:20 +0000 (17 19:56 -0800)]
PostgreSQL: Fix text search on moved pages
When a page is updated under PostgreSQL, there is code to
de-index all but the most recent version of the page. But
when a page is moved, it was accidentally de-indexing the
most recent version as well, because rev_text_id is not
incremented in that case. A simple tweak to the SQL
fixes that.
I added code to the update script to find pages
previously corrupted by this problem and reindex them.
Bug: 66650
Change-Id: I52e1bbbd8592be5e7c7383c225e6b4c19bbe5b9e
Gergő Tisza [Fri, 4 Sep 2015 23:15:03 +0000 (4 23:15 +0000)]
Log useful error messages on SSL errors in PhpHttpRequest
Work around PHP's crappy stream error handling to extract the
OpenSSL message that gives actually useful information.
Change-Id: I9eba0f90935e25e2d07995f6181fa90b7d52ea55
(cherry picked from commit
b020612f64c276db2ba679f77c8e4765e0b133ff)
Gergő Tisza [Wed, 8 Jul 2015 07:39:52 +0000 (8 07:39 +0000)]
Log errors in Http::request()
Instead of silently discarding errors in server-side HTTP requests,
log them to a 'http' channel.
Make ForeignAPIFile::httpGet() (which sort of reimplements Http::get())
log to the same channel, for consistency.
Bug: T103043
Change-Id: Ibf552e22adc7fde4a751f92e92dad6ceba2f335c
(cherry picked from commit
64446397925576210c50baedc77becb470df84e2)
Brian Wolff [Wed, 1 Jul 2015 08:15:39 +0000 (1 02:15 -0600)]
Workaround fopen lack of SubjectAltName support for instantCommons
Hacky work around, where on php < 5.6.0 where SubjectAltName is not
supported, if a request to commons.wikimedia.org fails, retry the
request but telling php fopen wrapper to treat it as if it came
from en.wikipedia.org for validation purposes, since as of
c02fab71422a that's what the common name of the cert will be.
In the ideal world, everyone would just have curl installed.
I know this is super hacky, but I'd really like instant commons to
work out of the box even without curl installed.
Note: I'm basing the php 5.6 part on documentation, I have not tested
this with a copy of that version of php.
Bug: T75199
Change-Id: Ibde59be61a5b3d7cd5397ba352dce9be11e1b06f
(cherry picked from commit
bb2adc239410563eeddd6f9017b62187c859fed6)
Brian Wolff [Wed, 1 Jul 2015 07:44:12 +0000 (1 01:44 -0600)]
Use system default location for cafile when using php fopen.
Up to 5.5, PHP does not accept any certificates if cafile/capath
is not set. (From 5.6 it uses the system default CA budle, which is
going to be a better choice than anything we can guess.) So try
to guess the location of the system default CA bundle.
Won't work on windows, but that's a lost cause anyway because PHP
(pre-5.6) can't handle the windows CA file format.
Bug: T75203
Change-Id: I07736c150fe0783e09d297395ed25adf335edbd3
(cherry picked from commit
bcc31a9a0fa77e91c4f3ad4a7f0e056d4bf5e713)
Aaron Schulz [Tue, 22 Apr 2014 02:30:44 +0000 (21 19:30 -0700)]
Avoid bogus IE extension check errors in img_auth.php
Bug: T68667
Change-Id: I57083d3fe0517b94d3b786970b412e6ec51cf5f0
(cherry picked from commit
a650998aa75c617bd2042ccd1b56737dc4517d08)
csteipp [Mon, 10 Aug 2015 20:23:01 +0000 (10 13:23 -0700)]
Update Releasenotes and version number for 1.23.10
Change-Id: Ibcb5605e99cbabbe4159b1131610cc8e9ab5e38f
Kunal Mehta [Fri, 24 Jul 2015 21:23:46 +0000 (24 14:23 -0700)]
SECURITY: Don't disclose if an IP is autoblocked on Special:DeletedContributions
Same patch as
dc2966bd05b, just for Special:DeletedContributions this
time.
Bug: T106893
Change-Id: I2089b21fc379b612fe9bf087b5f4ea75052bdbd3
csteipp [Mon, 10 Aug 2015 17:30:50 +0000 (10 10:30 -0700)]
thumb.php: Escape $rel404 in error message
Bug: T97391
Change-Id: I363686732fe9e5636c85c267c0728fc872c3e39d
Chad Horohoe [Mon, 10 Aug 2015 19:33:18 +0000 (10 12:33 -0700)]
SECURITY: API: Use constant-time comparison for watchlist token
Avoids a theoretical timing attack.
Includes backport of hash_equals() compat function from Iece006e
Bug: T94116
Change-Id: Ia4a2b13bd5d3cd256c6b2deada224148dc2888a6
jenkins-bot [Mon, 13 Jul 2015 18:17:52 +0000 (13 18:17 +0000)]
Merge "Fix InstantCommons - HTTP access to Commons does not work anymore" into REL1_23
umherirrender [Sun, 28 Jun 2015 18:03:00 +0000 (28 20:03 +0200)]
Log http error in ForeignAPIRepo::httpGet
This makes at least the "SSL certificate problem: unable to get local
issuer certificate" visible.
Change-Id: Icf0658b5e9f7ac9c58f98291345442f8e405435f
(cherry picked from commit
d2d692e17b8fa64f3d15b7ddf23173954317d31b)
Gergő Tisza [Mon, 15 Jun 2015 22:47:08 +0000 (15 22:47 +0000)]
Fix InstantCommons - HTTP access to Commons does not work anymore
Bug: T102562
Change-Id: Ie0b4ec179b9ccd13015c9bcbfa5c9917ff26de36
(backported from commit
8517b3cb2276878d11004e2b8bd0a41ce8876134)
Gergő Tisza [Sun, 24 May 2015 11:30:10 +0000 (24 11:30 +0000)]
Add a hook for reporting exceptions
Bug: T100141
Change-Id: I893f8b93e09f9ef70beef46922d304fdb3600b78
(cherry picked from commit
d0d539e6bae1d5b333828ad346eadef3399f5fb1)
Bryan Davis [Sun, 12 Apr 2015 23:20:54 +0000 (12 17:20 -0600)]
Minimal PSR-3 compatible logger layer
Provide a minimal PSR-3 compatible logger layer to make backporting
critical updates from 1.25+ easier. It also serves to allow extensions
that maintain backwards compatibility with the 1.23 LTS releases to
migrate to the new logging system.
A copy of the official PSR-3 implementation is added in
includes/libs/psr3 with the omission of PHP5.4+ Traits. In MediaWiki
1.25+ this library will be provided via Composer.
Bug: T91653
Change-Id: If385e722c62dc1f989af6fdee404535bad989acc
Chad Horohoe [Wed, 16 Jul 2014 00:49:18 +0000 (15 17:49 -0700)]
Make AutoLoaderTest handle namespaces
Bug: 67644
Change-Id: Ibeb0833742c574afac13bfebd278f9d2b8410de6
csteipp [Tue, 31 Mar 2015 13:08:01 +0000 (31 06:08 -0700)]
Updated release notes and version number for MediaWiki 1.23.9
Change-Id: Iceda1e73060a5c05ca11a9cdab065e5b28ae53a7
csteipp [Thu, 12 Mar 2015 22:49:22 +0000 (12 15:49 -0700)]
SECURITY: Don't allow entities in XMP
Test for, and refuse to parse, XMP chunks with a doctype declaration
when parsing XMP.
Bug: T85848
Change-Id: Iea4feb077ee85a35509a920153daaa9321ee69f3
csteipp [Fri, 13 Mar 2015 23:52:18 +0000 (13 16:52 -0700)]
SECURITY: Don't allow directly calling Xml::isWellFormed
Changing Xml::isWellFormed to private. In WMF hosted repos, there are
no callers to isWellFormed directly.
Bug: T85848
Change-Id: I104427989b89c386de571b8e60642095331a1132
csteipp [Fri, 27 Mar 2015 22:08:52 +0000 (27 15:08 -0700)]
SECURITY: Always expand xml entities when checking SVG's
XmlTypeCheck's use of xml_parse for filtering SVG's sometimes left xml
entities unexpanded, which can lead to false-negatives when the
callback was used for filtering. Update XmlTypeCheck to use XMLReader
instead, tell the library to fully expand entities, and rely on the
library to error out if it encounters XML that is likely to cause a DoS
if parsed.
Bug: T88310
Change-Id: I77c77a2d6d22f549e7ef969811f7edd77a45dbba
csteipp [Thu, 19 Feb 2015 23:05:40 +0000 (19 15:05 -0800)]
SECURITY: Escape > in Html::expandAttributes
Escape > characters in attributes, so we don't confuse post-processing,
like LanguageConverter.
Bug: T73394
Change-Id: I768e2a12c7b6ba635e6c8571676b8c776b16bf72
csteipp [Fri, 27 Mar 2015 21:45:55 +0000 (27 14:45 -0700)]
SECURITY: Don't execute another user's CSS or JS on preview
Someone could theoretically try to hide malicious code in their user
common.js and then trick an admin into previewing it by asking for help.
Bug: T85855
Change-Id: I5a7a75306695859df5d848f6105b81bea0098f0a
csteipp [Wed, 14 Jan 2015 00:48:01 +0000 (13 16:48 -0800)]
SECURITY: Fix animate blacklist
The blacklist should prevent animating any element's xlink:href to a
javascript url.
Bug: T86711
Change-Id: Ia9e9192165fdfe1701f22605eee0b0e5c9137d5a
csteipp [Tue, 24 Mar 2015 01:03:24 +0000 (23 18:03 -0700)]
SECURITY: Don't allow embedded application/xml in SVG's
Fix for iSEC-WMF1214-11 and issue reported by Cure 53, which got
around our blacklist on embedded href targets. Use a whitelist instead.
Bug: T85850
Change-Id: I0cf9df4883994072029a2eda1fce8acb39a8f6e9
Tyler Romeo [Tue, 30 Dec 2014 20:24:04 +0000 (30 15:24 -0500)]
SECURITY: Make SVG @import checking case insensitive
@import in embedded CSS is case-insensitive, meaning
an attacker can put "@iMpOrT" and it should still
work.
This uses stripos instead of strpos to make the check
case insensitive.
Bug: T85349
Change-Id: I31db9d81f46460af2d8d3f161ba46c2ab7a170d1
Timo Tijhof [Tue, 2 Dec 2014 21:48:21 +0000 (2 21:48 +0000)]
build: Add Karma task for automated QUnit testing in browsers
To use, first run 'npm install'. Then run 'grunt qunit' to start
the test suite in Chrome.
Squashed cherry-picks from master:
*
ba50b32556: SpecialJavaScriptTest: Add export feat
*
7605f112e4: jquery.mwExtension.test: Fix qunit-fixture conflict
*
365b6f3af9: mediawiki.jqueryMsg.test: Fix crazy concurrency
*
945c1efe37: build: Add Karma task
*
8d92aaf83e: build: Clean up Gruntfile
*
2258f25053: build: Add assert-mw-env task
*
dcbbc0489c: build: Increase browserNoActivityTimeout to 60s
*
fa4ba8dbd7: build: Declare grunt-cli dependency
Change-Id: I4e96da137340a28789b38940e75d4b6b8bc5d76a
Timo Tijhof [Sun, 8 Mar 2015 17:34:06 +0000 (8 18:34 +0100)]
Rename JSDuck config to standard 'jsduck'
* Move configuration to /jsduck.json per standard.
* Move --processes=0 from maintenace script into config file.
* Use grunt-contrib-copy instead of a symlink for resources.
Also removed old JSDuck 4 logic.
Change-Id: Iaaaac50ee78dd9ff8f24f1ef3a3685ad51cf33b2
(cherry picked from commit
3bbd27aa4911e491a6e0838438e9bc03c9df22c6)
Timo Tijhof [Fri, 6 Mar 2015 02:26:44 +0000 (6 03:26 +0100)]
resourceloader: Call setName() in test suite before calling getStyles()
This caused a database error due to NULL being inserted as name, which is illegal.
> Function: DatabaseSqlite::replace/single-row
> NOT NULL constraint failed: unittest_module_deps.md_module
> Stack trace:
> #3 includes/resourceloader/ResourceLoaderFileModule.php(420): DatabaseSqlite->replace()
> #4 tests/phpunit/includes/resourceloader/ResourceLoaderTest.php(88): ResourceLoaderFileModule->getStyles()
> #5 (): ResourceLoaderTest->testLessFileCompilation()
This test shouldn't be trigggering database updates, but that's for
a later change to stub out or refactor.
Bug: T91567
Change-Id: Ic451bd41e2ffc188d2efd6b7ce61b03b9de61296
(cherry picked from commit
54473cbb6deaf3c8b2089a3a9a995b067e272151)
Timo Tijhof [Tue, 14 Oct 2014 21:39:31 +0000 (14 23:39 +0200)]
jquery.badge: Swap non-breaking space character for regular space
Follows-up
d453f81f4e. PHP's native json_encode requires input
being a UTF-8 string. For some reason MediaWiki, Git or OS X is
not reading jquery.badge.css as UTF-8 for me.
https://bugs.php.net/bug.php?id=51947
Due to json_encode rejecting the entire value and returning null
instead, the jquery.badge stylesheet was absent. load.php:
mw.loader.implement("jquery.badge",function, {"css":[null]} );
Change-Id: I84d2017a976249f55bdb269d2b9762db941292fe
(cherry picked from commit
a334bfbb250c48f32827562d54d8cba8ed873d05)