-
-
Notifications
You must be signed in to change notification settings - Fork 389
Hardening: the Apache Alpine Docker Container 2024
CIS Benchmark: https://www.cisecurity.org/benchmark/apache_http_server
Docker Container: https://github.com/coreruleset/modsecurity-crs-docker/
An assessment by @dune73 / Christian Folini in March 2024 revealed the container has not been properly hardened. This page is a work in progress on the work to get this hardening done.
The work and the documentation below happens under the assumption that this is non-commercial use of the CIS Apache 2.4 Benchmark, which is allowed under the license.
Status: UNCLEAR
Evidence:
This depends on the local installation.
The only thing we can sign off is the following:
* Harden the underlying Operating System of the web server, by minimizing
listening network services, applying proper patches and hardening the
configurations as recommended in the appropriate Center for Internet Security
benchmark for the platform.
Plan:
Write a document with the minimal thing we think they need to do here.
Pull Request:
FIXME
Status: PASSED
Evidence:
This is a single use docker container.
Status: PASSED
Evidence:
The Alpine Linux binaries have been used. ModSecurity is being compiled during the build and CRS downloaded from the latest stable tag.
Status: FAIL
Evidence:
There are several additional authentication and authorization modules.
- authn_core_module enabled
- authn_file_module enabled
- authz_groupfile_module enabled
- authz_host_module enabled (unsure if needed)
- authz_user_module (unsure if needed)
Plan:
Remove unnecessary modules. Check the server still comes up.
Pull Request:
FIXME
Status: PASSED
Evidence:
The log_config module is enabled.
Status: PASSED
Evidence:
The WebDav modules are disabled.
Status: FAIL
Evidence:
The status_module is loaded.
Plan:
Limit the status modules to localhost. Talk to CIS Benchmark editor to see if the benchmark can be updated.
Pull Request:
FIXME
Status: FAIL
Evidence:
The autoindex_module is enabled.
Plan:
Disable module.
Pull Request:
FIXME
Status: PASSED
Evidence:
This is a proxy server and the proxy modules are thus enabled.
Status: PASSED
Evidence:
The user directories module is disabled.
Status: PASSED
Evidence:
The info module is disabled.
Status: FAIL
Evidence:
The Auth Basic and the Auth Digest modules are enabled.
Plan:
Disable Auth Basic and Auth Digest modules.
Pull Request:
FIXME
Status: PASSED
Evidence:
The server runs as a non-root user.
Status: PASSED
Evidence:
The Apache user account has an invalid shell.
Status: PASSED
Evidence:
The Apache user account is locked.
Status: FAIL
Evidence:
A lot of files are owned by non existing user 504.
Plan:
Find out the root cause of this problem and fix or assign files to root.
Pull Request:
FIXME
Status: PASSED
Evidence:
All files belong to the root group.
Status: PASSED
Evidence:
None of the files has write access beyond the root group.
Status: PASSED
Evidence:
The core dump directory is not configured.
Status: PASSED
Evidence:
The Mutex is set to default.
Status: PASSED
Evidence:
The PidFile is secured.
Status: PASSED
Evidence:
The ScoreBoardFile directive is not specified.
3.11 L1 Ensure Group Write Access for the Apache Directories and Files Is Properly Restricted (Automated)
Status: PASSED
Evidence:
Write access is limited to the root group.
3.12 L1 Ensure Group Write Access for the Document Root Directories and Files Is Properly Restricted (Automated)
Status: PASSED
Evidence:
Write access is limited to the root group.
3.13 L1 Ensure Access to Special Purpose Application Writable Directories is Properly Restricted (Manual)
Status: PASSED
Evidence:
The special purpose application writeable directories are properly restricted.
drwxr-xr-x 2 www-data root 4096 März 6 17:53 /tmp/modsecurity/data/
drwxr-xr-x 2 www-data root 4096 März 6 17:53 /tmp/modsecurity/tmp/
drwxr-xr-x 2 www-data root 4096 März 6 17:53 /tmp/modsecurity/upload/
drwxrwxr-x 1 root root 4096 Jan 27 00:53 /usr/local/apache2/cgi-bin/
The unwanted cgi-bin folder will be addressed separately.
Status: PASSED
Evidence:
This is configured as required by the Benchmark.
Status: PASSED
Evidence:
This is configured properly and grants access full to the DocumentRoot.
Status: PASSED
Evidence:
This is configured as required by the Benchmark.
Status: PASSED
Evidence:
This is configured as required by the Benchmark.
But 1 "none" is lowercase vs 2 "None"
Plan:
Fix typos.
Pull Request:
FIXME
Status: FAIL
Evidence:
We do Options Indexes FollowSymLinks for DocumentRoot
Plan:
Remove option Indexes and check if container works without FollowSymLinks. If it does not, then use SymLinksIfOwnerMatch.
Pull Request:
FIXME
Status: FAIL
Evidence:
Options Indexes and FollowSymLinks is active for DocumentRoot
Plan:
Remove option Indexes and check if container works without FollowSymLinks. If it does not, then use SymLinksIfOwnerMatch.
Pull Request:
FIXME
Status: PASSED
Evidence:
There is only the cgi-folder and that one has Options None
Status: FAIL
Evidence:
There is the following default content
- index.html
- icons folder
- build folder
- cgi-bin folder
- error folder (extended with includes)
Plan:
Remove:
- index.html
- icons folder
- build folder
- cgi-bin folder
- error folder (extended with includes)
Install simplified error documents. Think about displaying unique-ID on the error page via SSI and think about discreet CRS corporate design.
Pull Request:
FIXME
Status: FAIL
Evidence:
Printenv is present
Plan:
Remove printenv and other CGI content.
Pull Request:
FIXME
Status: FAIL
Evidence:
test-cgi is present
Plan:
Remove test-cgi and other CGI content.
Pull Request:
FIXME
Status: PASSED
Evidence:
HTTP methods restricted via a CRS (this is an alternative to the proposal by CIS)
Status: FAIL
Evidence:
TraceEnable is not set. The default applies, which is "on".
Plan:
Disable TRACE via TraceEnable.
Pull Request:
FIXME
Status: PASSED
Evidence:
Old HTTP protocol versions are disallowed via CRS.
Status: PASSED
Evidence:
Access to these files is forbidden via CRS.
Status: PASSED
Evidence:
Access to these files is forbidden via CRS.
Status: PASSED
Evidence:
Access to these files is forbidden via CRS.
Status: FAIL
Evidence:
CIS recommends an allowlist of permitted file extensions in favor of creating a deny-list.
CRS works with an extensive deny-list.
Plan:
Discuss this in the team. Maybe talk to CIS benchmark editor to see if this is acceptable.
Pull Request:
FIXME
Status: FAIL
Evidence:
CRS has rules to detect this, but the default installation will not raise the anomaly score high enough to block a request.
Plan:
Talk to CIS Benchmark editor to see if this is acceptable.
Pull Request:
FIXME
Status: FAIL
Evidence:
The webserver listens indiscriminatly on all IPs configured for the container.
Plan:
Check if this is possible to restrict for the docker container. If not, talk to CIS benchmark editor to see if this is acceptable.
Pull Request:
FIXME
Status: FAIL
Evidence:
Neither Content-Security-Policy nor X-Frame-Options are configured
Plan:
Provide X-Frame-Options header and also provide a minimal Content-Security-Policy.
Pull Request:
FIXME
Status: FAIL
Evidence:
No Referrer-Policy is defined.
Plan:
Set default Referrer-Policy header.
Pull Request:
FIXME
Status: FAIL
Evidence:
No Permissions-Policy is set appropriately.
Plan:
Set default Permissions-Policy.
Pull Request:
FIXME
Status: FAIL
Evidence:
Loglevel is set twice and it's both on the severity warn and not on LogLevel notice core:info
as CIS recommends.
Plan:
Discuss with team and then ideally set on CIS recommendation.
Pull Request:
FIXME
Status: FAIL
Evidence:
CIS recommends logging the Error-Log together with the system logs via syslog. The CRS docker container centralizes the logs via docker mechanisms. It is questionable whether the CIS advice is really better than what CRS is doing.
Plan:
Discuss with team.
Pull Request:
FIXME
Status: FAIL
Evidence:
The CRS docker container does not take the %h (remote host ip) into consideration, since the TLS endpoint is hardly on the container itself.
Plan:
Review access log format.
Pull Request:
FIXME
Status: UNCLEAR
Evidence:
Since the logs are sent outside the container, their rotation and retention depends on the local setup.
Plan:
Point this out in documentation.
Pull Request:
FIXME
Status: PASSED
Evidence:
CRS typically applies patches very fast. The current version as of this writing is up to date.
Status: PASSED
Evidence:
ModSecurity is compiled during the build process of the container.
Status: PASSED
Evidence:
The latest stable CRS is downloaded during the build process of the container.
Status: PASSED
Evidence:
Mod_ssl is installed and configured.
FIXME: UNSURE
Evidence:
It depends on the local installation. CRS recommends to deploy a valid certificate and replace the default one.
Plan:
Document this properly.
Pull Request:
FIXME
FIXME: UNSURE
Evidence:
It depends on the local installation. CRS recommends to deploy a valid certificate key and replace the default one.
Plan:
Document this properly.
Pull Request:
FIXME
Status: PASSED
Evidence:
The TLSv## 1.0 and TLSv1.1 protocols are disabled.
Status: PASSED
Evidence:
All weak SSL/TLS ciphers are disabled.
Status: PASSED
Evidence:
SSL Renegotiation is not enabled.
Status: PASSED
Evidence:
SSL Compression is not enabled.
Status: PASSED
Evidence:
All medium strength SSL/TLS ciphers are disabled.
Status: FAIL
Evidence:
Redirect is disabled by default.
Plan:
Enable mandatory redirect while keeping exceptions if necessary.
Pull Request:
FIXME
Status: PASSED
Evidence:
OCSP stapling is enabled.
Status: FAIL
Evidence:
HTTP Strict Transport Security is not enabled.
Plan:
Enable STS for host with maxage. Ignore inclusion of subdomains and preload setting, but make it configurable. Document accordingly.
Pull Request:
FIXME
Status: FAIL
Evidence:
The cipher suite supports secure ciphers, but also the non-forward secrecy ciphers TLS_AES_256_GCM_SHA384 and TLS_AES_128_GCM_SHA256.
Plan:
Remove bad ciphers.
Pull Request:
FIXME
Status: PASSED
Evidence:
The configuration sets ServerTokens to full and then uses ModSecurity functionality to set the tokens to "Apache". This is the recommended approach used by ModSecurity.
Status: PASSED
Evidence:
ServerSignature is set to off.
Status: FAIL
Evidence:
Icons, cgi-bin, build, extensive error folder are present.
Plan:
See above 5.4.
Pull Request:
FIXME
Status: PASSED
Evidence:
The FileETag directive is not set, the safe default applies.
Status: FAIL
Evidence:
The Timeout is set to 60 (in 2 redundant instances)
Plan:
Remove redundancy and set timeout to 10.
Pull Request:
FIXME
Status: PASSED
Evidence:
HTTP KeepAlive is enabled.
Status: PASSED
Evidence:
MaxKeepAliveRequests is set to 100.
Status: PASSED
Evidence:
KeepAliveTimeout is set to 5.
Status: PASSED
Evidence:
The desired value for request headers timeout is met.
Status: PASSED
Evidence:
The desired value for request body timeout is met.
Status: FAIL
Evidence:
The LimitRequestLine directive is not set.
Plan:
Set to secure default value and make it configureble.
Pull Request:
FIXME
Status: FAIL
Evidence:
The LimitRequestFields directive is not set.
Plan:
Set to secure default value and make it configureble.
Pull Request:
FIXME
Status: FAIL
Evidence:
The LimitRequestFieldsize directive is not set.
Plan:
Set to secure default value and make it configureble.
Pull Request:
FIXME
Status: FAIL
Evidence:
The LimitRequestBody directive is not set and the ModSecurity SecRequestBodyLimit and SecRequestBodyNoFilesLimit are both set to a higher value
Plan:
Set to secure default value and make it configureble.
Pull Request:
FIXME
Status: FAIL
Evidence:
SELinux is not configured.
Plan:
No plan to introduce SELinux. AppArmor will be enabled instead.
Pull Request:
n.n.
Status: FAIL
Evidence:
SELinux is not configured.
Plan:
No plan to introduce SELinux. AppArmor will be enabled instead.
Pull Request:
n.n.
Status: FAIL
Evidence:
SELinux is not configured.
Plan:
No plan to introduce SELinux. AppArmor will be enabled instead.
Pull Request:
n.n.
Status: FAIL
Evidence:
SELinux is not configured.
Plan:
No plan to introduce SELinux. AppArmor will be enabled instead.
Pull Request:
n.n.
Status: FAIL
Evidence:
AppArmor is not configured.
Plan:
Discuss AppArmor with team and introduce if yes.
Pull Request:
FIXME
Status: FAIL
Evidence:
AppArmor is not configured.
Plan:
See 12.1.
Pull Request:
See 12.1.
Status: FAIL
Evidence:
AppArmor is not configured.
Plan:
See 12.1.
Pull Request:
See 12.1.