Ensure Appropriate Access to Web Content Is Allowed
Description
In order to serve web content, the Apache Allow directive will need to be used to allow for appropriate access to directories, locations, and virtual hosts that contain web content.
Rationale
The Allow directive may be used within a directory, a location, or other context to allow appropriate access. Access may be allowed to all, or to specific networks, hosts, or users as appropriate.
Impact
None documented
Audit Procedure
Perform the following to determine if the recommended state is implemented:
- Search the Apache configuration files (
httpd.confand any included configuration files) to find all<Directory>elements. - Ensure there is a single
Orderdirective with the value ofDeny, Allowfor each. - Ensure the
AllowandDenydirectives have values that are appropriate for the purposes of the directory.
The following commands may be useful to extract <Directory> and <Location> elements and Allow directives from the apache configuration files.
# perl -ne 'print if /^ *<Directory *\/i .. /<\/Directory/i'
$APACHE_PREFIX/conf/httpd.conf $APACHE_PREFIX/conf.d/*.conf
# perl -ne 'print if /^ *<Location *\/i .. /<\/Location/i'
$APACHE_PREFIX/conf/httpd.conf $APACHE_PREFIX/conf.d/*.conf
# grep -i -C 6 -i 'Allow[[:space:]]*from' $APACHE_PREFIX/conf/httpd.conf
$APACHE_PREFIX/conf.d/*.conf
Remediation
Perform the following to implement the recommended state:
- Search the Apache configuration files (
httpd.confand any included configuration files) to find all<Directory>and<Location>elements. There should be one for the document root and any special purpose directories or locations. There are likely to be other access control directives in other contexts, such as virtual hosts or special elements like<Proxy>. - Add a single
Orderdirective and set the value todeny, allow. - Include the appropriate
AllowandDenydirectives, with values that are appropriate for the purposes of the directory.
The configurations below are just a few possible examples.
<Directory "/var/www/html/">
Order deny,allow
Deny from all
Allow from 192.169.
</Directory>
<Directory "/var/www/html/">
Order allow,deny
Allow from all
</Directory>
<Location /usage>
Order deny,allow
Deny from all
Allow from 127.0.0.1
Allow from ::1
</Location>
Default Value
The following is the default web root directory configuration:
<Directory "/usr/local/apache2/htdocs">
. . .
Order deny,allow
Allow from all
</Directory>
References
- https://httpd.apache.org/docs/2.2/mod/core.html#require
- https://httpd.apache.org/docs/2.2/mod/mod_authz_host.html
- https://httpd.apache.org/docs/2.2/howto/auth.html
CIS Controls
Version 6
14.4 Protect Information With Access Control Lists All information stored on systems shall be protected with file system, network share, claims, application, or database specific access control lists. These controls will enforce the principle that only authorized individuals should have access to the information based on their need to access the information as a part of their responsibilities.
Version 7
14.6 Protect Information through Access Control Lists Protect all information stored on systems with file system, network share, claims, application, or database specific access control lists. These controls will enforce the principle that only authorized individuals should have access to the information based on their need to access the information as a part of their responsibilities.
Profile
Level 1 | Not Scored