secure_tomcat_cis
Version information
This version is compatible with:
- Puppet Enterprise 2019.8.x, 2019.7.x, 2019.5.x, 2019.4.x, 2019.3.x, 2019.2.x, 2019.1.x, 2019.0.x, 2018.1.x, 2017.3.x, 2017.2.x, 2016.4.x
- Puppet >= 4.10.0 < 7.0.0
- ,
Start using this module
Add this module to your Puppetfile:
mod 'fervid-secure_tomcat_cis', '1.0.0'
Learn more about managing modules with a PuppetfileDocumentation
#secure_tomcat
####Table of Contents
- Overview
- Module Description - What the module does and why it is useful
- Setup - The basics of getting started with tomcat
- Usage - Configuration options and additional functionality
- Reference - An under-the-hood peek at what the module is doing and how
- Limitations - OS compatibility, etc.
- Development - Guide for contributing to the module
##Overview
The secure_tomcat module lets you use Puppet to install, deploy, and configure Tomcat web services that meet Security Configuration Benchmark for Apache Tomcat 7.0 standards.
##Module Description
Secure Tomcat wraps the Puppet supported Tomcat module. The types are exactly the same.
The biggest difference is all of the types are passed as a has to the secure_tomcat tomcat class.
What is Covered
Profile Definitions
The following configuration profiles are defined by this Benchmark:
Level 1
Items in this profile intend to:
- be practical and prudent;
- provide a clear security benefit;
- not inhibit the utility of the technology beyond acceptable means.
Level 2
This profile extends the "Level 1" profile. Items in this profile exhibit one or more of the following characteristics:
- are intended for environments or use cases where security is paramount
- acts as defense in depth measure
- may negatively inhibit the utility or performance of the technology
We attempted to cover all Level 1 requirements. Some Level 2 requirements are also implemented.
Control | Enforced | Notes | ||
---|---|---|---|---|
Y | N | N/A | ||
Level 1 | ||||
1 Remove Extraneous Resources | ||||
1.1 Remove extraneous files and directories (Scored) | X | |||
2 Limit Server Platform Information Leaks | ||||
2.5 Disable client facing Stack Traces (Scored) | X | |||
2.6 Turn off TRACE (Scored) | X | |||
3 Protect the Shutdown Port | ||||
3.1 Set a nondeterministic Shutdown command value (Scored) | X | |||
4 Protect Tomcat Configurations | ||||
4.1 Restrict access to $CATALINA_HOME (Scored) | X | |||
4.2 Restrict access to $CATALINA_BASE (Scored) | X | |||
4.3 Restrict access to Tomcat configuration directory (Scored) | X | |||
4.4 Restrict access to Tomcat logs directory (Scored) | X | |||
4.5 Restrict access to Tomcat temp directory (Scored) | X | |||
4.6 Restrict access to Tomcat binaries directory (Scored) | X | |||
4.7 Restrict access to Tomcat web application directory (Scored) | X | |||
4.8 Restrict access to Tomcat catalina.policy (Scored) | X | |||
4.9 Restrict access to Tomcat catalina.properties (Scored) | X | |||
4.10 Restrict access to Tomcat context.xml (Scored) | X | |||
4.11 Restrict access to Tomcat logging.properties (Scored) | X | |||
4.12 Restrict access to Tomcat server.xml (Scored) | X | |||
4.13 Restrict access to Tomcat tomcat-users.xml (Scored) | X | |||
4.14 Restrict access to Tomcat web.xml (Scored) | X | |||
6 Connector Security | ||||
6.2 Ensure SSLEnabled is set to True for Sensitive Connectors (Not Scored) | X | Developer must determine if a connector is sensitive. | ||
6.3 Ensure scheme is set accurately (Scored) | X | Developer must determine if connector is http or https | ||
6.4 Ensure secure is set to true only for SSL-enabled Connectors | ||||
6.5 Ensure SSL Protocol is set to TLS for Secure Connectors (Scored) | X | Developer must determine if a connector is secure. | ||
7. Establish and Protect Logging Facilities | ||||
7.2 Specify file handler in logging.properties files (Scored) | X | |||
7.4 Ensure directory in context.xml is a secure location (Scored) | X | |||
7.5 Ensure pattern in context.xml is correct (Scored) | X | |||
7.6 Ensure directory in logging.properties is a secure location (Scored) | X | |||
8. Configure Catalina Policy | ||||
8.1 Restrict runtime access to sensitive packages (Scored) | X | |||
9. Application Deployment | ||||
9.1 Starting Tomcat with Security Manager (Scored) | X | |||
10 Miscellaneous Configuration Settings | ||||
10.1 Ensure Web content directory is on a separate partition from the Tomcat system files (Not Scored) | X | |||
10.4 Force SSL when accessing the manager application (Scored) | X | Web manager application Is removed. | ||
10.6 Enable strict servlet Compliance (Scored) | X | |||
10.7 Turn off session facade recycling (Scored) | X | |||
10.14 Do not allow symbolic linking (Scored) | X | |||
10.15 Do not run applications as privileged (Scored) | X | |||
10.16 Do not allow cross context requests (Scored) | X | |||
10.18 Enable memory leak listener (Scored) | X | |||
10.19 Setting Security Liftcycle Listener (Scored) | X | |||
10.20 use the logEffectiveWebXml and metadata-complete settings for deploying applications in production (Scored) | X | |||
Level 2 | ||||
1 Remove Extraneous Resources | ||||
1.2 Disable Unused Connectors (Not Scored) | ||||
2 Limit Server Platform Information Leaks | ||||
2.1 Alter the Advertised server.info String (Scored) | ||||
2.2 Alter the Advertised server.number String (Scored) | ||||
2.3 Alter the Advertised server.built Date (Scored) | ||||
2.4 Disable X-Powered-By HTTP Header and Rename the Server Value for all Connectors (Scored) | ||||
3.2 Disable the Shutdown port (Not Scored) | ||||
5 Configure Realms | ||||
5.1 Use secure Realms (Scored) | ||||
5.2 Use LockOut Realms (Scored) | ||||
6 Connector Security | ||||
6.1 Setup Client-cert Authentication (Scored) | ||||
7. Establish and Protect Logging Facilities | ||||
7.1 Application specific logging (Scored) | X | |||
7.3 Ensure className is set correctly in context.xml (Scored) | X | |||
7.7 Configure log file size limit (Scored) | X | |||
9. Application Deployment | ||||
9.2 Disabling auto deployment of applications (Scored) | X | |||
9.3 Disable deploy on startup of applications (Scored) | X | |||
10 Miscellaneous Configuration Settings | ||||
10.2 Restrict access to the web administration (Not Scored) | X | |||
10.3 Restrict manager application (Not Scored) | X | Web manager application Is removed. | ||
10.5 Rename the manager application (Scored) | X | Web manager application Is removed. | ||
10.8 Do not allow additional path delimiters (Scored) | X | |||
10.9 Do not allow custom header status messages (Scored) | X | |||
10.10 Configure connectionTimeout (Scored) | X | |||
10.11 Configure maxHttpHeaderSize (Scored) | X | |||
10.12 Force SSL for all applications (Scored) | X | This requires SSL to be configured; which may not be applicable. | ||
10.17 Do not resolve hosts on logging valves (Scored) | X |
##Setup
###Setup requirements
The secure_tomcat module requires puppetlabs-tomcat version 4.0 or newer. On Puppet Enterprise you must meet this requirement before installing the module. To update stdlib, run:
puppet module upgrade puppetlabs-tomcat
Beginning with tomcat
The simplest way to get Tomcat up and running with the secure_tomcat module is to install the Tomcat source and start the service:
class { '::secure_tomcat':
installs => {
'/opt/tomcat' => {
user => 'tomcat_admin',
group => 'tomcat',
source_url => 'https://www-us.apache.org/dist/tomcat/tomcat-7/v7.0.73/bin/apache-tomcat-7.0.73.tar.gz',
}
},
instances => {
'default' => {
'catalina_base' => '/opt/tomcat',
}
}
}
Note: look up the correct version you want to install on the version list.
Usage
I want to run multiple instances of multiple versions tomcat
class { 'java': }
class { '::secure_tomcat':
installs => {
'/opt/tomcat7_1' => {
user => 'tomcat_admin',
group => 'tomcat',
source_url => 'https://www.apache.org/dist/tomcat/tomcat-7/v7.0.x/bin/apache-tomcat-7.0.x.tar.gz',
},
'/opt/tomcat7_2' => {
user => 'tomcat_admin',
group => 'tomcat',
source_url => 'http://www-eu.apache.org/dist/tomcat/tomcat-7/v7.0.x/bin/apache-tomcat-7.0.x.tar.gz',
},
},
instances => {
'tomcat7_1_1-first' => {
catalina_home => '/opt/tomcat7_1',
catalina_base => '/opt/tomcat7_1/first',
},
'tomcat7_1_2-second' => {
catalina_home => '/opt/tomcat7_1',
catalina_base => '/opt/tomcat7_1/second',
},
'tomcat7_2' => {
'catalina_home' => '/opt/tomcat7_2',
},
},
# Change the default port of the second instance server and HTTP connector
config_servers => {
'tomcat7_1-second' => {
catalina_base => '/opt/tomcat8/second',
port => '8006',
},
# Change tomcat 7_2's server and HTTP/AJP connectors
'tomcat7_2':
catalina_base => '/opt/tomcat7_2',
port => '8105',
},
},
config_server_connectors => {
'tomcat7_1-second-http' => {
catalina_base => '/opt/tomcat8/second',
port => '8081',
protocol => 'HTTP/1.1',
additional_attributes => {
'redirectPort' => '8443',
},
},
'tomcat7_2-http' => {
catalina_base => '/opt/tomcat6',
port => '8180',
protocol => 'HTTP/1.1',
additional_attributes => {
'redirectPort' => '8543',
},
},
'tomcat7_2-ajp' => {
catalina_base => '/opt/tomcat6',
port => '8109',
protocol => 'AJP/1.3',
additional_attributes => {
'redirectPort' => '8543',
},
},
}
}
Note: look up the correct version you want to install on the version list.
I want to deploy WAR files
Add the following to any existing installation with your own war source:
tomcat::war { 'sample.war':
catalina_base => '/opt/tomcat8/first',
war_source => '/opt/tomcat8/webapps/docs/appdev/sample/sample.war',
}
The name of the WAR file must end with '.war'.
The war_source
can be a local path or a puppet:///
, http://
, or ftp://
URL.
I want to remove some configuration
Different configuration defines will allow an ensure parameter to be passed, though the name may vary based on the define.
To remove a connector, for instance, the following configuration ensure that it is absent:
tomcat::config::server::connector { 'tomcat8-jsvc':
connector_ensure => 'absent',
catalina_base => '/opt/tomcat8/first',
port => '8080',
protocol => 'HTTP/1.1',
}
I want to manage a Connector or Realm that already exists
Describe the Realm or HTTP Connector element using tomcat::config::server::realm
or tomcat::config::server::connector
, and set purge_realms
or purge_connectors
to 'true'.
tomcat::config::server::realm { 'org.apache.catalina.realm.LockOutRealm':
realm_ensure => 'present',
purge_realms => true,
}
Puppet removes any existing Connectors or Realms and leaves only the ones you've specified.
##Reference
###Classes
####Public Classes
secure_tomcat
: Main class. Manages some of the defaults for installing and configuring Tomcat.
####Private Classes
secure_tomcat::run_installs'
: Runs all defined installssecure_tomcat::harden_installs'
: Hardens installssecure_tomcat::run_instances'
: Runs all defined instancessecure_tomcat::harden_instances'
: Hardens instancessecure_tomcat::run_wars'
: Runs all defined warssecure_tomcat::deploy_wars'
: Deploys war files into webappssecure_tomcat::configure_wars'
: Preps war files for hardeningsecure_tomcat::harden_wars'
: Hardens web applicationssecure_tomcat::configure'
: Hardens other components of applications
###Parameters
All parameters are optional except where otherwise noted.
####secure_tomcat The base class which manages all installations and resources.
#####instances
Hash of instances to configure. Defaults to empty.
#####wars
Hash of WARS to deploy. Defaults to empty.
#####config_properties_properties
Hash of properties to add to catalina.properties. Defaults to empty.
#####config_servers
Hash of attributes for server elements. Defaults to empty.
#####config_server_connectors
Hash of connector elements. Defaults to empty.
#####config_server_contexts
Hash of server context elements. Defaults to empty.
#####config_server_engines
Hash of server engine elements. Defaults to empty.
#####config_server_globalnamingresources
Hash of server global naming elements. Defaults to empty.
#####config_server_hosts
Hash of server host elements. Defaults to empty.
#####config_server_listeners
Hash of server listner elements. Defaults to empty.
#####config_server_services
Hash of server service elements. Defaults to empty.
#####config_server_tomcat_users
Hash of server role elements. Defaults to empty.
#####config_server_valves
Hash of server valve elements. Defaults to empty.
#####config_contexts
Hash of context attributes. Defaults to empty.
#####config_context_environments
Hash of context environment elements. Defaults to empty.
#####config_context_managers
Hash of context manager elements. Defaults to empty.
#####config_context_resources
Hash of context resource elements. Defaults to empty.
#####config_context_resourcelinks
Hash of context resource link elements. Defaults to empty.
#####use_manager_application
Boolean specifying whether or not to include manager application. Defaults to false.
#####checked_os_users
String listing users who cannot start the tomcat server. Uses comma delimited string. Defaults to root.
#####minimum_umask
String listing the minimum umask the tomcat process can be started as. Defaults to 0007.
##Limitations
This module only supports Tomcat installations on *nix systems. The tomcat::config::server*
defines require Augeas version 1.0.0 or newer.
###Multiple Instances
Some Tomcat packages do not let you install more than one instance. You can avoid this limitation by installing Tomcat from source.
##Development
Puppet Labs modules on the Puppet Forge are open projects, and community contributions are essential for keeping them great. We can't access the huge number of platforms and myriad of hardware, software, and deployment configurations that Puppet is intended to serve.
We want to keep it as easy as possible to contribute changes so that our modules work in your environment. There are a few guidelines that we need contributors to follow so that we can have a chance of keeping on top of things.
For more information, see our module contribution guide.
###Contributors
To see who's already involved, see the list of contributors.
###Running tests
This project contains tests for both rspec-puppet and beaker-rspec to verify functionality. For in-depth information, please see their respective documentation.
Quickstart:
gem install bundler
bundle install
bundle exec rake spec
bundle exec rspec spec/acceptance
RS_DEBUG=yes bundle exec rspec spec/acceptance
2017-03-24 Release 1.0.0
- logging.properties doesn't include '.war' string in prefix
2017-01-27 Release 0.1.14
- logging.properties doesn't include '.war' string in prefix
2017-01-17 Release 0.1.13
- Part of requirement 10.20 must be removed temporarily
2017-01-17 Release 0.1.12
- Chown the war file and deployed app to match tomcat user and group
2017-01-17 Release 0.1.11
- Force web app servlet to be version 3.0
Dependencies
- puppetlabs-tomcat (>= 1.6.0 < 4.0.0)
Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.