Actions

Beveiligingstips

From LimeSurvey Manual

Revision as of 13:29, 23 May 2013 by Rikthoff (talk | contribs) (Created page with "Nu kun je de bestands- en directoryrechten instellen.")

Algemeen

LimeSurvey vertrouwt op zijn eigen beveiligingssysteem, dat standaard geactiveerd is. Echter, de auteurs van de software accepteren geen verantwoordelijkheid voor, en maken geen claims over de veiligheid of geschikheid van de software. Dat gezegd hebbende zijn we uiteraard zeer benieuwd naar veiligheidslekken. Kom je zoiets tegen, mail ons dan op info@limesurvey.org, of open een foutrapport op onze bug tracker (zet deze wel graag op privé).

Linux bestandsrechten

Als je een Linux server gebruikt, bepalen de bestandsrechten mede de veiligheid van de LimeSurvey installatie.

Een primer over Linux/*nix bestandsrechten

Een Linux/*nix systeem is multiuser. Dat betekent dat er behalve jouw account mogelijk ook andere "gebruikers" actief zijn op het systeem. Deze "gebruikers" moeten de juiste rechten hebben.

Hint: Het instellen van bestandsrechten is bijzonder belangrijk bij configuratiebestanden, omdat hier gevoelige informatie, zoals wachtwoorden instaan.

Het 'root'-account geeft altijd toegang tot alle bestanden (ongeacht de toegekende rechten), omdat het de super-admin is

De webserver (waar LimeSurvey op draait) is ook zo'n gebruiker. Op Linux is dit waarschijnlijk de 'www','www-data' (op Debian/Ubuntu), 'apache' of 'nobody'-gebruiker. Ook kan de hoster er voor kiezen om systemen zoals 'suexec' te gebruikken om LimeSurvey-scripts uit te voeren onder jouw account. De webserver moet uiteraard de LimeSurvey-bestanden kunnen lezen. Maar slechts een klein gedeelte hoeft hij ook te kunnen overschrijven.

Hint: Het is zeer nuttig om de schrijfrechten voor de webservergebruiker in te trekken op bepaalde mappen. Mocht er dan een beveiligingslek in de software ontdekt worden, dan worden de bestanden nog steeds beschermd door de bestandsrechten van het systeem.

Instellen van bestandsrechten op een Linuxsysteem in eigen beheer

Als je zelf de webserver beheert (omdat je ofwel de hardware bezit of omdat je een (virtuele) server huurt met root-toegang), volg dan de volgende aanbevelingen:

Je kunt optioneel eerst een eigenaar en groep aanmaken zodat de toewijzing van rechten gemakkelijker gaat.

Een mogelijke aanpak daarbij is jezelf eigenaar maken van de bestanden, en de groep toewijzen aan de webservergroep. Daarbij is het gebruikelijk dat alleen de webservergebruiker lid is van deze groep (en mogelijk ook een andere webmaster).

Als bijvoorbeeld jouw gebruikersnaam 'mijnaccount' is, de webservergebruiker 'apache' die lid is van de groep 'apache', dan kun je het volgende commando gebruiken:

$ chown -R mijnaccount:apache limesurvey/

Nu kun je de bestands- en directoryrechten instellen.

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.