[debian-edu-commits] [Git][debian-edu/debian-edu-config][stretch] 8 commits: etc/apache2/mods-available/debian-edu-userdir.conf: White-space cleanup (tabs and spaces mixed).

Mike Gabriel (@sunweaver) gitlab at salsa.debian.org
Fri Feb 11 15:17:06 GMT 2022



Mike Gabriel pushed to branch stretch at Debian Edu / debian-edu-config


Commits:
4d662994 by Mike Gabriel at 2022-02-11T16:05:39+01:00
etc/apache2/mods-available/debian-edu-userdir.conf: White-space cleanup (tabs and spaces mixed).

(cherry picked from commit dee8b9df0fc936cf4407dead72b6d7205b065e70)
(cherry picked from commit bf4416cc2cdc77ce547d8280c80c5de63c5bf445)
(cherry picked from commit b9d581cc3e9216fd0a51359f28f89ffa6da9475c)

- - - - -
ac1d297b by Mike Gabriel at 2022-02-11T16:06:15+01:00
etc/apache2/mods-available/debian-edu-userdir.conf: Disable built-in PHP engine.

(cherry picked from commit 4d39a5888d193567704238f8c035f8d17cfe34e5)
(cherry picked from commit f400eb04488662059ba961d07cc94489c96601eb)

- - - - -
c91d8315 by Mike Gabriel at 2022-02-11T16:06:17+01:00
README.public_html_with_PHP-CGI+suExec.md: Provide documentation on how to enable suExec support in https userdirs (i.e. ~/public_html).

(cherry picked from commit 760d450c6f2504a9d2c43298b2398697fa20cfe5)
(cherry picked from commit 11bf64406289ac6055f5b4023d76b30078294679)

- - - - -
2d0512ad by Mike Gabriel at 2022-02-11T16:07:01+01:00
debian/changelog: update from Git history

(cherry picked from commit 77ceb4a356177cea78392696cf3950965262c723)
(cherry picked from commit 1ce577a818e570a206befd04d097959caadb6fff)

- - - - -
1e69b28e by Mike Gabriel at 2022-02-11T16:09:31+01:00
d/changelog: Attribute PHP engine disablement with CVE-2021-20001.

(cherry picked from commit f5988a0fcfab0284d46025603de68a3d2f23ab8e)
(cherry picked from commit d4701c9e825e4f4a0b931c90b46f8c8d31208f0c)

- - - - -
885199c3 by Mike Gabriel at 2022-02-11T16:10:46+01:00
debian/NEWS: Add file, inform about PHP being disabled in Apache2 user directories.

(cherry picked from commit ed0dca83df11c76f448844b48039a0f3ef353a79)

- - - - -
d9403bb2 by Mike Gabriel at 2022-02-11T16:11:19+01:00
debian/NEWS: amend typo fixes

(cherry picked from commit 5448a307990a8c69536512ae92f40196f3b3b1fa)

- - - - -
f0f843fa by Mike Gabriel at 2022-02-11T16:13:03+01:00
upload to stretch-security (debian/1.929+deb9u5)

- - - - -


5 changed files:

- Makefile
- + README.public_html_with_PHP-CGI+suExec.md
- debian/NEWS
- debian/changelog
- etc/apache2/mods-available/debian-edu-userdir.conf


Changes:

=====================================
Makefile
=====================================
@@ -316,6 +316,7 @@ install: install-testsuite
 	done
 
 	$(INSTALL_DATA) README $(DESTDIR)$(docdir)/README
+	$(INSTALL_DATA) README.public_html_with_PHP-CGI+suExec.md $(DESTDIR)$(docdir)/README.public_html_with_PHP-CGI+suExec.md
 
 # Samba roaming profile examples in different languages
 	set -e ; for l in en de nb nl ; do \


