Actions

Installation security hints

From LimeSurvey Manual

Revision as of 02:53, 2 February 2013 by C schmitz (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

General

LimeSurvey relies on its own security system which is activated by default. The authors of this software takes no responsibility and makes no claims in relation to the appropriateness or secureness of this software. However we take security issues very serious and react quickly - if you know of any security problems with LimeSurvey please let us know: info@limesurvey.org or open a bug report at our bug tracker (please mark it as private).

Linux file permissions

If you are using a Linux server, setting according file permissions is required to secure your LimeSurey installation.

Basic facts about Linux/*nix file permissions

A Linux/*nix operating system is multi-user. This means that, apart from your personal account, other user accounts may exist on the system and you should take care of what permissions you give to other users.

Hint: Setting file permissions is especially important in order to secure configuration files holding critical data such as passwords.

Note however that the 'root' account will always be granted permission to access your files (no matter what file permissions you set) as it is the super-admin user.

The webserver (which runs LimeSurvey), is also running under a given identity (user). On Linux, this is usually the 'www','www-data' (on Debian/Ubuntu), 'apache' or 'nobody' user. However, some hosting companies use systems (such as suexec) which make it possible to run LimeSurvey scripts with your personal user. Of course the webserver user must have the right to read LimeSurvey files. However, only a small subset of LimeSurvey subdirectories must be writeable by the webserver user.

Hint: It is very valuable to revoke write permission for the webserver user to these LimeSurvey subdirectories that do not require it. Indeed, even if a LimeSurvey vulnerability might be discovered, the main files will still be protected from an illicit modification thanks to the file system permissions.

Setting file permissions on a self-managed Linux system

If you're managing your webserver and operating system configuration (you are the owner of the physical server or are renting a virtual server on which you have root access), you can follow these recommendations.

You can first set the owner and group of your LimeSurvey files so that it will ease the file permissions setup.

A possible strategy is to set the owner of the LimeSurvey files to your personal username, and the group of the LimeSurvey files to the webserver group. Usually this webserver group only contains the webserver account (and possibly another webmaster account).

For instance if your username is 'myaccount' and the webserver user is 'apache' in the 'apache' group, then, from a shell access, you can use the following command:

$ chown -R myaccount:apache limesurvey/

Then set the file and subdirectories permissions.

For the script to work properly it needs write access to some directories:

  • The "/limesurvey/tmp" directory and its subdirectories are used for imports/uploads and should be set to Read & Write for your webserver.
  • The upload/ directory and all its subdirectories must also have Read & Write for your webserver in order to enable picture and media files upload.
  • All other directories and files can be set to Read Only
Hint: Supposing you've followed the above recommendations on owner/group, these settings can be applied by the following commands:

$ chmod -R o-r-w-x limesurvey/

$ chmod -R -w limesurvey/

$ chmod -R 770 limesurvey/tmp

$ chmod -R 770 limesurvey/upload

Setting file permissions on a hosted webserver

Giving a standard procedure to secure a web application on a hosted environment is rather difficult because hosted environments differ in so many ways.

As in the managed server case, for the script to work properly it needs write access to some directories:

  • The "/limesurvey/tmp" directory is used for imports/uploads and should be set to Read & Write for your webserver.
  • The upload/ directory and all its sub directories must also have Read & Write for your webserver in order to enable picture and media files upload.
  • The other directories and files should be set to Read Only
Hint:
  • Depending on your webserver configuration you will have to chmod the rights on the writable folders to 755 or 777 to make it writable for the webserver. Try 755 first - if it does not work 'upgrade' to 777.
  • You can also try to remove read access to config.php to others by setting this file's permissions to 750 - if it does not work 'upgrade' to 755.

Windows file permissions

If you are using a windows server your should ensure that the admin folder allows the owner of the webserver process to write files to this directory, however all other files can be set to read-only and execute.

Other security issues

The following are recommendations only. LimeSurvey in general is very safe without these additional measure. If you however collect extremely sensitive data a little additional security can help:

The /application/config/config.php file contains a user name and password for your database server. This poses certain security issues, particularly if you are using a login that has high level administrative access to your database. In the event of some error returning the content of this PHP file to a user's browser, your database password and other details could be compromised (please note, that this is a very unlikely scenario). The best way to minimize risk is to set up a specific login that has specific rights only to your limesurvey database.

Another way to secure this information can be to put the certain information from the /application/config/config.php file in a non-web directory, i.e. for Apache users this is the directory above the htdocs (aka public_html or www) folder. So you will use config.php, but have one line in it - a line that includes the file with ACTUAL configuration information (ex: <?php return include("/home/hostfolder/safedata/configreal.php"); ?>). Remove all actual configuration information from /application/config/config.php, and paste it into the other file (configreal.php) that is included by /application/config/config.php. This other file should be located in a non-Web directory. Then /application/config/config.php will not contain database passwords, etc. - just the name of the file that DOES contain the database info. This avoids having to change all the other files that include /application/config/config.php, since they can still include it, and it will include the real config information. However you will need to edit configreal.php and change the follow parameters

'basePath' => dirname(dirname('''FILE''')),

'runtimePath' => dirname(dirname(dirname('''FILE'''))).DIRECTORY_SEPARATOR.'tmp'.DIRECTORY_SEPARATOR.'runtime',

[...]

'urlManager' => array(

   [...]

   'rules' => require('routes.php'),

   [...]

);

to use absolute directory paths to work properly. Example:

'basePath' => '/var/www/htdocs/limesurvey',

'runtimePath' => '/var/www/htdocs/limesurvey/tmp/runtime',

[...]

'urlManager' => array(

   [...]

   'rules' => require('/var/www/htdocs/limesurvey/config/routes.php'),

   [...]

);

Also don't use "admin" as the default user. Go to your MySQL database (or other one if you installed LimeSurvey on different database) and change default user name "admin" to whatever you prefer (e.g. "admin_xyz"). It will be now much harder to guess administrator's new user name. Remember, this is one of the two variables intruders can use to gain access. The admin password is the other variable. So choose it with extreme care.