DokuWiki is a web application and is often used on public servers, reachable from the Internet. This means it is at a greater risk to be attacked by malicious people than, for example, a local application on your desktop system.
DokuWiki is developed with security in mind. We try to find a balance between user friendliness and security, but favor security when no satisfying compromise can be found.
This page should give you an overview on what aspects you should have an eye on to make sure your DokuWiki is secure.
When you discover a security issue in DokuWiki, please notify us. The preferred ways to do so are:
The first two ways should be preferred except for very serious bugs where making the bug public before a patch is available could endanger DokuWiki installations world wide.
All previous security issues can be seen in the bugtracking system.
Depending on the severity of a found security issue it will be fixed in a future release (on very minor issues) or a bugfix release will be made. In the latter case users will be informed through the update check mechanism.
You should always run the most current release of DokuWiki as there are no security fixes released for older versions.
DokuWiki stores configuration and page data in files. These files should never be accessible directly from the web. The distribution tarball contains a set of .htaccess files which usually tell the Apache web server to deny access to certain directories.
If you don't use the Apache web server or your Apache does not use .htaccess files you need to manually secure your installation
The following directories should not be accessible from the web:
dataconfbininc (isn't dangerous when accessible, though)
To check if you need to adjust the access permissions try to access http://yourserver.com/dokuwiki/data/pages/wiki/dokuwiki.txt. You should not get access to that file this way.
If your directories are not properly secured, read the following subsections on how to do that.
The simplest way is to enable .htaccess support in your Apache configuration. Please see the Apache .htaccess Tutorial.
DokuWiki already comes with correctly configured .htaccess files. The contents of a .htaccess file to block all access to the directory it is in should be as follows:
order allow,deny deny from all
Remark : Using apache2 on a Ubuntu, the .htaccess does not work !
It seems that Apache2 in general, or it might be specifically to Ubuntu, is configured slightly differently than Apache1.x.
In the /etc/apache2/sites-available you need to modify the file default (or the file default-ssl if you use https rather than http)
There you'll find:
NameVirtualHost *
<VirtualHost *>
ServerAdmin admin@site.com
DocumentRoot /var/www/
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride none
Order allow,deny
allow from all
</Directory>
Default for AllowOverride in the <Directory /var/www/> is none, should be all
/etc/init.d/apache2 reload to refresh your apache configuration and your .htaccess files should now work.
(See http://ubuntuforums.org/showthread.php?t=47669 for the full thread)
The other way is to use LocationMatch directive inside VirtualHost definition - it's a little bit more efficient than .htaccess. Just below Directory directive add:
<LocationMatch "/(data|conf|bin|inc)/">
Order allow,deny
Deny from all
Satisfy All
</LocationMatch>
However see the “What to use When” section here http://httpd.apache.org/docs/2.0/sections.html#file-and-web for a statement that “Location” directives should not be used for protecting filesystem objects, only virtual (e.g. database-generated) paths. IMO if .htaccess isn't available or sufficient, then putting directory-specific restrictions directly in the hosts conf file would be the safest approach. This http://ada.adrianlang.de/dokuwiki-php-execution#solutions_in_the_configuration seems a solid approach - but this document should be “canonical”.
The above could cause a problem if you have another “root” that includes the directorys data|conf|bin|inc. For example another wiki installation. You can avoid this problem by extending your LocationMatch within your wiki installation folder.
<Directory /var/www/dokuwiki>
order deny,allow
allow from all
</Directory>
<LocationMatch "/dokuwiki/(data|conf|bin|inc)/">
order allow,deny
deny from all
satisfy all
</LocationMatch>
Access to the mentioned directories can be disabled in IIS' configuration settings.
In IIS7:
Repeat for ”/data/media” and choose “Always Allow” (otherwise your images and other won't be visible)
Note: By default, the Management Console snap-in for Internet Information Services 7 does not have UI access to “IIS Request Filtering” section. However, can be enabled by installing “IIS Administration pack 1.0” by using the Web Platform Installer.
Using a URL re-write you can deny access to the above directories. In your lighttpd.conf file adding the following URL rewrite rule should be sufficient to keep people out. It suppose your Dokuwiki files are installed under http://yourwebsite.tld/dokuwiki/. Don't forget to uncomment “mod_rewrite” in the server.modules section.
url.rewrite-once = ( "^/dokuwiki/(data|conf|bin|inc)/+.*" => "/nonexistentfolder" )
Or use “mod_access”. More examples available here.
$HTTP["url"] =~ "^/dokuwiki/(data|conf|bin|inc)/+.*" {
url.access-deny = ("")
}
Access to aforementioned directories can be disabled in DokuWiki server section of Nginx configuration file. In your nginx.conf file add the following location to prevent access to secure directories.
location ~ /(data|conf|bin|inc)/ {
deny all;
}
Also disabling access to .htaccess files is recommended:
location ~ /\.ht {
deny all;
}
It is relatively easy to fordbid access to those directories using Cherokee. In cherokee-admin, select the virtual server where dokuwiki is installed and select rules management.
then add a new “Regular Expression” rule and put the following in it :
/(data|conf|bin|inc)/
Then go in “Handler” section and select HTTP Error. Finally select “403 Forbidden” in HTTP Error.
Securing the data directory is most important. If you can not move directories out of the webserver (see below) or can't configure your webserver to deny access (see above), then you should at least make it harder to guess the name of your data directory.
To do so, rename your data directory to something cryptic (eg. a long row of letters and numbers) and reconfigure your savedir option in your conf/local.php file.
The most secure way to avoid any access to the mentioned directories is to move them outside the so called “Document Root” of your Webserver.
WARNING: If you are planning to use the installer, you need to install your wiki executing the install.php script first before you can do this step. If the Move Directories operation is done before, the installer execution will fail.
data directory (and all its contents) out of the document rootdata directory.
For example, if the data directory is moved to /home/yourname/data, add the following line to conf/local.php:
$conf['savedir'] = '/home/yourname/data/';
conf directory (and all its contents) out of the document rootinc directory and set the DOKU_CONF define to the new location of the conf directory.
For example, if the conf directory is moved to /home/yourname/conf, create the following inc/preload.php:
<?php // DO NOT use a closing php tag. This causes a problem with the feeds, // among other things. For more information on this issue, please see: // http://www.dokuwiki.org/devel:coding_style#php_closing_tags define('DOKU_CONF','/home/yourname/conf/');
The bin directory contains CLI tools. If you don't have shell access on your server anyway you can simply delete the directory and its contents. Otherwise just move it out of the document root. No further configuration needed.
There is currently no easy way to move this directory out of the document root. But since it doesn't contain any sensitive data it isn't worth the effort to try anyway.
DokuWiki contains several configuration settings that have an impact on various security aspect of the installation. Please refer to the documentation of each setting to learn what they do and what suggested settings are.
DokuWiki has lots of community contributed plugins. Plugins add new functionality to DokuWiki by adding new code. This means the code has practically any access to your server. Additionally plugins are distributed separately from DokuWiki in an entirely ad-hoc manner. They are not subject to the same degree of attention and review that the core DokuWiki code base gets. So security precautions are necessary before installing a plugin.
Here are some tips to help you with choosing the plugins you install.
lib directory, which is directly accessible from the outside. Review what a plugin contains and lock down access with .htaccess files as appropriate.See also: How to report security issues in plugins
Here are a few more internal and external pages related to security.