4.1 Ensure Access to OS Root Directory Is Denied By Default
Profile Applicability
- Level 1
Description
The Apache Directory directive allows for directory specific configuration of access controls and many other features and options. One important usage is to create a default deny policy that does not allow access to operating system directories and files, except for those specifically allowed. This is done by denying access to the OS root directory.
Rationale
One aspect of Apache, which is occasionally misunderstood, is the feature of default access. That is, unless you take steps to change it, if the server can find its way to a file through normal URL mapping rules, it can and will serve it to clients. Having a default deny is a predominate security principle, and then helps prevent the unintended access, and we do that in this case by denying access to the OS root directory using either of two methods but not both:
- Using the Apache
Denydirective along with anOrderdirective. - Using the Apache
Requiredirective.
Either method is effective. The Order/Deny/Allow combination are now deprecated; they provide three passes where all the directives are processed in the specified order. In contrast, the Require directive works on the first match similar to firewall rules. The Require directive is the default for Apache 2.4 and is demonstrated in the remediation procedure as it may be less likely to be misunderstood.
Audit
Perform the following to determine if the recommended state is implemented:
- Search the Apache configuration files (
httpd.confand any included configuration files) to find a root<Directory>element. - Ensure that either one of the following two methods are configured:
Using the deprecated Order/Deny/Allow method:
- Ensure there is a single
Orderdirective with the value ofdeny, allow - Ensure there is a
Denydirective, and with the value offrom all. - Ensure there are no
AlloworRequiredirectives in the root<Directory>element.
Using the Require method:
- Ensure there is a single
Requiredirective with the value ofall denied - Ensure there are no
AlloworDenydirectives in the root<Directory>element.
The following may be useful in extracting root directory elements from the Apache configuration for auditing.
$ perl -ne 'print if /^ *<Directory */\/i .. /<\/Directory>/i'
$APACHE_PREFIX/conf/httpd.conf
Remediation
Perform the following to implement the recommended state:
- Search the Apache configuration files (
httpd.confand any included configuration files) to find a root<Directory>element. - Add a single
Requiredirective and set the value toall denied - Remove any
DenyandAllowdirectives from the root<Directory>element.
<Directory>
. . .
Require all denied
. . .
</Directory>
Default Value
The following is the default root directory configuration:
<Directory>
. . .
Require all denied
. . .
</Directory>
References
- https://httpd.apache.org/docs/2.4/mod/core.html#directory
- https://httpd.apache.org/docs/2.4/mod/mod_authz_host.html
CIS Controls
Controls Version: v8
- 3.3 Configure Data Access Control Lists
- Configure data access control lists based on a user's need to know. Apply data access control lists, also known as access permissions, to local and remote file systems, databases, and applications.
- IG 1: •
- IG 2: •
- IG 3: •
Controls Version: v7
- 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.
- IG 1: •
- IG 2: •
- IG 3: •
Profile
- Level 1 | Automated