=====================================
README.public_html_with_PHP-CGI+suExec.md
=====================================
@@ -0,0 +1,137 @@
+# Debian Edu and PHP scripts in ~/public_html
+
+This is about the Apache2 configuration on the Debian Edu mainserver (aka
+``tjener.intern``).
+
+## Security Notices and Warnings
+
+The configuration file
+``/etc/apache2/mods-available/debian-edu-userdir.conf`` disables the
+Apache2 built-in PHP support for PHP scripts in user directory (i.e. in
+web pages served via ~/public_html).
+
+This is for a reason, as Apache2's default system account ``www-data``
+has certain privileges on the Debian Edu main-server that we don't want to
+expose to arbitrary code in some ``~/public_html`` directory.
+
+If people shall be able to execute PHP (or other CGI scripts) from
+``~/public_html`` for studying purposes, then they should be executed
+with the script file owner's user privileges.
+
+Do not use this method if it is not required to interpret PHP code from
+within ~/public_html directories. This method (opposed to Apache2's
+built-in PHP support) exposes user home directories to data manipulation
+risks (in case users create bad code in their ~/public_html scripts).
+Also, this method turns Apache2's PHP interpretation into some rather
+performance wasting mode (libapach2-mod-phpX -> phpX-cgi).
+
+## Test built-in PHP
+
+Here is a simply PHP script for testing proper interpretation and
+checking that the suExec'ing really works
+
+```
+<?php
+
+print "hello, this script runs as user '";
+system("id -u -n");
+print "'<br>";
+
+?>
+```
+
+Place this script as e.g. ~/public_html/id.php into your HOME directory and
+make sure that everyone can access this file. A restrictive permission example
+is this:
+
+```
+<user>@tjener:~/public_html$ ls -al
+insgesamt 12
+drwx-----x  2 <user> <primgroup> 4096 19. Jan 20:35 .
+drwx-----x 20 <user> <primgroup> 4096 19. Jan 20:35 ..
+-rw----r--  1 <user> <primgroup>   90 19. Jan 20:35 id.php
+```
+
+Now edit /etc/apache2/mods-available/debian-edu-userdir.conf on TJENER and
+set ``php_admin_flag engine on``.
+
+When opening the URL ``http://www.intern/~<user>/id.php`` it should show this simple web page:
+
+```
+hello, this script runs as user 'www-data '
+```
+
+As enabling the built-in PHP engine (running as user www-data) is
+considered insecure on the Debian Edu main-server (aka TJENER), here
+follows the promised alternative setup.
+
+## Enable PHP CGI with suExec
+
+Install Apache2, PHP, suExec and support for executing pseudo-binaries.
+
+```
+<user>@tjener:~/public_html$ sudo apt-get install apache2-suexec-pristine php-cgi binfmt-support
+```
+
+Configure PHP to run ``.php`` scripts from the shell.
+
+```
+<user>@tjener:~/public_html$ sudo update-binfmts --install PHP /usr/bin/php-cgi --extension php
+```
+
+Enable the necessary suExec Apache module:
+
+```
+<user>@tjener:~/public_html$ sudo a2enmod suexec
+```
+
+Re-configure the ``debian-edu-userdir.conf`` module as follows:
+
+```
+--- a/etc/apache2/mods-available/debian-edu-userdir.conf
++++ b/etc/apache2/mods-available/debian-edu-userdir.conf
+@@ -8,6 +8,12 @@
+                # Read /usr/share/doc/debian-edu-config/README.public_html_with_PHP-CGI.md
+                php_admin_flag engine off
+ 
++               Options +ExecCGI
++               <FilesMatch "\.php$">
++                       SetHandler cgi-script
++                       SetEnv REDIRECT_STATUS 1
++               </FilesMatch>
++
+                AllowOverride FileInfo AuthConfig Limit
+                Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec
+                <Limit GET POST OPTIONS>
+```
+
+Reload the Apache configuration.
+
+```
+<user>@tjener:~/public_html$ sudo /etc/init.d/apache2 force-reload
+```
+
+## User Permissions on userdir PHP files
+
+Finally, userdir PHP scripts in ``~/public_html`` must not be writeable
+by group or others. If otherwise, their execution gets blocked by
+Apache2.
+
+Also, their executable bit must be set.
+
+See example below:
+
+```
+<user>@tjener:~/public_html$ find ~/public_html -name "*.php" -exec chmod 0700 {} \;
+```
+
+This will turn our ``~/public_html`` test directory to:
+
+```
+<user>@tjener:~/public_html$ ls -al
+insgesamt 12
+drwx-----x  2 <user> <primgroup> 4096 19. Jan 20:35 .
+drwx-----x 20 <user> <primgroup> 4096 19. Jan 20:35 ..
+-rwx------  1 <user> <primgroup>   90 19. Jan 20:35 id.php
+
+```


