Securing your Apache Tomcat installation. Tim Funk November 2009



Similar documents
The Server.xml File. Containers APPENDIX A. The Server Container

Tomcat 5 New Features

JBS-102: Jboss Application Server Administration. Course Length: 4 days

Railo Installation on CentOS Linux 6 Best Practices

Installation Guide for contineo

Still Aren't Doing. Frank Kim

From the Intranet to Mobile. By Divya Mehra and Stian Thorgersen

Programming on the Web(CSC309F) Tutorial: Servlets && Tomcat TA:Wael Aboelsaadat

Host Hardening. Presented by. Douglas Couch & Nathan Heck Security Analysts for ITaP 1

Clustering a Grails Application for Scalability and Availability

Understanding Tomcat Security

Configuring ActiveVOS Identity Service Using LDAP

Apache Tomcat. Load-balancing and Clustering. Mark Thomas, 20 November Pivotal Software, Inc. All rights reserved.

Web Application Security Assessment and Vulnerability Mitigation Tests

<Insert Picture Here> Oracle Web Cache 11g Overview

CHAPTER 1 - JAVA EE OVERVIEW FOR ADMINISTRATORS

Mastering Tomcat Development

JMETER - MONITOR TEST PLAN

24x7 Scheduler Multi-platform Edition 5.2

Thick Client Application Security

Crawl Proxy Installation and Configuration Guide

IBM WebSphere Application Server V8.5 lab Basic Liberty profile administration using the job manager

Intro to Load-Balancing Tomcat with httpd and mod_jk

Addressing Application Layer Attacks with Mod Security

RemotelyAnywhere. Security Considerations

Secure Web Application Coding Team Introductory Meeting December 1, :00 2:00PM Bits & Pieces Room, Sansom West Room 306 Agenda

6WRUP:DWFK. Policies for Dedicated SQL Servers Group

Out of the Fire - Adding Layers of Protection When Deploying Oracle EBS to the Internet

Securing Remote Desktop for Windows XP

6WRUP:DWFK. Policies for Dedicated IIS Web Servers Group. V2.1 policy module to restrict ALL network access

Setting Up B2B Data Exchange for High Availability in an Active/Active Configuration

Oracle WebLogic Server 11g Administration

SonicWALL PCI 1.1 Implementation Guide

Technical White Paper - JBoss Security

BYOD Guidance: BlackBerry Secure Work Space

WEBLOGIC ADMINISTRATION

Web Development on the SOEN 6011 Server

BlackBerry Enterprise Service 10. Secure Work Space for ios and Android Version: Security Note

Java Application Server Guide. For Version 10.3 or Later

VMware vcenter Log Insight Security Guide

W H IT E P A P E R. Salesforce CRM Security Audit Guide

Creating Stronger, Safer, Web Facing Code. JPL IT Security Mary Rivera June 17, 2011

Configuring Apache HTTP Server With Pramati

Kony MobileFabric. Sync Windows Installation Manual - WebSphere. On-Premises. Release 6.5. Document Relevance and Accuracy

Filr 2.0 Administration Guide. April 2016

Scaling Progress OpenEdge Appservers. Syed Irfan Pasha Principal QA Engineer Progress Software

Columbia University Web Security Standards and Practices. Objective and Scope

How to scan/exploit a ssl based webserver. by xxradar. mailto:xxradar@radarhack.com. Version 1.

74% 96 Action Items. Compliance

Network Security Policy

ArcGIS Server Security Threats & Best Practices David Cordes Michael Young

IS L06 Protect Servers and Defend Against APTs with Symantec Critical System Protection

Best Practice - Pentaho and Tomcat Security

LockoutGuard v1.2 Documentation

Advanced Web Security, Lab

Security Guide. BlackBerry Enterprise Service 12. for ios, Android, and Windows Phone. Version 12.0

