Extension:Secure HTML: Difference between revisions
Version 2.2.3 |
|||
| Line 8: | Line 8: | ||
|author = [[User:Fo0bar|Ryan Finnie]] |
|author = [[User:Fo0bar|Ryan Finnie]] |
||
|image = |
|image = |
||
|version = 2.2. |
|version = 2.2.3 |
||
|update = 2013- |
|update = 2013-05-04 |
||
|mediawiki = 1.18+ |
|mediawiki = 1.18+ |
||
|license = GPL |
|license = GPL |
||
|download = [https://gerrit.wikimedia.org/r/gitweb?p=mediawiki/extensions/SecureHTML.git;a=snapshot;h= |
|download = [https://gerrit.wikimedia.org/r/gitweb?p=mediawiki/extensions/SecureHTML.git;a=snapshot;h=32b935d5a43248d8dce03d1b6b38af4354fc272b;sf=tgz Download '''latest stable release''' (2.2.3)], or: {{WikimediaDownload|SecureHTML}} |
||
|readme = |
|readme = |
||
|changelog = |
|changelog = |
||
Revision as of 08:56, 4 May 2013
MediaWiki was not designed to support per-page or partial-page access restrictions. If you require this level of control, you are strongly advised to use a content management system that supports it natively.
Patches or third-party extensions claiming to provide access control, when in use with MediaWiki, may not work in all cases, potentially exposing confidential data. Use them at your own risk. Neither the MediaWiki developers nor the Wikimedia Foundation are responsible for any data leaks that may result. This message is added to all extensions of this nature and may not reflect the actual security status of this extension. For more information, see Security issues with authorization extensions. |
Release status: stable |
|
|---|---|
| Implementation | Tag, User rights |
| Description | Lets you include arbitrary HTML in an authorized and secure way |
| Author(s) | Ryan Finnie (Fo0bartalk) |
| Latest version | 2.2.3 (2013-05-04) |
| MediaWiki | 1.18+ |
|
$wgSecureHTMLSecrets, $shtml_keys (deprecated) |
|
|
<shtml> |
|
| Licence | GNU General Public License (any version) |
| Download | Download latest stable release (2.2.3), or: |
| Example | <shtml> tag (PayPal forms), Special:SecureHTML |
| Translate the Secure HTML extension if it is available at translatewiki.net | |
Occasionally you need to display HTML within a wiki, but allowing it site-wide opens you up to various XSS attacks. This extension solves that problem by letting you specify arbitrary HTML, but only if the HTML includes a corresponding hash that is created by combining the HTML input, along with a secret that only authorized people know.
The extension uses a special page, Special:SecureHTML which helps you build a tag, <shtml>, which acts as a wrapper around raw HTML. An example looks like (linefeeds added for readability):
<shtml version="2" keyname="fo0bar" hash="7fa503206cb1de131dd6acdca576e92262dd6d176cc3466073a343863743b8ed" ><strong>Hello world!</strong></shtml>
If the user uses a valid shared secret to build the hashed <shtml> snippet and includes it in a wiki page, the snippet is rendered as the raw HTML contained within the tag. If the shared secret is invalid, the snippet is rendered as an error message (but not containing the HTML, obviously).
Installation
Secure HTML has been tested with MediaWiki 1.18 and later (the earliest supported version at the time of this writing). It may work with earlier MediaWiki versions, however.
The extension can be retrieved directly from Git [?]:
- Browse code
- Some extensions have tags for stable releases.
- Browse tags
- Select the tag
- Click "snapshot"
- Each branch is associated with a past MediaWiki release. There is also a "master" branch containing the latest alpha version (might require an alpha version of MediaWiki).
- Browse branches
- Select a branch name
- Click
Continue
Extract the snapshot and place it in the extensions/SecureHTML/ directory of your MediaWiki installation.
If you are familiar with Git and have shell access to your server, you can also obtain the extension as follows:
cd extensions/
git clone https://gerrit.wikimedia.org/r/mediawiki/extensions/SecureHTML.git
- Edit LocalSettings.php in the root of your MediaWiki installation, and add the following lines near the bottom:
require_once( "$IP/extensions/SecureHTML/SecureHTML.php" );
$wgSecureHTMLSecrets = array(
'keyname' => 'keysecret',
);
- Modify $wgSecureHTMLSecrets as per below.
- Go to Special:SecureHTML and use the page to create a hashed snippet of raw HTML using the key secrets defined.
- Add the hashed snippet to your desired wiki page.
Configuration
Secure HTML uses HMAC digests to sign a piece of raw HTML in a <shtml> tag, using a shared secret key. The $wgSecureHTMLSecrets configuration array may have multiple shared secrets, and is in the format:
$wgSecureHTMLSecrets = array(
'Wiki admin' => 'foo',
'developers' => 'bar',
'Support department' => 'baz',
);
The first part of each pair is the key name, and the second part is the key secret. This way, you can logically segment shared secrets among several groups. If a keyname= parameter is not given to the <shtml> tag, the first entry in $wgSecureHTMLSecrets is assumed. So, for example:
<!-- Use the default key ("Wiki admin" in the above example), signed with "foo" -->
<shtml version="2" hash="ab...cd">HTML</shtml>
<!-- Or specify the key name explicitly -->
<shtml version="2" keyname="Wiki admin" hash="ab...cd">HTML</shtml>
<!-- Use the "developers" key, signed with "bar" -->
<shtml version="2" keyname="developers" hash="ab...cd">HTML</shtml>
Special:SecureHTML
The special page Special:SecureHTML is used to build the snippet, specifying the raw HTML, the key secret, and (optionally) the key name. If a key name is not specified, the first entry in $wgSecureHTMLSecrets is assumed. When the form is submitted, the signed snipped is displayed, and an attempt to render the snippet is made. If the key secret is incorrect, this will show you the results immediately, before you try to add the snippet to a page.
As of version 2.1, the special page is restricted to users who have the 'edit' right; the rationale being the user needs to be able to edit pages anyway to make use of this extension. If you would like to change this right, set $wgSecureHTMLSpecialRight to another right, or set to '' to allow anyone to use the special page.
Note that this restriction does not provide much extra security. If your MediaWiki installation requires users to be logged in to edit, it does provide superficial protection against anonymous dictionary attacks (checking the preview result) against a key. However, if a user already knows a key secret, he/she can build the signed snippet manually; the special page is not strictly needed.
Internationalization
Translation of the extension strings is managed by Translatewiki.net (direct extension link). Please contribute translations there.
Hash versions
Version 1 (deprecated)
The original version of this extension stored its keys in the global $shtml_keys, and used a simple MD5 concatenation of the key secret and the raw HTML to form the hash. This is potentialy less secure than HMAC, and has been deprecated. If a version= parameter is not given to the <shtml> tag, version 1 is assumed, and keys will be taken from $shtml_keys.
This interface is retained for backwards compatibility with the original version. If you have upgraded from the original version, please convert your snippets as soon as possible, as this interface will be removed at a future date.
Version 2
Version 2 is signified by <shtml version="2" ...>, and uses a HMAC_SHA256 digest of the raw HTML and key secret. It is the current, default (when using Special:SecureHTML to generate the snippet) and preferred interface.
See also
- Extension:SecureHTML - Similar name, different extension which restricts <html> sections to protected pages/namespaces.
- Extension:Secured HTML - Similar name, allows the use of arbitrary HTML if the editor is in the "coders" access group.