=====================================
debian/NEWS
=====================================
@@ -1,3 +1,19 @@
+debian-edu-config (1.929+deb9u5) stretch-security; urgency=high
+
+    CVE-2021-20001: For mitigating potential privilege escalations that
+    could be caused by malicious PHP scripts in Apache2-accessible user
+    directories (i.e. PHP files placed into ~/public_html) on the Debian
+    Edu mainserver, the PHP engine is now disabled for Apache2 user
+    directories (see /etc/apache2/mods-enabled/debian-edu-userdir.conf).
+
+    However, if PHP functionality is required for Apache2 user directories
+    for educational purposes, an alternative configuration approach is provided
+    in:
+
+    /usr/share/doc/debian-edu-config/README.public_html_with_PHP-CGI+suExec.md
+
+ -- Mike Gabriel <sunweaver at debian.org>  Fri, 04 Feb 2022 12:14:05 +0100
+
 debian-edu-config (1.929+deb9u4) stretch-security; urgency=high
 
     The Kerberos kadm ACLs in /etc/krb5kdc/kadm5.acl contained an insecure


=====================================
debian/changelog
=====================================
@@ -1,3 +1,18 @@
+debian-edu-config (1.929+deb9u5) stretch-security; urgency=medium
+
+  * etc/apache2/mods-available/debian-edu-userdir.conf:
+    - White-space cleanup (tabs and spaces mixed).
+    - CVE-2021-20001: Disable built-in PHP engine.
+    - Add warning to not re-enable PHP interpretation in user dirs (with
+      reference to our README).
+  * README.public_html_with_PHP-CGI+suExec.md:
+    - Provide documentation on how to enable suExec support in https userdirs
+      (i.e. ~/public_html).
+  * debian/NEWS:
+    + Add file, inform about PHP being disabled in Apache2 user directories.
+
+ -- Mike Gabriel <mike.gabriel at das-netzwerkteam.de>  Fri, 11 Feb 2022 16:12:52 +0100
+
 debian-edu-config (1.929+deb9u4) stretch-security; urgency=high
 
   * Security fix for CVE-2019-3467


=====================================
etc/apache2/mods-available/debian-edu-userdir.conf
=====================================
@@ -1,16 +1,18 @@
 <IfModule mod_userdir.c>
-        UserDir public_html
-        UserDir disabled root
+	UserDir public_html
+	UserDir disabled root
 
-        <Directory /skole/tjener/home*/*/public_html>
-                AllowOverride FileInfo AuthConfig Limit
-                Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec
+	<Directory /skole/tjener/home*/*/public_html>
+
+		php_admin_flag engine off
+
+		AllowOverride FileInfo AuthConfig Limit
+		Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec
 		<Limit GET POST OPTIONS>
 			Require all granted
 		</Limit>
 		<LimitExcept GET POST OPTIONS>
 			Require all denied
 		</LimitExcept>
-        </Directory>
+	</Directory>
 </IfModule>
-



View it on GitLab: https://salsa.debian.org/debian-edu/debian-edu-config/-/compare/de13e932de6041e5cce344ce7d47c0a6b53f01ca...f0f843fad5973067f8874dfd1ee7ba34838dd265

-- 
View it on GitLab: https://salsa.debian.org/debian-edu/debian-edu-config/-/compare/de13e932de6041e5cce344ce7d47c0a6b53f01ca...f0f843fad5973067f8874dfd1ee7ba34838dd265
You're receiving this email because of your account on salsa.debian.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/debian-edu-commits/attachments/20220211/70336f13/attachment-0001.htm>


More information about the debian-edu-commits mailing list