Basic TCP/IP networking knowledge of client/server concepts Basic Linux commands and desktop navigation (if don't know we will cover it )

Web Intrusion Detection with ModSecurity. Ivan Ristic

Table of Contents. Requirements and Options 1. Checklist for Server Installation 5. Checklist for Importing from CyberAudit

3. Broken Account and Session Management. 4. Cross-Site Scripting (XSS) Flaws. Web browsers execute code sent from websites. Account Management

Discovering passwords in the memory

Web application security

Put a Firewall in Your JVM Securing Java Applications!

Unlocking the Secrets of Alfresco Authentication. Mehdi BELMEKKI,! Consultancy Team! Alfresco!

How To Link Tomcat 5 with IIS 6 on Windows 2003 Server using the JK2 ajp13 connector

Deployment and Monitoring. Pascal Robert MacTI

Ruby on Rails Secure Coding Recommendations

alternative solutions, including: STRONG SECURITY for managing these security concerns. PLATFORM CHOICE LOW TOTAL COST OF OWNERSHIP

Why Should You Care About Security Issues? SySmox WEB security Top seven ColdFusion Security Issues

Tcat Server User s Guide. Version 6 R2 December 2009

SoftNAS Application Guide: In-Flight Encryption 12/7/2015 SOFTNAS LLC

How to break in. Tecniche avanzate di pen testing in ambito Web Application, Internal Network and Social Engineering

What is Web Security? Motivation

MagDiSoft Web Solutions Office No. 102, Bramha Majestic, NIBM Road Kondhwa, Pune Tel: /

WebNow Single Sign-On Solutions

Getting started with OWASP WebGoat 4.0 and SOAPUI.

Is Drupal secure? A high-level perspective on web vulnerabilities, Drupal s solutions, and how to maintain site security

Server Security. Contents. Is Rumpus Secure? 2. Use Care When Creating User Accounts 2. Managing Passwords 3. Watch Out For Aliases 4

Connecting to the Firewall Services Module and Managing the Configuration

INCREASE SYSTEM AVAILABILITY BY LEVERAGING APACHE TOMCAT CLUSTERING

Symantec LiveUpdate Administrator. Getting Started Guide

The Weakest Link: Mitigating Web Application Vulnerabilities. webscurity White Paper. webscurity Inc. Minneapolis, Minnesota USA

Instant Chime for IBM Sametime Installation Guide for Apache Tomcat and Microsoft SQL

Oracle WebLogic Server 11g: Administration Essentials

Product Documentation. Pivotal tc Server. Version 3.x. Getting Started with Pivotal tc Server. Rev: Pivotal Software, Inc.

Robert Honeyman

FINAL DoIT v.8 APPLICATION SECURITY PROCEDURE

NGASI AppServer Manager SaaS/ASP Hosting Automation for Cloud Computing Administrator and User Guide

Web Server Configuration Guide

Implementation of Web Application Firewall

Cúram Deployment Guide for WebSphere Application Server

Table of Contents. Chapter 1: Installing Endpoint Application Control. Chapter 2: Getting Support. Index

Testing New Applications In The DMZ Using VMware ESX. Ivan Dell Era Software Engineer IBM

Host/Platform Security. Module 11

Web Plus Security Features and Recommendations

CA Performance Center

SOLR INSTALLATION & CONFIGURATION GUIDE FOR USE IN THE NTER SYSTEM

FREQUENTLY ASKED QUESTIONS

How To Manage Web Content Management System (Wcm)

Transcription:

Securing your Apache Tomcat installation Tim Funk November 2009

Who am I? Tomcat committer for over 7 years Day job: programmer at Armstrong World Industries.

Why? function search() { var q = document.search.q.value.split(/\w+/); var where = ''; for (i=0;i<q.length;i++) { where+=" OR sku like '%"+q[i]+"%'" where+=" OR name like '%"+q[i]+"%'" where+=" OR descr like '%"+q[i]+"%'" } document.search.extracriteria = where; } ----------------------------------------------- String where = "type=1 and (" + request.getparameter("extracriteria") + ")"; String query = "select * from items where " + where; ResultSet rs = statement.executequery(query);

Based on 6.0.x Background Much applies to 5.5.x and 4.1.x Security: Confidentiality Integrity Availability Usability Need to balance for your environment

Threats seen in the wild Very few Tomcat specific Malicious webapp seen from July 2008 fex*.war Some variants download and execute code Some variants provide (effectively) a shell prompt Infection via insecure manager app What security flaw have been reported? http://tomcat.apache.org/security.html

Other components Tomcat configuration should not be your only line of defence OS Limit Tomcat privileges Limit access to Tomcat's files Minimize impact of a successful attack Firewall In and out

Installation If you don't need it, remove it Web applications docs examples host-manager ( probably ) manager ROOT

Security manager Web applications run in a 'sandbox Prevents System.exit Can limit what files can be accessed Some Tomcat testing is performed with this enabled Configured in catalina.policy

Security manager Do you trust your web applications? Restricts actions of malicious web applications Default policy very likely to break your application Don't use it without testing

server.xml Configuration is reasonably secure by default Discuss options to make it more/less secure Values shown are defaults unless otherwise noted

Comments Configuration server.xml Delete components you aren't using Minimize other comments <Server... /> port= -1 (non-default) disables it shutdown should use strong password <Listener.../> Native (APR) on Solaris is not stable <Executor.../> Nothing to see here

server.xml <GlobalNamingResources.../> Should not be using UserDatabase as primary realm Only used for shared resources Changes will require a Tomcat restart <Service.../> Nothing to see here <Engine.../> Nothing to see here

server.xml <Connector.../> Do you need HTTP and AJP enabled? ( alltodefaults )... = address allowtrace= false maxpostsize= 2097152 onlyparameters maxsavepostsize= 4096 xpoweredby= false server= Server:Apache-Coyote/1.1 server= Microsoft-IIS/5.0 Many more parameters may be set for tuning purposes

server.xml AJP specific request.secret=... shouldbestrongifused ( default ) request.shutdownenabled= false ( default ) request.usesecret= false ( default ) tomcatauthentication= true

<Host.../> autodeploy= false default is true deployonstartup= true Configuration server.xml If both false, only contexts defined in server.xml would be deployed deployxml= true Set to false to ignore META-INF/context.xml errorreportvalveclass Override error pages for all webapps allhandledoesn t in a host. May be helpful when a webapp errors. http://tomcat.apache.org/tomcat-6.0-doc/config/host.html

server.xml / context.xml <Context.../> crosscontext= false privileged= false allowlinking= false Don't change this on a case-insensitive OS This includes Windows usehttponly (default false) casesensitive (default true)

Nested components <Valve.../> Always configure an access log valve Remove/archive old log files Typically, one per host Can be configured at Engine, Host, or Context level e.g.: <Valve classname="org.apache.catalina.valves.accesslogvalve" directory="logs" prefix="localhost_access_log." suffix=".txt" pattern="common" resolvehosts="false" />

Nested components <Valve.../> Use a Remote Address Filter where possible The allow/deny attributes are regular expressions allow is better than deny e.g.: <Valve classname="org.apache.catalina.valves.remoteaddrvalve" </ allow= 127\.0\.0\.1

Nested components <Realm.../> Don't use these in production: Memory Realm UserDatabase Realm JDBC Realm That leaves: DataSource Realm JNDI Realm ( used JAAS Realm (not widely

Nested Components <Realm.../> There is no account lock-out implemented ( eventually ) Brute-force attacks will work May be protected by JNDI service if userpassword is not set Suspected infection method for fex* malicious web application

Nested Components <Realm.../> New for 6.0.19 Combined Realm Realm nesting Use multiple Realms for authentication LockOut Realm Wraps standard realms Locks accounts after multiple failed logins

Nested Components <Realm.../> LockOut Realm example: <Realm classname="org.apache.catalina.realm.lockoutrealm" failurecount="5" lockouttime="300" cachesize="1000" cacheremovalwarningtime="3600"> <Realm classname="org.apache.catalina.realm.datasourcerealm" datasourcename=... /> </Realm>

Nested Components <Loader.../>, <Resources.../>, <Manager.../> entropy= this.tostring() This has been shown to be predictable APR provides real random value randomclass= java.security.securerandom sessionidlength= 16

System Properties org.apache.catalina.connector. RECYCLE_FACADES= false org.apache.catalina.connector. CoyoteAdapter.ALLOW_BACKSLASH= false org.apache.tomcat.util.buf. Udecoder.ALLOW_ENCODED_SLASH= false org.apache.coyote. USE_CUSTOM_STATUS_MSG_IN_HEADER= false STRICT_SERVLET_COMPLIANCE= true

JNDI Resources server.xml or context.xml Why is the password in plain text? Tomcat needs the plain text password to connect to the external resource Encrypting the password means Tomcat would need a decryption key back to the original problem

JNDI Resources What are the risks of a plain text password? Remote information disclosure Is the resource remotely accessible? Local information disclosure If an attacker has console access you probably have bigger issues They can replace any Tomcat code and read the plain text password from memory

JNDI Resources Solutions to the plain text password issue: Enter the password at Tomcat start Needs custom code Password still in memory Tomcat restart requires manual input Encode the password Needs custom code Encoding is not encryption May prevent some accidental disclosures

web.xml Default servlet readonly= true listings= false Invoker servlet Evil bypass security constraints may expose servlets packaged in 3 rd party jars will be removed from 7.x onwards

manager web.xml Manager webapp is just a webapp You can edit web.xml to allow for different roles per action You can disable parts of it Consider adding <transport-guarantee>confidential</transport-guarantee>

manager web.xml Example: Allow reload, but disable install REMOVE <servlet-mapping> <servlet-name>manager</servlet-name> <url-pattern>/install</url-pattern> </servlet-mapping>

manager web.xml Example: Allow reload, but for role installer <security-constraint> <web-resource-collection> <url-pattern>/install</url-pattern> </web-resource-collection> <auth-constraint> <role-name>installer</role-name> </auth-constraint> </security-constraint>

manager webapp Extra lockdown considerations Consider RemoteAddrValve to only allow localhost Then ssh tunnel <Valve classname="org.apache.catalina.valves.remoteaddrvalve" </ allow= 127\.0\.0\.1 ssh -L 80:localhost:80 myserver.net

Monitoring Most monitoring tools also provide management functionality Is the benefit of monitoring worth the risk of exposing the management tools? Options manager LambdaProbe JMX commercial

Monitoring Always configure an access log Always use a Remote Address Filter Configure strong passwords Adm!n, @dmin, @adm!n are not strong passwords

Policy / Procedure / Process Review logs Which logs? Access logs Application logs Tomcat logs What do you do if you find an attempted attack? What do you do if you find a successful attack?

Policy / Procedure / Process Do you monitor Tomcat vulnerability announcements? What do you do if one affects you? Impact will be: configuration change patch upgrade Likely to require a Tomcat restart

Policy / Procedure / Process Avoiding downtime Restart = downtime Using a cluster minimises downtime one httpd instance two Tomcat instances mod_proxy_http / mod_jk / mod_proxy_balancer ( optional ) sticky sessions ( optional ) session replication

File Locations Your webapp When possible put everything in WEB-INF Templates Configuration Anything not directly requested by the browser Precompile your JSP s and do not deploy them When Anything not directly requested by the browser

Your webapp Don t trust the incoming data Be aware of what your parameters should be Be also of what they should not be Have bad incoming data? Try to detect early Return a 404, 400, or 301 as needed mod_security can handle obvious incoming data violations before the request is made to Tomcat See OWASP or {search engine} for the top # web vulnerabilities

Your webapp Configure Error pages CONFIGURE THEM! Otherwise, you will disclose that you are running Tomcat possibly the version and worst of all you may let users see stack traces or JSP code snippets <error-page> <error-code>500</error-code> <location>/web-inf/500.jsp</location> </error-page>

Your webapp Error pages / messages Do not expose stack traces or the message from a Throwable No out.println(e.getmessage()) HTML escape any messaging on the page which was user provided Invalid Zip Code <c:out value= ${param.zip} /> Log your errors. Make sure someone examines them and fixes them, or logs them correctly. Logs full of noise are logs which are not examined clean them up and log correctly.

References / Resources http://www.eu.apachecon.com/presentation/material s/78/2009-03-26-securingapachetomcat.pdf http://code.google.com/p/securetomcat/ http://www.owasp.org/index.php/securing_tomcat http://wiki.apache.org/tomcat/faq/security

Questions