security.html 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  1. <html lang="en">
  2. <head>
  3. <meta charset="utf-8" />
  4. <title>Chamilo Security Guide</title>
  5. <link rel="stylesheet" href="../web/assets/bootstrap/dist/css/bootstrap.css" type="text/css" media="screen,projection" />
  6. <link rel="stylesheet" href="default.css" type="text/css" media="screen,projection" />
  7. <link rel="shortcut icon" href="../favicon.ico" type="image/x-icon" />
  8. </head>
  9. <body>
  10. <div class="container">
  11. <h1>Chamilo LMS: Security Guide</h1>
  12. <a href="index.html">Documentation</a> &gt; Security Guide
  13. <p>We recommend you don't take security issues too lightly. Chamilo is security-audited at least once a year,
  14. but you're never too sure. This list is a work in progress. Feel free to recommend additional measures by
  15. sending us an e-mail at info@chamilo.org.</p>
  16. <h2><b>Contents</b></h2>
  17. <ol>
  18. <li><a href="#1.Disclosing-server-info">Disclosing server info</a></li>
  19. <li><a href="#2.Keeping-up-to-date">Keeping up to date</a></li>
  20. <li><a href="#3.Using-safe-browsers">Using safe browsers</a></li>
  21. <li><a href="#4.Moving-config-file">Moving your configuration file out of the web directory</a></li>
  22. <li><a href="#5.Files-permissions">Restricting files permissions</a></li>
  23. <li><a href="#6.HSTS">HTTP Headers Security</a></li>
  24. <li><a href="#7.Direct-web-access">Direct web access to files</a></li>
  25. </ol>
  26. <h2><a name="1.Disclosing-server-info"></a>1. Disclosing server info</h2>
  27. <p>
  28. It is considered a safer behaviour not to disclose server information from your Chamilo page. In order to avoid
  29. both web server and PHP information disclosure, you might want to take the following actions:
  30. </p>
  31. <ul>
  32. <li>Locate the <i>ServerTokens</i> setting inside your Apache configuration and set it to "Prod"</li>
  33. <li>Locate the <i>ServerSignature</i> setting inside your Apache configuration and set it to "Off"</li>
  34. <li>Locate the <i>expose_php</i> setting inside your PHP configuration and set it to "Off"</li>
  35. <li>Reload Apache</li>
  36. </ul>
  37. <h2><a name="2.Keeping-up-to-date"></a>2. Keeping up to date</h2>
  38. <p>
  39. Make sure you check <a href="http://support.chamilo.org/projects/chamilo-18/wiki/Security_issues">our security
  40. issues page</a> from time to time.
  41. Subscribe to our free security alerts mailing-list:
  42. <a href="http://lists.chamilo.org/listinfo/security">http://lists.chamilo.org/listinfo/security</a> or that you
  43. follow our security Twitter feed: <a href="http://twitter.com/chamilosecurity">http://twitter.com/chamilosecurity</a>.
  44. </p>
  45. <h2><a name="3.Using-safe-browsers"></a>3. Using safe browsers</h2>
  46. <p> Additionally to lacking the implementation of features that really improve the quality of your browsing the
  47. Internet, older browsers tend to have many unresolved security flaws. Using an old browser, you put in danger the
  48. security of your computer and the data it contains, but you can also put others in danger by letting crackers take
  49. control of it and attacking others.</p>
  50. <p>To avoid being a risk to yourself and others, you should download and install a recent browser. We recommend
  51. <a href="http://www.getfirefox.com" target="_blank">the latest stable version of Firefox</a>.</p>
  52. <h2><a name="4.Moving-config-file"></a>4. Moving your configuration file out of the web directory</h2>
  53. <p>It is considered unsafe to leave the configuration file inside the app/config/ directory, as it will be directly
  54. accessible for all users, which could lead crackers to download it, uninterpreted, and read through your
  55. configuration, which could lead to illicit
  56. access to your database if that one isn't well protected and many other stuff we'd prefer to avoid. To secure it,
  57. move the configuration file out of your web directory. If your Chamilo installation is in /var/www/, move your
  58. configuration to /etc/chamilo/configuration.php, for example. Then create a new app/config/configuration.php
  59. file, open it, and write the following:</p>
  60. <pre>
  61. &lt;?php
  62. require '/etc/chamilo/configuration.php';
  63. </pre>
  64. <p>
  65. This will prevent direct access to your settings and make it seem totally the same to Chamilo.
  66. </p>
  67. <h2><a name="5.Files-permissions"></a>5. Restricting files permissions</h2>
  68. <p>Making all the Chamilo files world-writable will help you install quickly, and it solves many
  69. issues for people without much admin experience. However, it's more
  70. secure to make a distinct user owner of all the chamilo files and folders,
  71. and only give read access to the web server to all files, and write access
  72. only to the directories previously mentioned.</p>
  73. <p>This way, these files need
  74. only be readable and writable by the Apache process owner, not by the
  75. entire world. It would also be advisable to make all writable directory
  76. refuse the interpretation of PHP files (except for the root of the courses
  77. directories).</p>
  78. <p>Don't hesitate to hire an experienced administrator to do that,
  79. it might be a bit more expensive now, but you'll be happy not to have to loose
  80. all of your data to a hacker who attacked your site.</p>
  81. <p>Only the following directories have required (or optional) write
  82. permissions from the web server:<br />
  83. <ul>
  84. <li>app/cache/</li>
  85. <li>app/courses/</li>
  86. <li>app/home/</li>
  87. <li>app/logs/</li>
  88. <li>app/upload/</li>
  89. <li>main/default_course_document/images/</li>
  90. <li>main/lang/ (optional, only for sublanguages)</li>
  91. <li>web/css/ (optional, only for switching CSS through the web)</li>
  92. </ul>
  93. <br />
  94. Because these directories have "write by the web server" permissions,
  95. it is important to prevent the execution of PHP scripts from those
  96. directories (because a specially-crafted attack could end up allowing
  97. the upload of a PHP script to one of these). To do that, taking into
  98. account we authorize overrides through .htaccess, we need to set
  99. something that a .htaccess file cannot revert, and we need to set it
  100. for each of those directories. This can be done as follows inside
  101. your VirtualHost definition in Apache, where "/var/www/URL/" is the path of your VirtualHost web root:<br />
  102. <pre>
  103. &lt;Directory /var/www/URL/app/cache&gt;
  104. php_admin_value engine Off
  105. &lt;/Directory&gt;
  106. &lt;Directory /var/www/URL/app/courses&gt;
  107. php_admin_value engine Off
  108. &lt;/Directory&gt;
  109. &lt;Directory /var/www/URL/app/home&gt;
  110. php_admin_value engine Off
  111. &lt;/Directory&gt;
  112. &lt;Directory /var/www/URL/app/logs&gt;
  113. php_admin_value engine Off
  114. &lt;/Directory&gt;
  115. &lt;Directory /var/www/URL/app/upload&gt;
  116. php_admin_value engine Off
  117. &lt;/Directory&gt;
  118. &lt;Directory /var/www/URL/app/Resources/public/css>
  119. php_admin_value engine Off
  120. &lt;/Directory&gt;
  121. &lt;Directory /var/www/URL/main/default_course_document/images&gt;
  122. php_admin_value engine Off
  123. &lt;/Directory&gt;
  124. &lt;Directory /var/www/URL/main/lang&gt;
  125. php_admin_value engine Off
  126. &lt;/Directory&gt;
  127. &lt;Directory /var/www/URL/web/css&gt;
  128. php_admin_value engine Off
  129. &lt;/Directory&gt;
  130. </pre>
  131. For Nginx, this would look like the following rules. However, do
  132. remember that Nginx interprets rules in order of appearance, so these
  133. rules would have to be at the top of your location rules to take the
  134. highest priority:
  135. <pre>
  136. location ~ ^/app/(cache|courses|home|logs|upload|Resources/public/css)/.*\.ph(p[3457]?|t|tml|ar)$ {
  137. deny all;
  138. }
  139. location ~ ^/main/default_course_document/images/.*\.ph(p[3457]?|t|tml|ar)$ {
  140. deny all;
  141. }
  142. location ~ ^/main/lang/.*\.ph(p[3457]?|t|tml|ar)$ {
  143. deny all;
  144. }
  145. location ~ ^/web/css/.*\.ph(p[3457]?|t|tml|ar)$ {
  146. deny all;
  147. }
  148. </pre>
  149. <br />
  150. <hr />
  151. <h2><a name="6.HSTS">HTTP Headers Security</a></h2>
  152. <p>A relatively recent development in web security, HTTP headers can be modified either
  153. from the web server or from the application (like Chamilo) to increase the security
  154. of your visitors.</p>
  155. <p>These implies several aspects, from simple to complex, to deal with, from stuff like
  156. indicating which websites you say media or libraries can be loaded from, to adding
  157. extra info about your SSL certificate to make sure a hacked certification authority
  158. will not immediately make your certificate useless.</p>
  159. <p>In Chamilo 1.11.6, we have added several parameters, together with recommendations,
  160. to main/install/configuration.dist.php, that you are free to use or ignore,
  161. depending on the level of security you want to achieve.</p>>
  162. <p>To check your portal for possible improvements in terms of headers security,
  163. we highly recommend the <a href="https://securityheaders.io/">securityheaders.io</a>
  164. website. If you want to read more about CSP and all related headers
  165. security techniques, check <a href="https://scotthelme.co.uk/">Scott Helme's blog</a>.
  166. <br />
  167. <hr />
  168. <h2><a name="7.Direct-web-access">Direct web access to files</a></h2>
  169. <p>If .htaccess is enabled or the .htaccess rules are translated into the
  170. web server vhost configuration (see installation guide for that), Chamilo
  171. will do some natural files access protection.<br />
  172. <br />
  173. This protection is executed through redirections of some URLs to make the
  174. request go through some kind of permissions validation script. For
  175. documents, this means going through the main/document/download.php script,
  176. but there are some more specific rules (see .htaccess for details).<br />
  177. <br />
  178. While this does a great job to avoid access by unprivileged users, this
  179. also creates an efficiency issue, whereby some files, in version 1.11, can
  180. take up to 5 times the load time when it goes through the permissions
  181. validation.<br />
  182. <br />
  183. Because of that, we have taken some decisions to reduce the impact in a
  184. reasonable way. For example, static files in SCORM content
  185. (in courses/[code]/scorm/) like CSS, JS, PNG, JPG and GIF are *not* scanned
  186. this way (there is an exception for that). We believe that these resources
  187. do not contain confidential information. If you *DO* have confidential
  188. information in images, CSS or JavaScript files, you will need to update
  189. these rules to suit your needs.
  190. </p>
  191. <h2>Authors</h2>
  192. <ul>
  193. <li>Yannick Warnier, Zend Certified PHP Engineer, BeezNest Belgium SPRL,
  194. <a href="mailto:yannick.warnier@beeznest.com">yannick.warnier@beeznest.com</a></li>
  195. </ul>
  196. </div>
  197. </body>
  198. </html>