<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>https://wiki.owasp.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Dledmonds</id>
		<title>OWASP - User contributions [en]</title>
		<link rel="self" type="application/atom+xml" href="https://wiki.owasp.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Dledmonds"/>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php/Special:Contributions/Dledmonds"/>
		<updated>2026-05-14T10:57:42Z</updated>
		<subtitle>User contributions</subtitle>
		<generator>MediaWiki 1.27.2</generator>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Talk:Securing_tomcat&amp;diff=57390</id>
		<title>Talk:Securing tomcat</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Talk:Securing_tomcat&amp;diff=57390"/>
				<updated>2009-03-26T09:11:39Z</updated>
		
		<summary type="html">&lt;p&gt;Dledmonds: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Newer Tomcat branches ==&lt;br /&gt;
&lt;br /&gt;
This page is hopelessly outdated for anyone working with the Tomcat 6 branch.  We need to figure out the best way to document security measures for the different supported branches.&lt;br /&gt;
[[User:Ken|Ken]] 10:25, 20 March 2009 (UTC)&lt;br /&gt;
&lt;br /&gt;
I've not had call to use Tomcat 6, but in a few months I plan to start experimenting with the embedded version.  I don't mind expanding the article to have a section on 6 (and keep the section on 5.5), but I can't contribute anything just yet.  My preference would be a single article as it will cut down on duplication.  In the meantime, any differences, areas to cover, new features, etc. that others could note down will help speed things up. [[User:Dledmonds|Darren]] 09:11, 26 March 2009 (UTC)&lt;/div&gt;</summary>
		<author><name>Dledmonds</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Talk:Securing_tomcat&amp;diff=26377</id>
		<title>Talk:Securing tomcat</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Talk:Securing_tomcat&amp;diff=26377"/>
				<updated>2008-03-06T20:12:09Z</updated>
		
		<summary type="html">&lt;p&gt;Dledmonds: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==UNIX Permissions==&lt;br /&gt;
&lt;br /&gt;
&amp;gt; Change files in CATALINA_HOME/conf to be readonly (440)&lt;br /&gt;
&lt;br /&gt;
Initially these are 600 (except for tomcat-users.xml which is 644 and Tomcat keeps it that way). Is there a need to make them group-readable?&lt;br /&gt;
&lt;br /&gt;
&amp;gt; Make sure tomcat user has ... write (220 - yes, only write) access to CATALINA_HOME/logs&lt;br /&gt;
&lt;br /&gt;
This doesn't work. I think the best that can be done here is 750 or 700.&lt;br /&gt;
&lt;br /&gt;
[[User:Combatopera|Combatopera]] 15:53, 12 November 2006 (EST)&lt;br /&gt;
&lt;br /&gt;
CATALINA_HOME/conf files updated to recommend chmod 400.  tomcat-user.xml the same as tomcat doesn't write to it.  Original file permissions for all these conf files were 600 when 5.5.20 was unpacked on a debian box.&lt;br /&gt;
&lt;br /&gt;
CATALINA_HOME/logs directory updated to recommend chmod 300.  Prevents tomcat user reading the logs within, but writing works fine for me - again after 5.5.20 was unpacked on a debian box.&lt;br /&gt;
&lt;br /&gt;
[[User:Dledmonds|Darren]] 04:35, 9 January 2007 (EST)&lt;br /&gt;
&lt;br /&gt;
==Replacing Default Error Page==&lt;br /&gt;
Why only restrict the default error page on java.lang.Exception?  The more inclusive java.lang.Throwable would seem to be the better choice, as it would prevent leakage of stack traces in the event of a java.lang.Error.&lt;br /&gt;
&lt;br /&gt;
[[User:Ken|Ken]] 23:07, 21 February 2008 (EST)&lt;br /&gt;
&lt;br /&gt;
Agreed, article updated [[User:Dledmonds|Darren]] 04:49, 22 February 2008 (EST)&lt;/div&gt;</summary>
		<author><name>Dledmonds</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Securing_tomcat&amp;diff=26376</id>
		<title>Securing tomcat</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Securing_tomcat&amp;diff=26376"/>
				<updated>2008-03-06T20:11:17Z</updated>
		
		<summary type="html">&lt;p&gt;Dledmonds: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Status==&lt;br /&gt;
Released 14/1/2007&lt;br /&gt;
&lt;br /&gt;
== Author ==&lt;br /&gt;
Darren Edmonds&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
Most weaknesses in [http://tomcat.apache.org/ Apache Tomcat] come from incorrect or inappropriate configuration.  It is nearly always possible to make Tomcat more secure than the default out of the box installation.  What follows documents best practices and recommendations on securing a production Tomcat server, whether it be hosted on a Windows or Unix based operating system.  ''Please note that the section ordering is not a representation of the section importance.''&lt;br /&gt;
&lt;br /&gt;
== Software Versions ==&lt;br /&gt;
&lt;br /&gt;
The first step is to make sure you are running the latest stable releases of software;&lt;br /&gt;
* Java Runtime Environment (JRE) or SDK&lt;br /&gt;
* Tomcat&lt;br /&gt;
* Third party libraries&lt;br /&gt;
This does not mean you have to upgrade all your production servers to a new (and potentially buggy) release which has just been made available to the public.  What you must do is download the latest stable bugfix release that has continual support.  For the JRE and Tomcat you should be looking at the last digits in the version number (5.5.'''X''') as it represents the bugfix information.  The bugs fixed in these releases are publicly available so if you don't upgrade you could be providing attackers with a very easy route to compromise your server.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Installation of Apache Tomcat 5.5 ==&lt;br /&gt;
&lt;br /&gt;
=== UNIX ===&lt;br /&gt;
&lt;br /&gt;
* Create a tomcat user/group&lt;br /&gt;
* Download and unpack the core distribution (referenced as '''CATALINA_HOME''' from now on)&lt;br /&gt;
* Change '''CATALINA_HOME''' ownership to tomcat user and tomcat group&lt;br /&gt;
* Change files in '''CATALINA_HOME'''/conf to be readonly (400)&lt;br /&gt;
* Make sure tomcat user has read/write access to /tmp and write (300 - yes, only write/execute) access to '''CATALINA_HOME'''/logs&lt;br /&gt;
&lt;br /&gt;
=== Windows ===&lt;br /&gt;
&lt;br /&gt;
* Download the core windows service installer&lt;br /&gt;
* Start the installation, click ''Next'' and ''Agree'' to the licence&lt;br /&gt;
* Untick ''native'', ''documentation'', ''examples'' and ''webapps'' then click ''Next''&lt;br /&gt;
* Choose an installation directory (referenced as '''CATALINA_HOME''' from now on), preferably on a different drive to the OS.  &lt;br /&gt;
* Choose an administrator username (NOT admin) and a secure password that complies with your organisations password policy.&lt;br /&gt;
* Complete tomcat installation, but do not start service.&lt;br /&gt;
&lt;br /&gt;
=== Common ===&lt;br /&gt;
&lt;br /&gt;
* Remove everything from '''CATALINA_HOME'''/webapps (ROOT, balancer, jsp-examples, servlet-examples, tomcat-docs, webdav)&lt;br /&gt;
&lt;br /&gt;
* Remove everything from '''CATALINA_HOME'''/server/webapps (host-manager, manager).  Note that it can be useful to keep the manager webapp installed if you need the ability to redeploy without restarting Tomcat.  If you choose to keep it please read the section on Securing the Manager WebApp.&lt;br /&gt;
&lt;br /&gt;
* Remove '''CATALINA_HOME'''/conf/Catalina/localhost/host-manager.xml and '''CATALINA_HOME'''/conf/Catalina/localhost/manager.xml (again, if you are keeping the manager application, do not remove this).&lt;br /&gt;
&lt;br /&gt;
* Make sure the default servlet is configured '''not''' to serve index pages when a welcome file is not present.  In '''CATALINA_HOME'''/conf/web.xml&lt;br /&gt;
  &amp;lt;servlet&amp;gt;&lt;br /&gt;
    &amp;lt;servlet-name&amp;gt;default&amp;lt;/servlet-name&amp;gt;&lt;br /&gt;
    &amp;lt;servlet-class&amp;gt;org.apache.catalina.servlets.DefaultServlet&amp;lt;/servlet-class&amp;gt;&lt;br /&gt;
    &amp;lt;init-param&amp;gt;&lt;br /&gt;
      &amp;lt;param-name&amp;gt;debug&amp;lt;/param-name&amp;gt;&lt;br /&gt;
      &amp;lt;param-value&amp;gt;0&amp;lt;/param-value&amp;gt;&lt;br /&gt;
    &amp;lt;/init-param&amp;gt;&lt;br /&gt;
    &amp;lt;init-param&amp;gt;&lt;br /&gt;
      &amp;lt;param-name&amp;gt;listings&amp;lt;/param-name&amp;gt;&lt;br /&gt;
      &amp;lt;param-value&amp;gt;'''false'''&amp;lt;/param-value&amp;gt;  &amp;amp;lt;!-- make sure this is false --&amp;amp;gt;&lt;br /&gt;
    &amp;lt;/init-param&amp;gt;&lt;br /&gt;
    &amp;lt;load-on-startup&amp;gt;1&amp;lt;/load-on-startup&amp;gt;&lt;br /&gt;
  &amp;lt;/servlet&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Remove version string from HTTP error messages by repacking '''CATALINA_HOME'''/server/lib/catalina.jar with an updated ServerInfo.properties file.  Note that making this change may prevent [http://www.lambdaprobe.org  Lambda Probe] (popular Tomcat monitoring webapp) to initialise as it cannot determine the Tomcat version.  A solution to this can be found on the [http://www.lambdaprobe.org/forum2/message.jspa?messageID=477 Lambda Probe Forum].&lt;br /&gt;
:unpack catalina.jar&lt;br /&gt;
  cd CATALINA_HOME/server/lib&lt;br /&gt;
  jar xf catalina.jar org/apache/catalina/util/ServerInfo.properties&lt;br /&gt;
:update ServerInfo.properties by changing server.info line to server.info=Apache Tomcat&lt;br /&gt;
:repackage catalina.jar&lt;br /&gt;
  jar uf catalina.jar org/apache/catalina/util/ServerInfo.properties&lt;br /&gt;
:remove CATALINA_HOME/server/lib/org (created when extracting the ServerInfo.properties file)&lt;br /&gt;
&lt;br /&gt;
* Replace default error page (default is stacktrace) by adding the following into '''CATALINA_HOME'''/conf/web.xml.  The default error page shows a full stacktrace which is a disclosure of sensitive information.  Place the following within the ''web-app'' tag (after the ''welcome-file-list'' tag is fine). ''The following solution is not ideal as it produces a blank page because Tomcat cannot find the file specified, but without a better solution this, at least, achieves the desired result.  A well configured web application will override this default in CATALINA_HOME/webapps/APP_NAME/WEB-INF/web.xml so it won't cause problems.''&lt;br /&gt;
  &amp;lt;error-page&amp;gt;&lt;br /&gt;
    &amp;lt;exception-type&amp;gt;java.lang.Throwable&amp;lt;/exception-type&amp;gt;&lt;br /&gt;
    &amp;lt;location&amp;gt;/error.jsp&amp;lt;/location&amp;gt;&lt;br /&gt;
  &amp;lt;/error-page&amp;gt;&lt;br /&gt;
* Rename '''CATALINA_HOME'''/conf/server.xml to '''CATALINA_HOME'''/conf/server-original.xml and rename '''CATALINA_HOME'''/conf/server-minimal.xml to '''CATALINA_HOME'''/conf/server.xml.  The minimal configuration provides the same basic configuration, but without the nested comments is much easier to maintain and understand.  Do not delete the original file as the comments make it useful for reference if you ever need to make changes - e.g. enable SSL.&lt;br /&gt;
&lt;br /&gt;
* Replace the server version string from HTTP headers in server responses, by adding the server keyword in your Connectors in '''CATALINA_HOME'''/conf/server.xml&lt;br /&gt;
  &amp;lt;Connector port=&amp;quot;8080&amp;quot; ...&lt;br /&gt;
             server=&amp;quot;Apache&amp;quot; /&amp;gt;  &amp;amp;lt;!-- server header is now Apache --&amp;amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Start Tomcat, deploy your applications into '''CATALINA_HOME'''/webapps and hope it works!&lt;br /&gt;
&lt;br /&gt;
== Protecting the Shutdown Port ==&lt;br /&gt;
Tomcat uses a port (defaults to 8005) as a shutdown port.  What this means is that to stop all webapps and stop Tomcat cleanly the shutdown scripts make a connection to this port and send the ''shutdown'' command.  This is not as huge a security problem as it may sound considering the connection to the port must be made from the machine running tomcat and the ''shutdown'' command can be changed to something other than the string ''SHUTDOWN''.  However, it's wise to take the following precautions;&lt;br /&gt;
* if you are running a publicly accessible server make sure you prevent external access to the shutdown port by using a suitable firewall.&lt;br /&gt;
* change the shutdown command in '''CATALINA_HOME'''/conf/server.xml and make sure that file is only readable by the tomcat user.&lt;br /&gt;
  &amp;amp;lt;Server port=&amp;quot;8005&amp;quot; shutdown=&amp;quot;ReallyComplexWord&amp;quot;&amp;amp;gt;&lt;br /&gt;
* if this is still a big problem for you then check [http://marc.theaimsgroup.com/?l=tomcat-user&amp;amp;m=104400608619118&amp;amp;w=2 this thread], from the Tomcat mailing list, for alternatives (they all involve code customisation though).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Securing Manager WebApp ==&lt;br /&gt;
&lt;br /&gt;
* By default there are no users with the manager role.  To make use of the manager webapp you need to add a new role and user into the '''CATALINA_HOME'''/conf/tomcat-users.xml file.&lt;br /&gt;
  &amp;lt;role rolename=&amp;quot;manager&amp;quot;/&amp;gt;&lt;br /&gt;
  &amp;lt;user username=&amp;quot;darren&amp;quot; password=&amp;quot;ReallyComplexPassword&amp;quot; roles=&amp;quot;manager&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Using a [http://tomcat.apache.org/tomcat-5.5-doc/config/valve.html valve] to filter by IP or hostname to only allow a subset of machines to connect (i.e. LAN machines).  Add one of the following within the Context tag in '''CATALINA_HOME'''/conf/Catalina/localhost/manager.xml&lt;br /&gt;
  &amp;amp;lt;!-- allow only LAN IPs to connect to the manager webapp --&amp;amp;gt;&lt;br /&gt;
  &amp;amp;lt;!-- contrary to the current Tomcat 5.5 documation the value for '''allow''' is not a regular expression --&amp;amp;gt;&lt;br /&gt;
  &amp;amp;lt;!-- future versions may have to be specified as 192\.168\.1\.* --&amp;amp;gt;&lt;br /&gt;
  &amp;lt;Valve className=&amp;quot;org.apache.catalina.valves.RemoteAddrValve&amp;quot;&lt;br /&gt;
         allow=&amp;quot;192.168.1.*&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  &amp;amp;lt;!-- allow only LAN hosts to connect to the manager webapp --&amp;amp;gt;&lt;br /&gt;
  &amp;amp;lt;!-- contrary to the current Tomcat 5.5 documation the value for '''allow''' is not a regular expression --&amp;amp;gt;&lt;br /&gt;
  &amp;amp;lt;!-- future versions may have to be specified as *\.localdomain\.com --&amp;amp;gt;&lt;br /&gt;
  &amp;lt;Valve className=&amp;quot;org.apache.catalina.valves.RemoteHostValve&amp;quot;&lt;br /&gt;
         allow=&amp;quot;*.localdomain.com&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* You can rename the manager webapp to something else, e.g. ''foobar''&lt;br /&gt;
** Move '''CATALINA_HOME'''/conf/Catalina/localhost/'''manager.xml''' to '''CATALINA_HOME'''/conf/Catalina/localhost/'''foobar.xml'''&lt;br /&gt;
** Update the '''docBase''' attribute within '''CATALINA_HOME'''/conf/Catalina/localhost/'''foobar.xml''' to ${catalina.home}/server/webapps/foobar&lt;br /&gt;
** Move '''CATALINA_HOME'''/server/webapps/'''manager''' to '''CATALINA_HOME'''/server/webapps/'''foobar'''&lt;br /&gt;
&lt;br /&gt;
== Logging ==&lt;br /&gt;
&lt;br /&gt;
As of tomcat 5.5 logging is now handled by the commons-logging framework allowing you to choose your preferred logging implementation - log4j or standard JDK logging.  By default the standard JDK logging is used (or a compatible extension called juli to be more precise), storing daily log files in '''CATALINA_HOME'''/logs.&lt;br /&gt;
&lt;br /&gt;
By default additional webapp log entries are added to '''CATALINA_HOME'''/logs/catalina.YYYY-MM-DD.log and System.out/System.err are redirected to '''CATALINA_HOME'''/logs/catalina.out.  To place webapp log entries in individual log files create a ''logging.properties'' file similar to the following within '''CATALINA_HOME'''/webapps/''APP_NAME''/WEB-INF/classes (change the ''APP_NAME'' value to create a unique file for each webapp)&lt;br /&gt;
&lt;br /&gt;
  handlers = org.apache.juli.FileHandler, java.util.logging.ConsoleHandler&lt;br /&gt;
  org.apache.juli.FileHandler.level = ALL&lt;br /&gt;
  org.apache.juli.FileHandler.directory = ${catalina.base}/logs&lt;br /&gt;
  org.apache.juli.FileHandler.prefix = APP_NAME.&lt;br /&gt;
&lt;br /&gt;
Further details on logging configuration can be found in the [http://tomcat.apache.org/tomcat-5.5-doc/logging.html tomcat logging documentation.]&lt;br /&gt;
&lt;br /&gt;
If you find you get logging output duplicated in catalina.out, you most likely have unnecessary entries for ''java.util.logging.ConsoleHandler'' in your logging configuration file.&lt;br /&gt;
&lt;br /&gt;
== Encryption ==&lt;br /&gt;
&lt;br /&gt;
* SSL for password or other sensitive data exchange (''bordering on application security, not specific to tomcat'')&lt;br /&gt;
* SSL for connections (JDBC, LDAP, etc ..)&lt;br /&gt;
* The Tomcat documentation clearly explains how to [http://tomcat.apache.org/tomcat-5.5-doc/ssl-howto.html enable SSL.]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Java Security ==&lt;br /&gt;
&lt;br /&gt;
=== Running Tomcat with a Security Manager=== &lt;br /&gt;
The default Tomcat configuration provides good protection for most requirements, but does not prevent a malicious application from compromising the security of other applications running in the same instance.  To prevent this sort of attack, Tomcat can be run with a Security Manager enabled which strictly controls access to server resources.&lt;br /&gt;
Tomcat documentation has a good section on [http://tomcat.apache.org/tomcat-5.5-doc/security-manager-howto.html enabling the Security Manager.]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Miscellaneous ==&lt;br /&gt;
&lt;br /&gt;
* [http://tomcat.apache.org/faq/security.html Tomcat Security FAQ]&lt;br /&gt;
&lt;br /&gt;
=== Using Port 80 ===&lt;br /&gt;
&lt;br /&gt;
If you are on a Windows machine you will be able to change the port attribute of the connector within the ''Catalina'' service from 8080 to 80.  This allows you to use tomcat directly to serve all requests.  Depending on your requirements it may not be good enough to serve directly from Tomcat so you may like to consider;&lt;br /&gt;
* Use IIS / Apache running on port 80 and mod_jk to proxy requests to Tomcat&lt;br /&gt;
&lt;br /&gt;
On a UNIX machine only root is allowed to run services on ports below 1024 (kernel recompilation can overcome this).  It is a very bad idea to run Tomcat as root, so the options are (in no particular order);&lt;br /&gt;
* Use Apache running on port 80 and mod_jk (or mod_proxy_ajp) to proxy requests to Tomcat&lt;br /&gt;
* Run Tomcat as root, but in a chroot jail&lt;br /&gt;
* Use a tool like authbind to enable a non root user to bind to ports below 1024&lt;br /&gt;
* Use a port forwarder such as [http://www.netfilter.org/projects/iptables/index.html Iptables] to redirect incoming requests from 8080 to 80.  This has the disadvantage that internal redirects still need to use 8080.&lt;br /&gt;
* Run [http://www.squid-cache.org/ Squid] as a web accelerator in front of Tomcat&lt;br /&gt;
* Use JSVC/procrun&lt;br /&gt;
Each of the above options '''may''' bring extra security concerns which are outside the scope of this document.&lt;br /&gt;
&lt;br /&gt;
=== Cleartext Passwords in CATALINA_HOME/conf/server.xml ===&lt;br /&gt;
&lt;br /&gt;
When configuring a resource, such as a JDBC pool, it is necessary to include clear text username and password in CATALINA_HOME/conf/server.xml  Best practices advice us never to store clear text passwords, but the following paragraphs highlight it is very difficult to avoid.&lt;br /&gt;
&lt;br /&gt;
If one way encryption was used on the password it must be possible for a database connection to be established using a username and encrypted password - so the encrypted password is just as valuable as the clear text one to an attacker.&lt;br /&gt;
&lt;br /&gt;
If two way encryption was used a keyfile is needed which must also live on the filesystem.  To make it more secure a passphase is added to the keyfile which then has to be stored in the configuration as clear text - no improvement.&lt;br /&gt;
&lt;br /&gt;
Encoding is security by obscurity and offers no form of protection (algorithms can be reverse engineered).  What encoding does do is make huge amounts of overhead work - you need to customise Tomcat and the commons digester it uses to parse the config files.  You'd also need a way to create encoded passwords.&lt;br /&gt;
&lt;br /&gt;
In the case of a JDBC pool what you can do is;&lt;br /&gt;
* make sure the database user only has access to the databases and tables they need (also limit rights as necessary).&lt;br /&gt;
* make sure the raw database files are only accessible to the user running the database services (e.g. mysql/postgresql user)&lt;br /&gt;
* make sure the Tomcat configuration files are only accessible to the tomcat user&lt;br /&gt;
&lt;br /&gt;
==Acknowledgements==&lt;br /&gt;
The author would like to thank Kris Easter, Michel Prunet and Stephen More for their valuable input.&lt;br /&gt;
&lt;br /&gt;
[[Category:OWASP Java Project]]&lt;br /&gt;
[[Category:Java]]&lt;/div&gt;</summary>
		<author><name>Dledmonds</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Talk:Securing_tomcat&amp;diff=25764</id>
		<title>Talk:Securing tomcat</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Talk:Securing_tomcat&amp;diff=25764"/>
				<updated>2008-02-22T09:49:11Z</updated>
		
		<summary type="html">&lt;p&gt;Dledmonds: /* Replacing Default Error Page */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;What's the best way to acknowledge the contributions of others as I'd like to add some thanks to Kris Easter, Michel Prunet and Stephen More.  This discussion area?  In brackets after the article link from [https://www.owasp.org/index.php/OWASP_Java_Project_Roadmap#Securing_Popular_J2EE_Servers Java Project Roadmap] ? [[User:Dledmonds|Darren]] 08:58, 27 October 2006 (EDT)&lt;br /&gt;
&lt;br /&gt;
I've added an acknowledgements section to the main page.  [[User:Stephendv|Stephendv]] 11:58, 14 January 2008 (EST)&lt;br /&gt;
&lt;br /&gt;
==UNIX Permissions==&lt;br /&gt;
&lt;br /&gt;
&amp;gt; Change files in CATALINA_HOME/conf to be readonly (440)&lt;br /&gt;
&lt;br /&gt;
Initially these are 600 (except for tomcat-users.xml which is 644 and Tomcat keeps it that way). Is there a need to make them group-readable?&lt;br /&gt;
&lt;br /&gt;
&amp;gt; Make sure tomcat user has ... write (220 - yes, only write) access to CATALINA_HOME/logs&lt;br /&gt;
&lt;br /&gt;
This doesn't work. I think the best that can be done here is 750 or 700.&lt;br /&gt;
&lt;br /&gt;
[[User:Combatopera|Combatopera]] 15:53, 12 November 2006 (EST)&lt;br /&gt;
&lt;br /&gt;
CATALINA_HOME/conf files updated to recommend chmod 400.  tomcat-user.xml the same as tomcat doesn't write to it.  Original file permissions for all these conf files were 600 when 5.5.20 was unpacked on a debian box.&lt;br /&gt;
&lt;br /&gt;
CATALINA_HOME/logs directory updated to recommend chmod 300.  Prevents tomcat user reading the logs within, but writing works fine for me - again after 5.5.20 was unpacked on a debian box.&lt;br /&gt;
&lt;br /&gt;
[[User:Dledmonds|Darren]] 04:35, 9 January 2007 (EST)&lt;br /&gt;
&lt;br /&gt;
==Replacing Default Error Page==&lt;br /&gt;
Why only restrict the default error page on java.lang.Exception?  The more inclusive java.lang.Throwable would seem to be the better choice, as it would prevent leakage of stack traces in the event of a java.lang.Error.&lt;br /&gt;
&lt;br /&gt;
[[User:Ken|Ken]] 23:07, 21 February 2008 (EST)&lt;br /&gt;
&lt;br /&gt;
Agreed, article updated [[User:Dledmonds|Darren]] 04:49, 22 February 2008 (EST)&lt;/div&gt;</summary>
		<author><name>Dledmonds</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Securing_tomcat&amp;diff=25763</id>
		<title>Securing tomcat</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Securing_tomcat&amp;diff=25763"/>
				<updated>2008-02-22T09:47:55Z</updated>
		
		<summary type="html">&lt;p&gt;Dledmonds: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Status==&lt;br /&gt;
Released 14/1/2007&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
Most weaknesses in [http://tomcat.apache.org/ Apache Tomcat] come from incorrect or inappropriate configuration.  It is nearly always possible to make Tomcat more secure than the default out of the box installation.  What follows documents best practices and recommendations on securing a production Tomcat server, whether it be hosted on a Windows or Unix based operating system.  ''Please note that the section ordering is not a representation of the section importance.''&lt;br /&gt;
&lt;br /&gt;
== Software Versions ==&lt;br /&gt;
&lt;br /&gt;
The first step is to make sure you are running the latest stable releases of software;&lt;br /&gt;
* Java Runtime Environment (JRE) or SDK&lt;br /&gt;
* Tomcat&lt;br /&gt;
* Third party libraries&lt;br /&gt;
This does not mean you have to upgrade all your production servers to a new (and potentially buggy) release which has just been made available to the public.  What you must do is download the latest stable bugfix release that has continual support.  For the JRE and Tomcat you should be looking at the last digits in the version number (5.5.'''X''') as it represents the bugfix information.  The bugs fixed in these releases are publicly available so if you don't upgrade you could be providing attackers with a very easy route to compromise your server.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Installation of Apache Tomcat 5.5 ==&lt;br /&gt;
&lt;br /&gt;
=== UNIX ===&lt;br /&gt;
&lt;br /&gt;
* Create a tomcat user/group&lt;br /&gt;
* Download and unpack the core distribution (referenced as '''CATALINA_HOME''' from now on)&lt;br /&gt;
* Change '''CATALINA_HOME''' ownership to tomcat user and tomcat group&lt;br /&gt;
* Change files in '''CATALINA_HOME'''/conf to be readonly (400)&lt;br /&gt;
* Make sure tomcat user has read/write access to /tmp and write (300 - yes, only write/execute) access to '''CATALINA_HOME'''/logs&lt;br /&gt;
&lt;br /&gt;
=== Windows ===&lt;br /&gt;
&lt;br /&gt;
* Download the core windows service installer&lt;br /&gt;
* Start the installation, click ''Next'' and ''Agree'' to the licence&lt;br /&gt;
* Untick ''native'', ''documentation'', ''examples'' and ''webapps'' then click ''Next''&lt;br /&gt;
* Choose an installation directory (referenced as '''CATALINA_HOME''' from now on), preferably on a different drive to the OS.  &lt;br /&gt;
* Choose an administrator username (NOT admin) and a secure password that complies with your organisations password policy.&lt;br /&gt;
* Complete tomcat installation, but do not start service.&lt;br /&gt;
&lt;br /&gt;
=== Common ===&lt;br /&gt;
&lt;br /&gt;
* Remove everything from '''CATALINA_HOME'''/webapps (ROOT, balancer, jsp-examples, servlet-examples, tomcat-docs, webdav)&lt;br /&gt;
&lt;br /&gt;
* Remove everything from '''CATALINA_HOME'''/server/webapps (host-manager, manager).  Note that it can be useful to keep the manager webapp installed if you need the ability to redeploy without restarting Tomcat.  If you choose to keep it please read the section on Securing the Manager WebApp.&lt;br /&gt;
&lt;br /&gt;
* Remove '''CATALINA_HOME'''/conf/Catalina/localhost/host-manager.xml and '''CATALINA_HOME'''/conf/Catalina/localhost/manager.xml (again, if you are keeping the manager application, do not remove this).&lt;br /&gt;
&lt;br /&gt;
* Make sure the default servlet is configured '''not''' to serve index pages when a welcome file is not present.  In '''CATALINA_HOME'''/conf/web.xml&lt;br /&gt;
  &amp;lt;servlet&amp;gt;&lt;br /&gt;
    &amp;lt;servlet-name&amp;gt;default&amp;lt;/servlet-name&amp;gt;&lt;br /&gt;
    &amp;lt;servlet-class&amp;gt;org.apache.catalina.servlets.DefaultServlet&amp;lt;/servlet-class&amp;gt;&lt;br /&gt;
    &amp;lt;init-param&amp;gt;&lt;br /&gt;
      &amp;lt;param-name&amp;gt;debug&amp;lt;/param-name&amp;gt;&lt;br /&gt;
      &amp;lt;param-value&amp;gt;0&amp;lt;/param-value&amp;gt;&lt;br /&gt;
    &amp;lt;/init-param&amp;gt;&lt;br /&gt;
    &amp;lt;init-param&amp;gt;&lt;br /&gt;
      &amp;lt;param-name&amp;gt;listings&amp;lt;/param-name&amp;gt;&lt;br /&gt;
      &amp;lt;param-value&amp;gt;'''false'''&amp;lt;/param-value&amp;gt;  &amp;amp;lt;!-- make sure this is false --&amp;amp;gt;&lt;br /&gt;
    &amp;lt;/init-param&amp;gt;&lt;br /&gt;
    &amp;lt;load-on-startup&amp;gt;1&amp;lt;/load-on-startup&amp;gt;&lt;br /&gt;
  &amp;lt;/servlet&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Remove version string from HTTP error messages by repacking '''CATALINA_HOME'''/server/lib/catalina.jar with an updated ServerInfo.properties file.  Note that making this change may prevent [http://www.lambdaprobe.org  Lambda Probe] (popular Tomcat monitoring webapp) to initialise as it cannot determine the Tomcat version.  A solution to this can be found on the [http://www.lambdaprobe.org/forum2/message.jspa?messageID=477 Lambda Probe Forum].&lt;br /&gt;
:unpack catalina.jar&lt;br /&gt;
  cd CATALINA_HOME/server/lib&lt;br /&gt;
  jar xf catalina.jar org/apache/catalina/util/ServerInfo.properties&lt;br /&gt;
:update ServerInfo.properties by changing server.info line to server.info=Apache Tomcat&lt;br /&gt;
:repackage catalina.jar&lt;br /&gt;
  jar uf catalina.jar org/apache/catalina/util/ServerInfo.properties&lt;br /&gt;
:remove CATALINA_HOME/server/lib/org (created when extracting the ServerInfo.properties file)&lt;br /&gt;
&lt;br /&gt;
* Replace default error page (default is stacktrace) by adding the following into '''CATALINA_HOME'''/conf/web.xml.  The default error page shows a full stacktrace which is a disclosure of sensitive information.  Place the following within the ''web-app'' tag (after the ''welcome-file-list'' tag is fine). ''The following solution is not ideal as it produces a blank page because Tomcat cannot find the file specified, but without a better solution this, at least, achieves the desired result.  A well configured web application will override this default in CATALINA_HOME/webapps/APP_NAME/WEB-INF/web.xml so it won't cause problems.''&lt;br /&gt;
  &amp;lt;error-page&amp;gt;&lt;br /&gt;
    &amp;lt;exception-type&amp;gt;java.lang.Throwable&amp;lt;/exception-type&amp;gt;&lt;br /&gt;
    &amp;lt;location&amp;gt;/error.jsp&amp;lt;/location&amp;gt;&lt;br /&gt;
  &amp;lt;/error-page&amp;gt;&lt;br /&gt;
* Rename '''CATALINA_HOME'''/conf/server.xml to '''CATALINA_HOME'''/conf/server-original.xml and rename '''CATALINA_HOME'''/conf/server-minimal.xml to '''CATALINA_HOME'''/conf/server.xml.  The minimal configuration provides the same basic configuration, but without the nested comments is much easier to maintain and understand.  Do not delete the original file as the comments make it useful for reference if you ever need to make changes - e.g. enable SSL.&lt;br /&gt;
&lt;br /&gt;
* Replace the server version string from HTTP headers in server responses, by adding the server keyword in your Connectors in '''CATALINA_HOME'''/conf/server.xml&lt;br /&gt;
  &amp;lt;Connector port=&amp;quot;8080&amp;quot; ...&lt;br /&gt;
             server=&amp;quot;Apache&amp;quot; /&amp;gt;  &amp;amp;lt;!-- server header is now Apache --&amp;amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Start Tomcat, deploy your applications into '''CATALINA_HOME'''/webapps and hope it works!&lt;br /&gt;
&lt;br /&gt;
== Protecting the Shutdown Port ==&lt;br /&gt;
Tomcat uses a port (defaults to 8005) as a shutdown port.  What this means is that to stop all webapps and stop Tomcat cleanly the shutdown scripts make a connection to this port and send the ''shutdown'' command.  This is not as huge a security problem as it may sound considering the connection to the port must be made from the machine running tomcat and the ''shutdown'' command can be changed to something other than the string ''SHUTDOWN''.  However, it's wise to take the following precautions;&lt;br /&gt;
* if you are running a publicly accessible server make sure you prevent external access to the shutdown port by using a suitable firewall.&lt;br /&gt;
* change the shutdown command in '''CATALINA_HOME'''/conf/server.xml and make sure that file is only readable by the tomcat user.&lt;br /&gt;
  &amp;amp;lt;Server port=&amp;quot;8005&amp;quot; shutdown=&amp;quot;ReallyComplexWord&amp;quot;&amp;amp;gt;&lt;br /&gt;
* if this is still a big problem for you then check [http://marc.theaimsgroup.com/?l=tomcat-user&amp;amp;m=104400608619118&amp;amp;w=2 this thread], from the Tomcat mailing list, for alternatives (they all involve code customisation though).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Securing Manager WebApp ==&lt;br /&gt;
&lt;br /&gt;
* By default there are no users with the manager role.  To make use of the manager webapp you need to add a new role and user into the '''CATALINA_HOME'''/conf/tomcat-users.xml file.&lt;br /&gt;
  &amp;lt;role rolename=&amp;quot;manager&amp;quot;/&amp;gt;&lt;br /&gt;
  &amp;lt;user username=&amp;quot;darren&amp;quot; password=&amp;quot;ReallyComplexPassword&amp;quot; roles=&amp;quot;manager&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Using a [http://tomcat.apache.org/tomcat-5.5-doc/config/valve.html valve] to filter by IP or hostname to only allow a subset of machines to connect (i.e. LAN machines).  Add one of the following within the Context tag in '''CATALINA_HOME'''/conf/Catalina/localhost/manager.xml&lt;br /&gt;
  &amp;amp;lt;!-- allow only LAN IPs to connect to the manager webapp --&amp;amp;gt;&lt;br /&gt;
  &amp;amp;lt;!-- contrary to the current Tomcat 5.5 documation the value for '''allow''' is not a regular expression --&amp;amp;gt;&lt;br /&gt;
  &amp;amp;lt;!-- future versions may have to be specified as 192\.168\.1\.* --&amp;amp;gt;&lt;br /&gt;
  &amp;lt;Valve className=&amp;quot;org.apache.catalina.valves.RemoteAddrValve&amp;quot;&lt;br /&gt;
         allow=&amp;quot;192.168.1.*&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  &amp;amp;lt;!-- allow only LAN hosts to connect to the manager webapp --&amp;amp;gt;&lt;br /&gt;
  &amp;amp;lt;!-- contrary to the current Tomcat 5.5 documation the value for '''allow''' is not a regular expression --&amp;amp;gt;&lt;br /&gt;
  &amp;amp;lt;!-- future versions may have to be specified as *\.localdomain\.com --&amp;amp;gt;&lt;br /&gt;
  &amp;lt;Valve className=&amp;quot;org.apache.catalina.valves.RemoteHostValve&amp;quot;&lt;br /&gt;
         allow=&amp;quot;*.localdomain.com&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* You can rename the manager webapp to something else, e.g. ''foobar''&lt;br /&gt;
** Move '''CATALINA_HOME'''/conf/Catalina/localhost/'''manager.xml''' to '''CATALINA_HOME'''/conf/Catalina/localhost/'''foobar.xml'''&lt;br /&gt;
** Update the '''docBase''' attribute within '''CATALINA_HOME'''/conf/Catalina/localhost/'''foobar.xml''' to ${catalina.home}/server/webapps/foobar&lt;br /&gt;
** Move '''CATALINA_HOME'''/server/webapps/'''manager''' to '''CATALINA_HOME'''/server/webapps/'''foobar'''&lt;br /&gt;
&lt;br /&gt;
== Logging ==&lt;br /&gt;
&lt;br /&gt;
As of tomcat 5.5 logging is now handled by the commons-logging framework allowing you to choose your preferred logging implementation - log4j or standard JDK logging.  By default the standard JDK logging is used (or a compatible extension called juli to be more precise), storing daily log files in '''CATALINA_HOME'''/logs.&lt;br /&gt;
&lt;br /&gt;
By default additional webapp log entries are added to '''CATALINA_HOME'''/logs/catalina.YYYY-MM-DD.log and System.out/System.err are redirected to '''CATALINA_HOME'''/logs/catalina.out.  To place webapp log entries in individual log files create a ''logging.properties'' file similar to the following within '''CATALINA_HOME'''/webapps/''APP_NAME''/WEB-INF/classes (change the ''APP_NAME'' value to create a unique file for each webapp)&lt;br /&gt;
&lt;br /&gt;
  handlers = org.apache.juli.FileHandler, java.util.logging.ConsoleHandler&lt;br /&gt;
  org.apache.juli.FileHandler.level = ALL&lt;br /&gt;
  org.apache.juli.FileHandler.directory = ${catalina.base}/logs&lt;br /&gt;
  org.apache.juli.FileHandler.prefix = APP_NAME.&lt;br /&gt;
&lt;br /&gt;
Further details on logging configuration can be found in the [http://tomcat.apache.org/tomcat-5.5-doc/logging.html tomcat logging documentation.]&lt;br /&gt;
&lt;br /&gt;
If you find you get logging output duplicated in catalina.out, you most likely have unnecessary entries for ''java.util.logging.ConsoleHandler'' in your logging configuration file.&lt;br /&gt;
&lt;br /&gt;
== Encryption ==&lt;br /&gt;
&lt;br /&gt;
* SSL for password or other sensitive data exchange (''bordering on application security, not specific to tomcat'')&lt;br /&gt;
* SSL for connections (JDBC, LDAP, etc ..)&lt;br /&gt;
* The Tomcat documentation clearly explains how to [http://tomcat.apache.org/tomcat-5.5-doc/ssl-howto.html enable SSL.]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Java Security ==&lt;br /&gt;
&lt;br /&gt;
=== Running Tomcat with a Security Manager=== &lt;br /&gt;
The default Tomcat configuration provides good protection for most requirements, but does not prevent a malicious application from compromising the security of other applications running in the same instance.  To prevent this sort of attack, Tomcat can be run with a Security Manager enabled which strictly controls access to server resources.&lt;br /&gt;
Tomcat documentation has a good section on [http://tomcat.apache.org/tomcat-5.5-doc/security-manager-howto.html enabling the Security Manager.]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Miscellaneous ==&lt;br /&gt;
&lt;br /&gt;
* [http://tomcat.apache.org/faq/security.html Tomcat Security FAQ]&lt;br /&gt;
&lt;br /&gt;
=== Using Port 80 ===&lt;br /&gt;
&lt;br /&gt;
If you are on a Windows machine you will be able to change the port attribute of the connector within the ''Catalina'' service from 8080 to 80.  This allows you to use tomcat directly to serve all requests.  Depending on your requirements it may not be good enough to serve directly from Tomcat so you may like to consider;&lt;br /&gt;
* Use IIS / Apache running on port 80 and mod_jk to proxy requests to Tomcat&lt;br /&gt;
&lt;br /&gt;
On a UNIX machine only root is allowed to run services on ports below 1024 (kernel recompilation can overcome this).  It is a very bad idea to run Tomcat as root, so the options are (in no particular order);&lt;br /&gt;
* Use Apache running on port 80 and mod_jk (or mod_proxy_ajp) to proxy requests to Tomcat&lt;br /&gt;
* Run Tomcat as root, but in a chroot jail&lt;br /&gt;
* Use a tool like authbind to enable a non root user to bind to ports below 1024&lt;br /&gt;
* Use a port forwarder such as [http://www.netfilter.org/projects/iptables/index.html Iptables] to redirect incoming requests from 8080 to 80.  This has the disadvantage that internal redirects still need to use 8080.&lt;br /&gt;
* Run [http://www.squid-cache.org/ Squid] as a web accelerator in front of Tomcat&lt;br /&gt;
* Use JSVC/procrun&lt;br /&gt;
Each of the above options '''may''' bring extra security concerns which are outside the scope of this document.&lt;br /&gt;
&lt;br /&gt;
=== Cleartext Passwords in CATALINA_HOME/conf/server.xml ===&lt;br /&gt;
&lt;br /&gt;
When configuring a resource, such as a JDBC pool, it is necessary to include clear text username and password in CATALINA_HOME/conf/server.xml  Best practices advice us never to store clear text passwords, but the following paragraphs highlight it is very difficult to avoid.&lt;br /&gt;
&lt;br /&gt;
If one way encryption was used on the password it must be possible for a database connection to be established using a username and encrypted password - so the encrypted password is just as valuable as the clear text one to an attacker.&lt;br /&gt;
&lt;br /&gt;
If two way encryption was used a keyfile is needed which must also live on the filesystem.  To make it more secure a passphase is added to the keyfile which then has to be stored in the configuration as clear text - no improvement.&lt;br /&gt;
&lt;br /&gt;
Encoding is security by obscurity and offers no form of protection (algorithms can be reverse engineered).  What encoding does do is make huge amounts of overhead work - you need to customise Tomcat and the commons digester it uses to parse the config files.  You'd also need a way to create encoded passwords.&lt;br /&gt;
&lt;br /&gt;
In the case of a JDBC pool what you can do is;&lt;br /&gt;
* make sure the database user only has access to the databases and tables they need (also limit rights as necessary).&lt;br /&gt;
* make sure the raw database files are only accessible to the user running the database services (e.g. mysql/postgresql user)&lt;br /&gt;
* make sure the Tomcat configuration files are only accessible to the tomcat user&lt;br /&gt;
&lt;br /&gt;
==Acknowledgements==&lt;br /&gt;
The author would like to thank Kris Easter, Michel Prunet and Stephen More for their valuable input.&lt;br /&gt;
&lt;br /&gt;
[[Category:OWASP Java Project]]&lt;br /&gt;
[[Category:Java]]&lt;/div&gt;</summary>
		<author><name>Dledmonds</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Securing_tomcat&amp;diff=24369</id>
		<title>Securing tomcat</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Securing_tomcat&amp;diff=24369"/>
				<updated>2008-01-11T11:20:59Z</updated>
		
		<summary type="html">&lt;p&gt;Dledmonds: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
Most weaknesses in [http://tomcat.apache.org/ Apache Tomcat] come from incorrect or inappropriate configuration.  It is nearly always possible to make Tomcat more secure than the default out of the box installation.  What follows documents best practices and recommendations on securing a production Tomcat server, whether it be hosted on a Windows or Unix based operating system.  ''Please note that the section ordering is not a representation of the section importance.''&lt;br /&gt;
&lt;br /&gt;
== Software Versions ==&lt;br /&gt;
&lt;br /&gt;
The first step is to make sure you are running the latest stable releases of software;&lt;br /&gt;
* Java Runtime Environment (JRE) or SDK&lt;br /&gt;
* Tomcat&lt;br /&gt;
* Third party libraries&lt;br /&gt;
This does not mean you have to upgrade all your production servers to a new (and potentially buggy) release which has just been made available to the public.  What you must do is download the latest stable bugfix release that has continual support.  For the JRE and Tomcat you should be looking at the last digits in the version number (5.5.'''X''') as it represents the bugfix information.  The bugs fixed in these releases are publicly available so if you don't upgrade you could be providing attackers with a very easy route to compromise your server.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Installation of Apache Tomcat 5.5 ==&lt;br /&gt;
&lt;br /&gt;
=== UNIX ===&lt;br /&gt;
&lt;br /&gt;
* Create a tomcat user/group&lt;br /&gt;
* Download and unpack the core distribution (referenced as '''CATALINA_HOME''' from now on)&lt;br /&gt;
* Change '''CATALINA_HOME''' ownership to tomcat user and tomcat group&lt;br /&gt;
* Change files in '''CATALINA_HOME'''/conf to be readonly (400)&lt;br /&gt;
* Make sure tomcat user has read/write access to /tmp and write (300 - yes, only write/execute) access to '''CATALINA_HOME'''/logs&lt;br /&gt;
&lt;br /&gt;
=== Windows ===&lt;br /&gt;
&lt;br /&gt;
* Download the core windows service installer&lt;br /&gt;
* Start the installation, click ''Next'' and ''Agree'' to the licence&lt;br /&gt;
* Untick ''native'', ''documentation'', ''examples'' and ''webapps'' then click ''Next''&lt;br /&gt;
* Choose an installation directory (referenced as '''CATALINA_HOME''' from now on), preferably on a different drive to the OS.  &lt;br /&gt;
* Choose an administrator username (NOT admin) and a secure password that complies with your organisations password policy.&lt;br /&gt;
* Complete tomcat installation, but do not start service.&lt;br /&gt;
&lt;br /&gt;
=== Common ===&lt;br /&gt;
&lt;br /&gt;
* Remove everything from '''CATALINA_HOME'''/webapps (ROOT, balancer, jsp-examples, servlet-examples, tomcat-docs, webdav)&lt;br /&gt;
&lt;br /&gt;
* Remove everything from '''CATALINA_HOME'''/server/webapps (host-manager, manager).  Note that it can be useful to keep the manager webapp installed if you need the ability to redeploy without restarting Tomcat.  If you choose to keep it please read the section on Securing the Manager WebApp.&lt;br /&gt;
&lt;br /&gt;
* Remove '''CATALINA_HOME'''/conf/Catalina/localhost/host-manager.xml and '''CATALINA_HOME'''/conf/Catalina/localhost/manager.xml (again, if you are keeping the manager application, do not remove this).&lt;br /&gt;
&lt;br /&gt;
* Make sure the default servlet is configured '''not''' to serve index pages when a welcome file is not present.  In '''CATALINA_HOME'''/conf/web.xml&lt;br /&gt;
  &amp;lt;servlet&amp;gt;&lt;br /&gt;
    &amp;lt;servlet-name&amp;gt;default&amp;lt;/servlet-name&amp;gt;&lt;br /&gt;
    &amp;lt;servlet-class&amp;gt;org.apache.catalina.servlets.DefaultServlet&amp;lt;/servlet-class&amp;gt;&lt;br /&gt;
    &amp;lt;init-param&amp;gt;&lt;br /&gt;
      &amp;lt;param-name&amp;gt;debug&amp;lt;/param-name&amp;gt;&lt;br /&gt;
      &amp;lt;param-value&amp;gt;0&amp;lt;/param-value&amp;gt;&lt;br /&gt;
    &amp;lt;/init-param&amp;gt;&lt;br /&gt;
    &amp;lt;init-param&amp;gt;&lt;br /&gt;
      &amp;lt;param-name&amp;gt;listings&amp;lt;/param-name&amp;gt;&lt;br /&gt;
      &amp;lt;param-value&amp;gt;'''false'''&amp;lt;/param-value&amp;gt;  &amp;amp;lt;!-- make sure this is false --&amp;amp;gt;&lt;br /&gt;
    &amp;lt;/init-param&amp;gt;&lt;br /&gt;
    &amp;lt;load-on-startup&amp;gt;1&amp;lt;/load-on-startup&amp;gt;&lt;br /&gt;
  &amp;lt;/servlet&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Remove version string from HTTP error messages by repacking '''CATALINA_HOME'''/server/lib/catalina.jar with an updated ServerInfo.properties file.  Note that making this change may prevent [http://www.lambdaprobe.org  Lambda Probe] (popular Tomcat monitoring webapp) to initialise as it cannot determine the Tomcat version.  A solution to this can be found on the [http://www.lambdaprobe.org/forum2/message.jspa?messageID=477 Lambda Probe Forum].&lt;br /&gt;
:unpack catalina.jar&lt;br /&gt;
  cd CATALINA_HOME/server/lib&lt;br /&gt;
  jar xf catalina.jar org/apache/catalina/util/ServerInfo.properties&lt;br /&gt;
:update ServerInfo.properties by changing server.info line to server.info=Apache Tomcat&lt;br /&gt;
:repackage catalina.jar&lt;br /&gt;
  jar uf catalina.jar org/apache/catalina/util/ServerInfo.properties&lt;br /&gt;
:remove CATALINA_HOME/server/lib/org (created when extracting the ServerInfo.properties file)&lt;br /&gt;
&lt;br /&gt;
* Replace default error page (default is stacktrace) by adding the following into '''CATALINA_HOME'''/conf/web.xml.  The default error page shows a full stacktrace which is a disclosure of sensitive information.  Place the following within the ''web-app'' tag (after the ''welcome-file-list'' tag is fine). ''The following solution is not ideal as it produces a blank page because Tomcat cannot find the file specified, but without a better solution this, at least, achieves the desired result.  A well configured web application will override this default in CATALINA_HOME/webapps/APP_NAME/WEB-INF/web.xml so it won't cause problems.''&lt;br /&gt;
  &amp;lt;error-page&amp;gt;&lt;br /&gt;
    &amp;lt;exception-type&amp;gt;java.lang.Exception&amp;lt;/exception-type&amp;gt;&lt;br /&gt;
    &amp;lt;location&amp;gt;/error.jsp&amp;lt;/location&amp;gt;&lt;br /&gt;
  &amp;lt;/error-page&amp;gt;&lt;br /&gt;
* Rename '''CATALINA_HOME'''/conf/server.xml to '''CATALINA_HOME'''/conf/server-original.xml and rename '''CATALINA_HOME'''/conf/server-minimal.xml to '''CATALINA_HOME'''/conf/server.xml.  The minimal configuration provides the same basic configuration, but without the nested comments is much easier to maintain and understand.  Do not delete the original file as the comments make it useful for reference if you ever need to make changes - e.g. enable SSL.&lt;br /&gt;
&lt;br /&gt;
* Replace the server version string from HTTP headers in server responses, by adding the server keyword in your Connectors in '''CATALINA_HOME'''/conf/server.xml&lt;br /&gt;
  &amp;lt;Connector port=&amp;quot;8080&amp;quot; ...&lt;br /&gt;
             server=&amp;quot;Apache&amp;quot; /&amp;gt;  &amp;amp;lt;!-- server header is now Apache --&amp;amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Start Tomcat, deploy your applications into '''CATALINA_HOME'''/webapps and hope it works!&lt;br /&gt;
&lt;br /&gt;
== Protecting the Shutdown Port ==&lt;br /&gt;
Tomcat uses a port (defaults to 8005) as a shutdown port.  What this means is that to stop all webapps and stop Tomcat cleanly the shutdown scripts make a connection to this port and send the ''shutdown'' command.  This is not as huge a security problem as it may sound considering the connection to the port must be made from the machine running tomcat and the ''shutdown'' command can be changed to something other than the string ''SHUTDOWN''.  However, it's wise to take the following precautions;&lt;br /&gt;
* if you are running a publicly accessible server make sure you prevent external access to the shutdown port by using a suitable firewall.&lt;br /&gt;
* change the shutdown command in '''CATALINA_HOME'''/conf/server.xml and make sure that file is only readable by the tomcat user.&lt;br /&gt;
  &amp;amp;lt;Server port=&amp;quot;8005&amp;quot; shutdown=&amp;quot;ReallyComplexWord&amp;quot;&amp;amp;gt;&lt;br /&gt;
* if this is still a big problem for you then check [http://marc.theaimsgroup.com/?l=tomcat-user&amp;amp;m=104400608619118&amp;amp;w=2 this thread], from the Tomcat mailing list, for alternatives (they all involve code customisation though).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Securing Manager WebApp ==&lt;br /&gt;
&lt;br /&gt;
* By default there are no users with the manager role.  To make use of the manager webapp you need to add a new role and user into the '''CATALINA_HOME'''/conf/tomcat-users.xml file.&lt;br /&gt;
  &amp;lt;role rolename=&amp;quot;manager&amp;quot;/&amp;gt;&lt;br /&gt;
  &amp;lt;user username=&amp;quot;darren&amp;quot; password=&amp;quot;ReallyComplexPassword&amp;quot; roles=&amp;quot;manager&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Using a [http://tomcat.apache.org/tomcat-5.5-doc/config/valve.html valve] to filter by IP or hostname to only allow a subset of machines to connect (i.e. LAN machines).  Add one of the following within the Context tag in '''CATALINA_HOME'''/conf/Catalina/localhost/manager.xml&lt;br /&gt;
  &amp;amp;lt;!-- allow only LAN IPs to connect to the manager webapp --&amp;amp;gt;&lt;br /&gt;
  &amp;amp;lt;!-- contrary to the current Tomcat 5.5 documation the value for '''allow''' is not a regular expression --&amp;amp;gt;&lt;br /&gt;
  &amp;amp;lt;!-- future versions may have to be specified as 192\.168\.1\.* --&amp;amp;gt;&lt;br /&gt;
  &amp;lt;Valve className=&amp;quot;org.apache.catalina.valves.RemoteAddrValve&amp;quot;&lt;br /&gt;
         allow=&amp;quot;192.168.1.*&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  &amp;amp;lt;!-- allow only LAN hosts to connect to the manager webapp --&amp;amp;gt;&lt;br /&gt;
  &amp;amp;lt;!-- contrary to the current Tomcat 5.5 documation the value for '''allow''' is not a regular expression --&amp;amp;gt;&lt;br /&gt;
  &amp;amp;lt;!-- future versions may have to be specified as *\.localdomain\.com --&amp;amp;gt;&lt;br /&gt;
  &amp;lt;Valve className=&amp;quot;org.apache.catalina.valves.RemoteHostValve&amp;quot;&lt;br /&gt;
         allow=&amp;quot;*.localdomain.com&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* You can rename the manager webapp to something else, e.g. ''foobar''&lt;br /&gt;
** Move '''CATALINA_HOME'''/conf/Catalina/localhost/'''manager.xml''' to '''CATALINA_HOME'''/conf/Catalina/localhost/'''foobar.xml'''&lt;br /&gt;
** Update the '''docBase''' attribute within '''CATALINA_HOME'''/conf/Catalina/localhost/'''foobar.xml''' to ${catalina.home}/server/webapps/foobar&lt;br /&gt;
** Move '''CATALINA_HOME'''/server/webapps/'''manager''' to '''CATALINA_HOME'''/server/webapps/'''foobar'''&lt;br /&gt;
&lt;br /&gt;
== Logging ==&lt;br /&gt;
&lt;br /&gt;
As of tomcat 5.5 logging is now handled by the commons-logging framework allowing you to choose your preferred logging implementation - log4j or standard JDK logging.  By default the standard JDK logging is used (or a compatible extension called juli to be more precise), storing daily log files in '''CATALINA_HOME'''/logs.&lt;br /&gt;
&lt;br /&gt;
By default additional webapp log entries are added to '''CATALINA_HOME'''/logs/catalina.YYYY-MM-DD.log and System.out/System.err are redirected to '''CATALINA_HOME'''/logs/catalina.out.  To place webapp log entries in individual log files create a ''logging.properties'' file similar to the following within '''CATALINA_HOME'''/webapps/''APP_NAME''/WEB-INF/classes (change the ''APP_NAME'' value to create a unique file for each webapp)&lt;br /&gt;
&lt;br /&gt;
  handlers = org.apache.juli.FileHandler, java.util.logging.ConsoleHandler&lt;br /&gt;
  org.apache.juli.FileHandler.level = ALL&lt;br /&gt;
  org.apache.juli.FileHandler.directory = ${catalina.base}/logs&lt;br /&gt;
  org.apache.juli.FileHandler.prefix = APP_NAME.&lt;br /&gt;
&lt;br /&gt;
Further details on logging configuration can be found in the [http://tomcat.apache.org/tomcat-5.5-doc/logging.html tomcat logging documentation.]&lt;br /&gt;
&lt;br /&gt;
If you find you get logging output duplicated in catalina.out, you most likely have unnecessary entries for ''java.util.logging.ConsoleHandler'' in your logging configuration file.&lt;br /&gt;
&lt;br /&gt;
== Encryption ==&lt;br /&gt;
&lt;br /&gt;
* SSL for password or other sensitive data exchange (''bordering on application security, not specific to tomcat'')&lt;br /&gt;
* SSL for connections (JDBC, LDAP, etc ..)&lt;br /&gt;
* The Tomcat documentation clearly explains how to [http://tomcat.apache.org/tomcat-5.5-doc/ssl-howto.html enable SSL.]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Java Security ==&lt;br /&gt;
&lt;br /&gt;
=== Running Tomcat with a Security Manager=== &lt;br /&gt;
The default Tomcat configuration provides good protection for most requirements, but does not prevent a malicious application from compromising the security of other applications running in the same instance.  To prevent this sort of attack, Tomcat can be run with a Security Manager enabled which strictly controls access to server resources.&lt;br /&gt;
Tomcat documentation has a good section on [http://tomcat.apache.org/tomcat-5.5-doc/security-manager-howto.html enabling the Security Manager.]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Miscellaneous ==&lt;br /&gt;
&lt;br /&gt;
* [http://tomcat.apache.org/faq/security.html Tomcat Security FAQ]&lt;br /&gt;
&lt;br /&gt;
=== Using Port 80 ===&lt;br /&gt;
&lt;br /&gt;
If you are on a Windows machine you will be able to change the port attribute of the connector within the ''Catalina'' service from 8080 to 80.  This allows you to use tomcat directly to serve all requests.  Depending on your requirements it may not be good enough to serve directly from Tomcat so you may like to consider;&lt;br /&gt;
* Use IIS / Apache running on port 80 and mod_jk to proxy requests to Tomcat&lt;br /&gt;
&lt;br /&gt;
On a UNIX machine only root is allowed to run services on ports below 1024 (kernel recompilation can overcome this).  It is a very bad idea to run Tomcat as root, so the options are (in no particular order);&lt;br /&gt;
* Use Apache running on port 80 and mod_jk (or mod_proxy_ajp) to proxy requests to Tomcat&lt;br /&gt;
* Run Tomcat as root, but in a chroot jail&lt;br /&gt;
* Use a tool like authbind to enable a non root user to bind to ports below 1024&lt;br /&gt;
* Use a port forwarder such as [http://www.netfilter.org/projects/iptables/index.html Iptables] to redirect incoming requests from 8080 to 80.  This has the disadvantage that internal redirects still need to use 8080.&lt;br /&gt;
* Run [http://www.squid-cache.org/ Squid] as a web accelerator in front of Tomcat&lt;br /&gt;
* Use JSVC/procrun&lt;br /&gt;
Each of the above options '''may''' bring extra security concerns which are outside the scope of this document.&lt;br /&gt;
&lt;br /&gt;
=== Cleartext Passwords in CATALINA_HOME/conf/server.xml ===&lt;br /&gt;
&lt;br /&gt;
When configuring a resource, such as a JDBC pool, it is necessary to include clear text username and password in CATALINA_HOME/conf/server.xml  Best practices advice us never to store clear text passwords, but the following paragraphs highlight it is very difficult to avoid.&lt;br /&gt;
&lt;br /&gt;
If one way encryption was used on the password it must be possible for a database connection to be established using a username and encrypted password - so the encrypted password is just as valuable as the clear text one to an attacker.&lt;br /&gt;
&lt;br /&gt;
If two way encryption was used a keyfile is needed which must also live on the filesystem.  To make it more secure a passphase is added to the keyfile which then has to be stored in the configuration as clear text - no improvement.&lt;br /&gt;
&lt;br /&gt;
Encoding is security by obscurity and offers no form of protection (algorithms can be reverse engineered).  What encoding does do is make huge amounts of overhead work - you need to customise Tomcat and the commons digester it uses to parse the config files.  You'd also need a way to create encoded passwords.&lt;br /&gt;
&lt;br /&gt;
In the case of a JDBC pool what you can do is;&lt;br /&gt;
* make sure the database user only has access to the databases and tables they need (also limit rights as necessary).&lt;br /&gt;
* make sure the raw database files are only accessible to the user running the database services (e.g. mysql/postgresql user)&lt;br /&gt;
* make sure the Tomcat configuration files are only accessible to the tomcat user&lt;br /&gt;
&lt;br /&gt;
[[Category:OWASP Java Project]]&lt;br /&gt;
[[Category:Java]]&lt;/div&gt;</summary>
		<author><name>Dledmonds</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=SpoC_007_-_WebScarab_NG_Security_Test_Automation_-_Progress_Page&amp;diff=22412</id>
		<title>SpoC 007 - WebScarab NG Security Test Automation - Progress Page</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=SpoC_007_-_WebScarab_NG_Security_Test_Automation_-_Progress_Page&amp;diff=22412"/>
				<updated>2007-10-16T22:56:07Z</updated>
		
		<summary type="html">&lt;p&gt;Dledmonds: /* Project Plan */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Project Plan ==&lt;br /&gt;
&lt;br /&gt;
* Familiarise myself with spring and spring rich client frameworks. (COMPLETE)&lt;br /&gt;
* Research and test BSF (Bean Scripting Framework) as a way to write custom tests (COMPLETE)&lt;br /&gt;
* Design regression testing framework (IN PROGRESS)&lt;br /&gt;
* Design regression testing UIs for review&lt;br /&gt;
* Write sample tests in javascript&lt;br /&gt;
&lt;br /&gt;
* Port spider functionality from webscarab&lt;br /&gt;
* Extend spider functionality to perform surface testing of website using sample tests (e.g. check for ~ files)&lt;/div&gt;</summary>
		<author><name>Dledmonds</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=SpoC_007_-_WebScarab_NG_Security_Test_Automation_-_Progress_Page&amp;diff=22407</id>
		<title>SpoC 007 - WebScarab NG Security Test Automation - Progress Page</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=SpoC_007_-_WebScarab_NG_Security_Test_Automation_-_Progress_Page&amp;diff=22407"/>
				<updated>2007-10-15T19:52:54Z</updated>
		
		<summary type="html">&lt;p&gt;Dledmonds: /* Project Plan */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Project Plan ==&lt;br /&gt;
&lt;br /&gt;
OK, step backwards.  Not being familiar with spring or spring rich client I've had to spend time getting up to speed before making any real progress.&lt;br /&gt;
&lt;br /&gt;
* Familiarise myself with spring and spring rich client frameworks.&lt;br /&gt;
* Port spider functionality from webscarab as a familiarisation exercise and because it's feature will be useful for automated testing.&lt;br /&gt;
* Design regression testing UIs for review&lt;br /&gt;
* Research and testing of BSF (Bean Scripting Framework) as a way to write custom tests&lt;/div&gt;</summary>
		<author><name>Dledmonds</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=SpoC_007_-_WebScarab_NG_Security_Test_Automation_-_Progress_Page&amp;diff=22228</id>
		<title>SpoC 007 - WebScarab NG Security Test Automation - Progress Page</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=SpoC_007_-_WebScarab_NG_Security_Test_Automation_-_Progress_Page&amp;diff=22228"/>
				<updated>2007-10-07T12:42:55Z</updated>
		
		<summary type="html">&lt;p&gt;Dledmonds: /* Project Plan */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Project Plan ==&lt;br /&gt;
&lt;br /&gt;
OK, step backwards.  Not being familiar with spring or spring rich client I've had to spend time getting up to speed before making any real progress.&lt;br /&gt;
&lt;br /&gt;
* Familiarise myself with spring and spring rich client frameworks.&lt;br /&gt;
* Port spider functionality from webscarab as a familiarisation exercise and because it's feature will be useful for automated testing.&lt;br /&gt;
* Design regression testing UIs for review&lt;/div&gt;</summary>
		<author><name>Dledmonds</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=SpoC_007_-_WebScarab_NG_Security_Test_Automation_-_Progress_Page&amp;diff=21816</id>
		<title>SpoC 007 - WebScarab NG Security Test Automation - Progress Page</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=SpoC_007_-_WebScarab_NG_Security_Test_Automation_-_Progress_Page&amp;diff=21816"/>
				<updated>2007-09-17T19:08:42Z</updated>
		
		<summary type="html">&lt;p&gt;Dledmonds: New page: == Project Plan ==  * Port spider functionality from webscarab as a familiarisation exercise and because it's feature will be useful for automated testing.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Project Plan ==&lt;br /&gt;
&lt;br /&gt;
* Port spider functionality from webscarab as a familiarisation exercise and because it's feature will be useful for automated testing.&lt;/div&gt;</summary>
		<author><name>Dledmonds</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Talk:Hashing_Java&amp;diff=17891</id>
		<title>Talk:Hashing Java</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Talk:Hashing_Java&amp;diff=17891"/>
				<updated>2007-04-17T16:34:49Z</updated>
		
		<summary type="html">&lt;p&gt;Dledmonds: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Status==&lt;br /&gt;
Needs review&lt;br /&gt;
&lt;br /&gt;
==Reviewers==&lt;br /&gt;
* ?&lt;br /&gt;
&lt;br /&gt;
==General Discussion==&lt;br /&gt;
I use a very similar scheme in my applications, but 2 points that came to mind whilst reading.&lt;br /&gt;
#Iterations of at least 1000 times seemed a bit excessive, but it is in the standard and I'm in no way qualified to critise.&lt;br /&gt;
#Instead of storing salt in it's own field I usually include it amongst the password (i.e characters 2, 4, 7, 13, 17, 19) to make it that bit harder to even find the salt value.  I generally hex encode the hashes as well to make them a bit easier to work with.  Assuming decompiled code is available (as an attacker has gained access to the password hashes) this extra salt hiding may not serve any useless purpose.&lt;br /&gt;
:--------------&lt;br /&gt;
:I think that the above comment about hiding the bits in the password should just tossed. First, it is basically arguing security by obscurity - never a good practice. Second, it states that the bit hiding isn't helpful when the source code is available. Being that this article is discussing hashing in &amp;quot;Java&amp;quot; specifically and Java decompilation is a well-known and freely available technology, it seems that there is no need to mention hiding of the salt unless it is in reference to other languages. Eg: &amp;quot;In languages other than Java, where obtaining the source code can be difficult and reading the machine code is awkward, hiding the bits of the salt within the hashed password might provide some extra security.(And comments probably should be signed. Four tilde's &amp;quot;~ ~ ~ ~&amp;quot;, without the intervening spaces, adds your username and timestamps the comment.)&lt;br /&gt;
:[[User:Neil Smithline|Neil Smithline]] 16:46, 13 April 2007 (EDT)&lt;br /&gt;
::I'm advocating information hiding, not security by obscurity, albeit a fine line.  The case where source is available makes it a pointless exercise from a security perspective, but imagine a badly written webapp provides access to the database.  Showing the use of different salts and then making the salt value obvious allows an attacker to perform dictionary attacks.  Hiding the salt within the encrypted password makes this almost impossible. [[User:Dledmonds|Darren]] 12:34, 17 April 2007 (EDT)&lt;br /&gt;
&lt;br /&gt;
== Huh? Repetitive hashing only affects the attacker?  ==&lt;br /&gt;
&lt;br /&gt;
The article states ([[Hashing_Java#Hardening against the attacker's attack]]):&lt;br /&gt;
:To slow down the computation it is recommended to iterate the hash operation n times. Because hashing is a fast operation, it slows down by a n factor an attacker but not a legitimate user. &lt;br /&gt;
I find the second sentence so awkward to parse that I'm not sure if it is incorrect, I'm mis-parsing it, or I'm not understanding what it is saying. My understanding is that doing the hash ''n'' times slows down both the attacker, the user, and anyone else who wants to hash, by a factor of ''n'' every time they hash. The key here is that most of what a typical user does is not authentication, and most of authentication is not password validation. Other tasks such as database lookups, permission gathering, and session initialization tend to be much slower than password validation (which likely happens entirely in memory in a tight loop and thereby flies by comparison to the DB-based operations). So, while hashing the password ''n'' times does slow down '''hashing''' for both attackers '''and''' typical users, typical users don't really notice it being that hashing is such a small percentage of their total time interacting with the system. On the other hand, an attacker trying to crack passwords spends nearly 100% of their time hashing so hashing ''n'' times '''gives the appearance''' of slowing the attacker down by a factor of ''n'' while not noticeably affecting the typical user.&lt;br /&gt;
&lt;br /&gt;
If someone else takes a look at my comment and the article and agrees, then it should probably just be changed. I would have done this myself but I'm concerned (although not very concerned) that I might be misunderstanding the text.&lt;br /&gt;
&lt;br /&gt;
[[User:Neil Smithline|Neil Smithline]] 17:09, 13 April 2007 (EDT)&lt;/div&gt;</summary>
		<author><name>Dledmonds</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Securing_tomcat&amp;diff=17890</id>
		<title>Securing tomcat</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Securing_tomcat&amp;diff=17890"/>
				<updated>2007-04-17T16:12:45Z</updated>
		
		<summary type="html">&lt;p&gt;Dledmonds: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
Most weaknesses in [http://tomcat.apache.org/ Apache Tomcat] come from incorrect or inappropiate configuration.  It is nearly always possible to make Tomcat more secure than the default out of the box installation.  What follows documents best practices and recommendations on securing a production Tomcat server, whether it be hosted on a Windows or Unix based operating system.  ''Please note that the section ordering is not a representation of the section importance.''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Software Versions ==&lt;br /&gt;
&lt;br /&gt;
The first step is to make sure you are running the latest stable releases of software;&lt;br /&gt;
* Java Runtime Environment (JRE) or SDK&lt;br /&gt;
* Tomcat&lt;br /&gt;
* Third party libraries&lt;br /&gt;
This does not mean you have to upgrade all your production servers to a new (and potentially buggy) release which has just been made available to the public.  What you must do is download the latest stable bugfix release that has continual support.  For the JRE and Tomcat you should be looking at the last digits in the version number (5.5.'''X''') as it represents the bugfix information.  The bugs fixed in these releases are publicly available so if you don't upgrade you could be providing attackers with a very easy route to compromise your server.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Installation of Apache Tomcat 5.5 ==&lt;br /&gt;
&lt;br /&gt;
=== UNIX ===&lt;br /&gt;
&lt;br /&gt;
* Create a tomcat user/group&lt;br /&gt;
* Download and unpack the core distribution (referenced as '''CATALINA_HOME''' from now on)&lt;br /&gt;
* Change '''CATALINA_HOME''' ownership to tomcat user and tomcat group&lt;br /&gt;
* Change files in '''CATALINA_HOME'''/conf to be readonly (400)&lt;br /&gt;
* Make sure tomcat user has read/write access to /tmp and write (300 - yes, only write/execute) access to '''CATALINA_HOME'''/logs&lt;br /&gt;
&lt;br /&gt;
=== Windows ===&lt;br /&gt;
&lt;br /&gt;
* Download the core windows service installer&lt;br /&gt;
* Start the installation, click ''Next'' and ''Agree'' to the licence&lt;br /&gt;
* Untick ''native'', ''documentation'', ''examples'' and ''webapps'' then click ''Next''&lt;br /&gt;
* Choose an installation directory (referenced as '''CATALINA_HOME''' from now on), preferably on a different drive to the OS.  &lt;br /&gt;
* Choose an administrator username (NOT admin) and a secure password that complies with your organisations password policy.&lt;br /&gt;
* Complete tomcat installation, but do not start service.&lt;br /&gt;
&lt;br /&gt;
=== Common ===&lt;br /&gt;
&lt;br /&gt;
* Remove everything from '''CATALINA_HOME'''/webapps (ROOT, balancer, jsp-examples, servlet-examples, tomcat-docs, webdav)&lt;br /&gt;
&lt;br /&gt;
* Remove everything from '''CATALINA_HOME'''/server/webapps (host-manager, manager).  Note that it can be useful to keep the manager webapp installed if you need the ability to redeploy without restarting Tomcat.  If you choose to keep it please read the section on Securing the Manager WebApp.&lt;br /&gt;
&lt;br /&gt;
* Remove '''CATALINA_HOME'''/conf/Catalina/localhost/host-manager.xml and '''CATALINA_HOME'''/conf/Catalina/localhost/manager.xml (again, if you are keeping the manager application, do not remove this).&lt;br /&gt;
&lt;br /&gt;
* Make sure the default servlet is configured '''not''' to serve index pages when a welcome file is not present.  In '''CATALINA_HOME'''/conf/web.xml&lt;br /&gt;
  &amp;lt;servlet&amp;gt;&lt;br /&gt;
    &amp;lt;servlet-name&amp;gt;default&amp;lt;/servlet-name&amp;gt;&lt;br /&gt;
    &amp;lt;servlet-class&amp;gt;org.apache.catalina.servlets.DefaultServlet&amp;lt;/servlet-class&amp;gt;&lt;br /&gt;
    &amp;lt;init-param&amp;gt;&lt;br /&gt;
      &amp;lt;param-name&amp;gt;debug&amp;lt;/param-name&amp;gt;&lt;br /&gt;
      &amp;lt;param-value&amp;gt;0&amp;lt;/param-value&amp;gt;&lt;br /&gt;
    &amp;lt;/init-param&amp;gt;&lt;br /&gt;
    &amp;lt;init-param&amp;gt;&lt;br /&gt;
      &amp;lt;param-name&amp;gt;listings&amp;lt;/param-name&amp;gt;&lt;br /&gt;
      &amp;lt;param-value&amp;gt;'''false'''&amp;lt;/param-value&amp;gt;  &amp;amp;lt;!-- make sure this is false --&amp;amp;gt;&lt;br /&gt;
    &amp;lt;/init-param&amp;gt;&lt;br /&gt;
    &amp;lt;load-on-startup&amp;gt;1&amp;lt;/load-on-startup&amp;gt;&lt;br /&gt;
  &amp;lt;/servlet&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Remove version string from HTTP error messages by repacking '''CATALINA_HOME'''/server/lib/catalina.jar with an updated ServerInfo.properties file.&lt;br /&gt;
:unpack catalina.jar&lt;br /&gt;
  cd CATALINA_HOME/server/lib&lt;br /&gt;
  jar xf catalina.jar org/apache/catalina/util/ServerInfo.properties&lt;br /&gt;
:update ServerInfo.properties by changing server.info line to server.info=Apache Tomcat&lt;br /&gt;
:repackage catalina.jar&lt;br /&gt;
  jar uf catalina.jar org/apache/catalina/util/ServerInfo.properties&lt;br /&gt;
:remove CATALINA_HOME/server/lib/org (created when extracting the ServerInfo.properties file)&lt;br /&gt;
&lt;br /&gt;
* Replace default error page (default is stacktrace) by adding the following into '''CATALINA_HOME'''/conf/web.xml.  The default error page shows a full stacktrace which is a disclosure of sensitive information.  Place the following within the ''web-app'' tag (after the ''welcome-file-list'' tag is fine). ''The following solution is not ideal as it produces a blank page because Tomcat cannot find the file specified, but without a better solution this, at least, achieves the desired result.  A well configured web application will override this default in CATALINA_HOME/webapps/APP_NAME/WEB-INF/web.xml so it won't cause problems.''&lt;br /&gt;
  &amp;lt;error-page&amp;gt;&lt;br /&gt;
    &amp;lt;exception-type&amp;gt;java.lang.Exception&amp;lt;/exception-type&amp;gt;&lt;br /&gt;
    &amp;lt;location&amp;gt;/error.jsp&amp;lt;/location&amp;gt;&lt;br /&gt;
  &amp;lt;/error-page&amp;gt;&lt;br /&gt;
* Rename '''CATALINA_HOME'''/conf/server.xml to '''CATALINA_HOME'''/conf/server-original.xml and rename '''CATALINA_HOME'''/conf/server-minimal.xml to '''CATALINA_HOME'''/conf/server.xml.  The minimal configuration provides the same basic configuration, but without the nested comments is much easier to maintain and understand.  Do not delete the original file as the comments make it useful for reference if you ever need to make changes - e.g. enable SSL.&lt;br /&gt;
&lt;br /&gt;
* Replace the server version string from HTTP headers in server responses, by adding the server keyword in your Connectors in '''CATALINA_HOME'''/conf/server.xml&lt;br /&gt;
  &amp;lt;Connector port=&amp;quot;8080&amp;quot; ...&lt;br /&gt;
             server=&amp;quot;Apache&amp;quot; /&amp;gt;  &amp;amp;lt;!-- server header is now Apache --&amp;amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Start Tomcat, deploy your applications into '''CATALINA_HOME'''/webapps and hope it works!&lt;br /&gt;
&lt;br /&gt;
== Protecting the Shutdown Port ==&lt;br /&gt;
Tomcat uses a port (defaults to 8005) as a shutdown port.  What this means is that to stop all webapps and stop Tomcat cleanly the shutdown scripts make a connection to this port and send the ''shutdown'' command.  This is not as huge a security problem as it may sound considering the connection to the port must be made from the machine running tomcat and the ''shutdown'' command can be changed to something other than the string ''SHUTDOWN''.  However, it's wise to take the following precautions;&lt;br /&gt;
* if you are running a publicly accessible server make sure you prevent external access to the shutdown port by using a suitable firewall.&lt;br /&gt;
* change the shutdown command in '''CATALINA_HOME'''/conf/server.xml and make sure that file is only readable by the tomcat user.&lt;br /&gt;
  &amp;amp;lt;Server port=&amp;quot;8005&amp;quot; shutdown=&amp;quot;ReallyComplexWord&amp;quot;&amp;amp;gt;&lt;br /&gt;
* if this is still a big problem for you then check [http://marc.theaimsgroup.com/?l=tomcat-user&amp;amp;m=104400608619118&amp;amp;w=2 this thread], from the Tomcat mailing list, for alternatives (they all involve code customisation though).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Securing Manager WebApp ==&lt;br /&gt;
&lt;br /&gt;
* By default there are no users with the manager role.  To make use of the manager webapp you need to add a new role and user into the '''CATALINA_HOME'''/conf/tomcat-users.xml file.&lt;br /&gt;
  &amp;lt;role rolename=&amp;quot;manager&amp;quot;/&amp;gt;&lt;br /&gt;
  &amp;lt;user username=&amp;quot;darren&amp;quot; password=&amp;quot;ReallyComplexPassword&amp;quot; roles=&amp;quot;manager&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Using a [http://tomcat.apache.org/tomcat-5.5-doc/config/valve.html valve] to filter by IP or hostname to only allow a subset of machines to connect (i.e. LAN machines).  Add one of the following within the Context tag in '''CATALINA_HOME'''/conf/Catalina/localhost/manager.xml&lt;br /&gt;
  &amp;amp;lt;!-- allow only LAN IPs to connect to the manager webapp --&amp;amp;gt;&lt;br /&gt;
  &amp;amp;lt;!-- contrary to the current Tomcat 5.5 documation the value for '''allow''' is not a regular expression --&amp;amp;gt;&lt;br /&gt;
  &amp;amp;lt;!-- future versions may have to be specified as 192\.168\.1\.* --&amp;amp;gt;&lt;br /&gt;
  &amp;lt;Valve className=&amp;quot;org.apache.catalina.valves.RemoteAddrValve&amp;quot;&lt;br /&gt;
         allow=&amp;quot;192.168.1.*&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  &amp;amp;lt;!-- allow only LAN hosts to connect to the manager webapp --&amp;amp;gt;&lt;br /&gt;
  &amp;amp;lt;!-- contrary to the current Tomcat 5.5 documation the value for '''allow''' is not a regular expression --&amp;amp;gt;&lt;br /&gt;
  &amp;amp;lt;!-- future versions may have to be specified as *\.localdomain\.com --&amp;amp;gt;&lt;br /&gt;
  &amp;lt;Valve className=&amp;quot;org.apache.catalina.valves.RemoteHostValve&amp;quot;&lt;br /&gt;
         allow=&amp;quot;*.localdomain.com&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* You can rename the manager webapp to something else, e.g. ''foobar''&lt;br /&gt;
** Move '''CATALINA_HOME'''/conf/Catalina/localhost/'''manager.xml''' to '''CATALINA_HOME'''/conf/Catalina/localhost/'''foobar.xml'''&lt;br /&gt;
** Update the '''docBase''' attribute within '''CATALINA_HOME'''/conf/Catalina/localhost/'''foobar.xml''' to ${catalina.home}/server/webapps/foobar&lt;br /&gt;
** Move '''CATALINA_HOME'''/server/webapps/'''manager''' to '''CATALINA_HOME'''/server/webapps/'''foobar'''&lt;br /&gt;
&lt;br /&gt;
== Logging ==&lt;br /&gt;
&lt;br /&gt;
As of tomcat 5.5 logging is now handled by the commons-logging framework allowing you to choose your preferred logging implementation - log4j or standard JDK logging.  By default the standard JDK logging is used (or a compatible extension called juli to be more precise), storing daily log files in '''CATALINA_HOME'''/logs.&lt;br /&gt;
&lt;br /&gt;
By default additional webapp log entries are added to '''CATALINA_HOME'''/logs/catalina.YYYY-MM-DD.log and System.out/System.err are redirected to '''CATALINA_HOME'''/logs/catalina.out.  To place webapp log entries in individual log files create a ''logging.properties'' file similar to the following within '''CATALINA_HOME'''/webapps/''APP_NAME''/WEB-INF/classes (change the ''APP_NAME'' value to create a unique file for each webapp)&lt;br /&gt;
&lt;br /&gt;
  handlers = org.apache.juli.FileHandler, java.util.logging.ConsoleHandler&lt;br /&gt;
  org.apache.juli.FileHandler.level = ALL&lt;br /&gt;
  org.apache.juli.FileHandler.directory = ${catalina.base}/logs&lt;br /&gt;
  org.apache.juli.FileHandler.prefix = APP_NAME.&lt;br /&gt;
&lt;br /&gt;
Further details on logging configuration can be found in the [http://tomcat.apache.org/tomcat-5.5-doc/logging.html tomcat logging documentation.]&lt;br /&gt;
&lt;br /&gt;
If you find you get logging output duplicated in catalina.out, you most likely have unnecessary entries for ''java.util.logging.ConsoleHandler'' in your logging configuration file.&lt;br /&gt;
&lt;br /&gt;
== Encryption ==&lt;br /&gt;
&lt;br /&gt;
* SSL for password or other sensitive data exchange (''bordering on application security, not specific to tomcat'')&lt;br /&gt;
* SSL for connections (JDBC, LDAP, etc ..)&lt;br /&gt;
* The Tomcat documentation clearly explains how to [http://tomcat.apache.org/tomcat-5.5-doc/ssl-howto.html enable SSL.]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Java Security ==&lt;br /&gt;
&lt;br /&gt;
=== Running Tomcat with a Security Manager=== &lt;br /&gt;
The default Tomcat configuration provides good protection for most requirements, but does not prevent a malicious application from compromising the security of other applications running in the same instance.  To prevent this sort of attack, Tomcat can be run with a Security Manager enabled which strictly controls access to server resources.&lt;br /&gt;
Tomcat documentation has a good section on [http://tomcat.apache.org/tomcat-5.5-doc/security-manager-howto.html enabling the Security Manager.]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Miscellaneous ==&lt;br /&gt;
&lt;br /&gt;
* [http://tomcat.apache.org/faq/security.html Tomcat Security FAQ]&lt;br /&gt;
&lt;br /&gt;
=== Using Port 80 ===&lt;br /&gt;
&lt;br /&gt;
If you are on a Windows machine you will be able to change the port attribute of the connector within the ''Catalina'' service from 8080 to 80.  This allows you to use tomcat directly to serve all requests.  Depending on your requirements it may not be good enough to serve directly from Tomcat so you may like to consider;&lt;br /&gt;
* Use IIS / Apache running on port 80 and mod_jk to proxy requests to Tomcat&lt;br /&gt;
&lt;br /&gt;
On a UNIX machine only root is allowed to run services on ports below 1024 (kernel recompilation can overcome this).  It is a very bad idea to run Tomcat as root, so the options are (in no particular order);&lt;br /&gt;
* Use Apache running on port 80 and mod_jk (or mod_proxy_ajp) to proxy requests to Tomcat&lt;br /&gt;
* Run Tomcat as root, but in a chroot jail&lt;br /&gt;
* Use a tool like authbind to enable a non root user to bind to ports below 1024&lt;br /&gt;
* Use a port forwarder such as [http://www.netfilter.org/projects/iptables/index.html Iptables] to redirect incoming requests from 8080 to 80.  This has the disadvantage that internal redirects still need to use 8080.&lt;br /&gt;
* Run [http://www.squid-cache.org/ Squid] as a web accelerator in front of Tomcat&lt;br /&gt;
* Use JSVC/procrun&lt;br /&gt;
Each of the above options '''may''' bring extra security concerns which are outside the scope of this document.&lt;br /&gt;
&lt;br /&gt;
=== Cleartext Passwords in CATALINA_HOME/conf/server.xml ===&lt;br /&gt;
&lt;br /&gt;
When configuring a resource, such as a JDBC pool, it is necessary to include clear text username and password in CATALINA_HOME/conf/server.xml  Best practices advice us never to store clear text passwords, but the following paragraphs highlight it is very difficult to avoid.&lt;br /&gt;
&lt;br /&gt;
If one way encryption was used on the password it must be possible for a database connection to be established using a username and encrypted password - so the encrypted password is just as valuable as the clear text one to an attacker.&lt;br /&gt;
&lt;br /&gt;
If two way encryption was used a keyfile is needed which must also live on the filesystem.  To make it more secure a passphase is added to the keyfile which then has to be stored in the configuration as clear text - no improvement.&lt;br /&gt;
&lt;br /&gt;
Encoding is security by obscurity and offers no form of protection (algorithms can be reverse engineered).  What encoding does do is make huge amounts of overhead work - you need to customise Tomcat and the commons digester it uses to parse the config files.  You'd also need a way to create encoded passwords.&lt;br /&gt;
&lt;br /&gt;
In the case of a JDBC pool what you can do is;&lt;br /&gt;
* make sure the database user only has access to the databases and tables they need (also limit rights as necessary).&lt;br /&gt;
* make sure the raw database files are only accessible to the user running the database services (e.g. mysql/postgresql user)&lt;br /&gt;
* make sure the Tomcat configuration files are only accessible to the tomcat user&lt;br /&gt;
&lt;br /&gt;
[[Category:OWASP Java Project]]&lt;br /&gt;
[[Category:Java]]&lt;/div&gt;</summary>
		<author><name>Dledmonds</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=OWASP_Spring_Of_Code_2007_Applications&amp;diff=17539</id>
		<title>OWASP Spring Of Code 2007 Applications</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=OWASP_Spring_Of_Code_2007_Applications&amp;diff=17539"/>
				<updated>2007-03-29T23:03:25Z</updated>
		
		<summary type="html">&lt;p&gt;Dledmonds: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page contains project Applications to the [[OWASP_Spring_Of_Code_2007]]&lt;br /&gt;
&lt;br /&gt;
'''If you want to apply for a SpoC 007 sponsorship you HAVE TO USE THIS PAGE for your application'''&lt;br /&gt;
&lt;br /&gt;
See [[OWASP_Spring_Of_Code_2007#How_To_Participate]] for what do to one you completed your Application&lt;br /&gt;
&lt;br /&gt;
---------&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Proposed template:''' {for longer proposals, in addition to these details you can create a PDF}:&lt;br /&gt;
&lt;br /&gt;
== {Your first name or Alias} - {Project name} ==&lt;br /&gt;
Please remember that projects will be selected and funded based on how well they meet the [[OWASP_Spring_Of_Code_2007_:_Selection|Selection Criteria]].&lt;br /&gt;
&lt;br /&gt;
You can propose your project in any form you wish, but the best proposals will be well thought out, clear and concise, and reflective of your passion for the topic.  We strongly suggest that you include the following information in your proposal.&lt;br /&gt;
&lt;br /&gt;
* Your educational and professional background&lt;br /&gt;
&lt;br /&gt;
* Application security experience and accomplishments&lt;br /&gt;
&lt;br /&gt;
* Participation and leadership in open communities&lt;br /&gt;
&lt;br /&gt;
* The opportunity, challenges, issues or need your proposal addresses&lt;br /&gt;
&lt;br /&gt;
* Objectives or ways in which you will meet the goal(s)&lt;br /&gt;
&lt;br /&gt;
* Specific activities and who will carry out these activities&lt;br /&gt;
&lt;br /&gt;
* Specific deliverables and a rough project schedule so we can track progress&lt;br /&gt;
&lt;br /&gt;
* Long-term vision for the project&lt;br /&gt;
&lt;br /&gt;
* Any other reasons why you and your project should be selected&lt;br /&gt;
&lt;br /&gt;
== Buanzo - Enigform: Firefox Addon for OpenPGP signing of HTTP requests ==&lt;br /&gt;
&lt;br /&gt;
I am a 25 year old Independent security consultant from Buenos Aires, Argentina, that has contributed to the world of&lt;br /&gt;
information systems security since 1994, when BBSes and Linux still lived together.&lt;br /&gt;
&lt;br /&gt;
A quick search for buanzo on google [http://www.google.com/search?hl=en&amp;amp;q=buanzo&amp;amp;btnG=Google+Search] will provide all necessary details about my professional and community background. For comprobable experience, you could also check my Rent a Coder profile.[http://www.rentacoder.com/RentACoder/SoftwareCoders/showBioInfo.asp?lngAuthorId=735204].&lt;br /&gt;
&lt;br /&gt;
In my free time I like playing with my Punk-Pop band [http://www.purevolume.com/futurabandapunkpop], Futurabanda. [http://www.futurabanda.com.ar], and maintaining my Restaurants, Wines and Recipes site. [http://www.vivamoslavida.com.ar]. I have to admit that my first priorities are my beloved son [http://www.fotolog.com/buanzo] and my wonderful wife [http://www.fotolog.com/buanzo].&lt;br /&gt;
&lt;br /&gt;
=== Accomplishments ===&lt;br /&gt;
&lt;br /&gt;
I've contributed scripts, fixes and translations to the Nmap project. I've also acted as Expert Contributor for SANS TOP-20 2004, 2005 and 2006. I've developed &lt;br /&gt;
tools that can be found in Freshmeat, like mprl (a getty enhancement to allow remote logins from the login: prompt of the console). I've also written&lt;br /&gt;
the Unix chapter of the OISSG's Information Systems Security Assessment Framework, v0.1 [http://www.oissg.org/content/view/71/71/]. I'm currently writing&lt;br /&gt;
an Internet Draft to be proposed for RFC regarding Enigform.&lt;br /&gt;
&lt;br /&gt;
=== Community ===&lt;br /&gt;
&lt;br /&gt;
I run the official 2600 meetings site for Argentina [http://www.2600.com/meetings/pages.html], I've been proposed, but I refused, for President of the Argentinian Free Software group called SOLAR [www.solar.org.ar]. I'm an active member of the FLOSS community since 1996, having written articles in magazines http://www.net-security.org/dl/articles/Detecting_and_Understanding_rootkits.txt, made TV, radio&lt;br /&gt;
and newspaper appearances [http://codigoabierto.bitacoras.com/archivos/2005/04/01/buanzo-hacks] and led different security research groups of Spain, Mexico and Argentina. Currently I contribute time thorugh my sites, forums and blogs,&lt;br /&gt;
answering questions in mailing lists and helping coordinate some local LUGs. I do also manager the Linux Counter for Argentina [http://counter.li.org/reports/place.php?place=AR].&lt;br /&gt;
&lt;br /&gt;
=== My Project ===&lt;br /&gt;
&lt;br /&gt;
Enigform [http://enigform.mozdev.org] is a Firefox extension that enhances HTTP with OpenPGP functionality. It digitally signs outgoing HTTP requests so that a web server can authenticate the identity and data of the incoming request. It is a Web Security tool because it can, if correctly implemented as any OpenPGP based technology, render man in the middle attacks useless. I think OpenPGP already speaks for itself regarding eMail. Imagine the same benefits for http and web applications. I think Enigform can fit into the OWASP Validation Project [http://www.owasp.org/index.php/Category:OWASP_Validation_Project].&lt;br /&gt;
&lt;br /&gt;
Enigform is the reference implementation of the Internet Draft I'm working on, in discussion with members of the IETF's OpenPGP Working Group.&lt;br /&gt;
&lt;br /&gt;
Some simple PHP code is enough to make a web application Enigform-aware [http://enigformtest.buanzo.com.ar]. The Smutty PHP MVC Framework already supports Enigform [http://smutty.pu-gh.com/demo/enigform].&lt;br /&gt;
&lt;br /&gt;
=== Long Term ===&lt;br /&gt;
&lt;br /&gt;
Have the Draft be proposed as a Standards Track RFC document, have Enigform support directly in Apache and IIS, and port Enigform to other browsers&lt;br /&gt;
and/or programming languages, and also provide OpenPGP De/Encryption support.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Why should I be selected ===&lt;br /&gt;
&lt;br /&gt;
I have the experience, security awareness and means to make this project THE web security project of the decade. I am a respected member of the&lt;br /&gt;
international security community, and I firmly believe Enigform is my greatest idea so far.&lt;br /&gt;
&lt;br /&gt;
== Eoin Keary - Code review Project ==&lt;br /&gt;
* '''Executive Summary''':&lt;br /&gt;
I am proposing that I complete the OWASP Code review guide during this period.&lt;br /&gt;
The code review guide was started by me in 2005 and has much information on reviewing code for common vulnerabilities. It is frequently accessed (looking at the stats on the OWASP site) and therefore is useful to practitioners. &lt;br /&gt;
&lt;br /&gt;
I believe the code review guide is an integral part of the OWASP BOK (Body of Knowledge). Ensuring secure development is key to secure applications and code review is of paramount importance in this domain.&lt;br /&gt;
&lt;br /&gt;
There are many sections still to be added and more to be readjusted and rewritten to reflect the current state of the security world.&lt;br /&gt;
Much needs to be written on Web 2.0 technologies and distributed B2B technologies such as Webservices.&lt;br /&gt;
 &lt;br /&gt;
The Code review process and procedure needs also to be covered. A guide to establishing a mature code review process also needs to be done.&lt;br /&gt;
Code review methodologies also need to be discussed.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* '''Objectives and Deliverables''':&lt;br /&gt;
&lt;br /&gt;
Update of the code review guide:&lt;br /&gt;
* Add additional areas relating to the code review process such as:&lt;br /&gt;
** Benefits and pitfalls&lt;br /&gt;
** Methodology&lt;br /&gt;
** The code review process&lt;br /&gt;
*** Transactional analysis&lt;br /&gt;
*** Managing the code review process&lt;br /&gt;
*** Assigning risk to findings&lt;br /&gt;
&lt;br /&gt;
** Technical guides&lt;br /&gt;
*** Language specific best practice &lt;br /&gt;
*** Java &lt;br /&gt;
*** .NET &lt;br /&gt;
*** PHP &lt;br /&gt;
*** MySQL &lt;br /&gt;
*** Stored Procs &lt;br /&gt;
*** C/C++ &lt;br /&gt;
&lt;br /&gt;
** Code review by vulnerability:&lt;br /&gt;
*** Reviewing Code for Buffer Overruns and Overflows &lt;br /&gt;
*** Reviewing Code for OS Injection&lt;br /&gt;
*** Reviewing Code for SQL Injection&lt;br /&gt;
*** Reviewing Code for Data Validation&lt;br /&gt;
*** Reviewing code for XSS issues&lt;br /&gt;
*** Reviewing Code for Error Handling&lt;br /&gt;
*** Reviewing Code for Logging Issues&lt;br /&gt;
*** Reviewing The Secure Code Environment&lt;br /&gt;
*** Reviewing code for Authorization Issues&lt;br /&gt;
*** Reviewing code for Authentication Issues&lt;br /&gt;
*** Reviewing code for Session Integrity&lt;br /&gt;
*** Reviewing code for Cross Site Request Forgery&lt;br /&gt;
*** Reviewing code for Cryptography implementation issues&lt;br /&gt;
*** Reviewing code Dangerous HTTP Methods (Deployment)&lt;br /&gt;
*** Race Conditions &lt;br /&gt;
&lt;br /&gt;
The areas of code are structured giving a brief explanation, the anti-pattern (vulnerable pattern to look for) and a suggested fix.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* '''Why I should be sponsored for the project''':&lt;br /&gt;
&lt;br /&gt;
I used to head up the code review team as part of the application security group in fidelity investments and have 5+ years of the secure code review process. &lt;br /&gt;
I also was the lead of the Testing guide until V2 was published via the Autumn of Code. &lt;br /&gt;
&lt;br /&gt;
I have always  delivered any work I have volunteered for on time. &lt;br /&gt;
 &lt;br /&gt;
I have been involved in OWASP projects for 2/3 years now and have always been an active contributor.&lt;br /&gt;
&lt;br /&gt;
== Paolo Perego - Owasp Orizon Project ==&lt;br /&gt;
* '''Executive Summary''':&lt;br /&gt;
Owasp Orizon [http://www.owasp.org/index.php/Category:OWASP_Orizon_Project] Project born in 2006 as answer to the lack of common engine and library usable by opensource code review related tools.&lt;br /&gt;
&lt;br /&gt;
I'm proposing that, during the Spring of Code 2007 period, I'll complete static analisys API and java source code enforment objects.&lt;br /&gt;
&lt;br /&gt;
Sometimes a complete code review approach is not suitable for most customers who wants to harden their code which is being approaching release stage. For such a reason, I started writing Java objects that embeds most of the security checks against common web vulnerabilities (XSS, SQL injection, Session handling, ...) so that source code can be hardened with a small effort in terms of code rewriting.&lt;br /&gt;
&lt;br /&gt;
I do believe that a common set of API and a common safe coding best practices library is one of the most important goals to bring application security to the developers.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* '''Objectives and Deliverables''':&lt;br /&gt;
Completing the static code review API section&lt;br /&gt;
* improving programming language to XML translator&lt;br /&gt;
* improving security best practices code review scan library&lt;br /&gt;
* improving secure coding fashion best practices library&lt;br /&gt;
* writing the pattern matching scan using the aformentioned libraries&lt;br /&gt;
Writing the java source code enforment objects&lt;br /&gt;
* writing an object to handle form data values to avoid XSS&lt;br /&gt;
* writing an object to handle form data values to avoid SQL Injection&lt;br /&gt;
* writing an object to handle HttpRequest and HttpSession objects&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* '''Why I should be sponsored for the project''':&lt;br /&gt;
Owasp Orizon is the first Owasp project I'm involved in. I'm also contributor of Owasp Italian chapter managed by Matteo Meucci and I'm talking at various speeches about application security and safe coding best practices.&lt;br /&gt;
&lt;br /&gt;
I'm a security consultant working in ethical hacking and we're approaching code review and safe topics right now.&lt;br /&gt;
I'm a developer too so I understand also the &amp;quot;dark side&amp;quot; of the problem developing code with security in mind.&lt;br /&gt;
&lt;br /&gt;
I work using the &amp;quot;release early release often&amp;quot; paradigm so to be concrete and let other people having something usable to work with.&lt;br /&gt;
&lt;br /&gt;
== Sebastien Deleersnyder - OWASP Education Project ==&lt;br /&gt;
* '''Executive Summary''':&lt;br /&gt;
This Education project aims to provide in building blocks of web application security information. These modules can be combined together in education tracks targeting different audiences. &lt;br /&gt;
&lt;br /&gt;
Web Application Security Education and Awareness is needed throughout the entire organization, each area and level of organizations have specific needs and requirements regarding education. A manager needs other information than a security professional or developer. Novices to the profession require other training than people with several years of experience. &lt;br /&gt;
&lt;br /&gt;
* '''Objectives and Deliverables''':&lt;br /&gt;
Currently the project goals are to create Educational Tracks: &lt;br /&gt;
* Complete the [[OWASP Education Presentation|consolidation page of OWASP presentations]] performed in the past&lt;br /&gt;
* A &amp;quot;Web Application Security Primer&amp;quot; Track for beginners (4 hours) &lt;br /&gt;
* A &amp;quot;What developers should know on Web Application Security&amp;quot; Track for developers (4 hours) &lt;br /&gt;
&lt;br /&gt;
* '''Why you should be sponsored for the project''': &lt;br /&gt;
I started the successful Belgian Chapter 3 years ago and have actively contributed to OWASP since then. I also co-organized the European conference last year in Belgium.&lt;br /&gt;
&lt;br /&gt;
This is the first separate project that I started, originating from a local demand to set up educational tracks for people that are new to Web Application Security. There are literally hundreds of presentations and an enormous amount of information on the OWASP web site. The goal of this project is to restructure pieces of that information in reusable modules that can be combined in educational tracks. It is my believe that awareness is an important cornerstone of building secure web applications, and this project will actively support that.&lt;br /&gt;
&lt;br /&gt;
If we are granted Spoc 007 participation, I will be sharing the budget with all active participants. This will be an extra motivation for project participation. I will reinvest my part in the project to set up a web conferencing / web casting solution to be used to disseminate the project results and make them available for later use.&lt;br /&gt;
&lt;br /&gt;
* '''More details''': &lt;br /&gt;
The detailed [[OWASP Education Project Roadmap|road map]] can be found here.&lt;br /&gt;
The SpoC 007 goal is to finish Sub Goals 1, 2, 3 and 4. If time permits we can start with sub goal 5.&lt;br /&gt;
&lt;br /&gt;
== Subere - OWASP JBroFuzz Project ==&lt;br /&gt;
&lt;br /&gt;
==== Overview ==== &lt;br /&gt;
&lt;br /&gt;
JBroFuzz is a stateless network protocol fuzzer that emerged from the needs of penetration testing. The purpose of this application is to provide a single, portable application that offers stable cross-platform network protocol fuzzing capabilities. At the same time, JBroFuzz attempts to keep the User Interface (UI) as intuitive as possible.&lt;br /&gt;
&lt;br /&gt;
==== Fuzzing ==== &lt;br /&gt;
&lt;br /&gt;
As seen by the emphasis given on the subject of fuzzing in the 2007 Testing Guide (v2), network protocol fuzzing serves as a fundamental cornerstone of application security testing. For this, many different categories and types of fuzzing have been defined.&lt;br /&gt;
&lt;br /&gt;
==== Objectives ==== &lt;br /&gt;
&lt;br /&gt;
JBroFuzz needs to expand and grow in order to cover network fuzzing in a more complete manner. Its modular implementation allows for the addtion of new functionality by means of independent tabs. The key tabs proposed to be added during the spring of code 2007 are (details in next section):&lt;br /&gt;
&lt;br /&gt;
* '''Open Source Tab'''&lt;br /&gt;
* '''NTLM Brute Force over HTTP/S Tab'''&lt;br /&gt;
* '''Pure HTTP/S Fuzzing using HTTPClient'''&lt;br /&gt;
* '''Blind SQL Injection Fuzzing Tab'''&lt;br /&gt;
&lt;br /&gt;
At the same time, the following existing tabs need to be updated and made more robust (details in next section):&lt;br /&gt;
&lt;br /&gt;
* '''TCP Fuzzing tab allowing graph outputs'''&lt;br /&gt;
* '''TCP Sniffing tab update thread Agent Queue'''&lt;br /&gt;
* '''Update Generators file format'''&lt;br /&gt;
* '''Include SOAP and XML fuzzing'''&lt;br /&gt;
&lt;br /&gt;
This expansion process relates to stabilising code that is presently included in JBroFuzz, thus allowing it to run for extensive periods of time (24h+) as well as adding more functionality in terms of the three new tabs.&lt;br /&gt;
&lt;br /&gt;
==== Deliverables ==== &lt;br /&gt;
&lt;br /&gt;
Based on the above, the new code elements that will be added are as follows:&lt;br /&gt;
&lt;br /&gt;
* '''Open Source Tab:''' ''Provide the ability to enumerate e-mails from newsgroups without breaching google automated search rules''&lt;br /&gt;
* '''NTLM Brute Force over HTTP/S Tab:''' ''Provide the ability to enumerate NTLM as well as brute over HTTP/S NTLM.''&lt;br /&gt;
* '''Pure HTTP/S Fuzzing:''' ''Implement a fuzzing tab utilising HTTPClient from Jakarta that will also allow for multi-threading''&lt;br /&gt;
* '''Blind SQL Fuzzing Tab''' ''Implement a tab that extracts information from a blind SQL injection point identified on web server over HTTP/HTTPS.''&lt;br /&gt;
&lt;br /&gt;
For updating existing code elements that require a partial rewrite, the following areas of focus are presented in detail: &lt;br /&gt;
&lt;br /&gt;
* '''TCP Fuzzing tab allowing graph outputs:''' ''Provide the ability to graph fuzzing results during a particular session run. This will give the ability to integrate and pickup potential fuzzing patterns.''&lt;br /&gt;
* '''TCP Sniffing tab update thread Agent Queue:''' ''Update the code of the sniffing panel in order to handle threaded agents in a more memory efficient way.''&lt;br /&gt;
* '''Update Generators file format:''' ''Update the generators file format to allow for the parsing and creation of recursive generators.''&lt;br /&gt;
* '''Include SOAP and XML fuzzing:''' ''Include an up to date list of SOAP and XML fuzzing templates.''&lt;br /&gt;
&lt;br /&gt;
Overall, the above two lists of changes should provide sufficient complexity and output for the spring of code 2007, forming a challenging implementation project.&lt;br /&gt;
&lt;br /&gt;
==== Background ==== &lt;br /&gt;
&lt;br /&gt;
In its short life, the OWASP JBroFuzz Project has attracted the interest of the online security community with a total of appr. 5000 downloads in the last months. &lt;br /&gt;
&lt;br /&gt;
Coming from a strong java background (5+ years) I decided to implement and release JBroFuzz in order to initially simplify penetrations testing processes that relate to web application and network protocol fuzzing.&lt;br /&gt;
&lt;br /&gt;
I see the spring of code 2007 as a unique opportunity to industrialise network protocol fuzzing (and in particular HTTP/S fuzzing) within a single application, residing within OWASP.&lt;br /&gt;
&lt;br /&gt;
==== Why should JBroFuzz be sponsored? ==== &lt;br /&gt;
&lt;br /&gt;
Centralising fuzzing resources into one application that has the ability to handle network protocol fuzzing over HTTP and HTTPS in a simple and intuitive manner forms an area of focus that should not be dismissed in building secure software applications.&lt;br /&gt;
&lt;br /&gt;
Keep the code platform independent adds a huge advantage. &lt;br /&gt;
&lt;br /&gt;
Receving an OWASP grant from the spring of code 2007 will trigger a share in the budget with all active participants depending on their level of involvement. This will be a direct function of the number of tabs and/or user functionality that they have assisted in implementing.&lt;br /&gt;
&lt;br /&gt;
== Joshua Perrymon - OWASP LiveCD Project ==&lt;br /&gt;
* '''Executive Summary''':&lt;br /&gt;
I am proposing that I complete the second version of the OWASP LiveCD during this period.&lt;br /&gt;
The first version of the LiveCD is now available and include many of the current OWASP documents and tools. I believe the LiveCD is one of the best mediums to promote OWASP tools and documentation. It is portable and already being used by thousands of security proffesionals to perform application testing and training. &lt;br /&gt;
&lt;br /&gt;
In the current state the CD is stable and contains a lot of tools. However, this is just the beginning. There is a LOT of work that needs to be completed. The entire CD experience needs to be branded using OWASP graphics. This shouls start with the boot screen and carry all the way through to the icons and desktop graphics. The CD should also inlcude the wiki and ALL the tools developed for OWASP.&lt;br /&gt;
&lt;br /&gt;
* '''Objectives and Deliverables''':&lt;br /&gt;
&lt;br /&gt;
Update of the LiveCD:&lt;br /&gt;
* Complete OWASP branding&lt;br /&gt;
* Add OWASP wiki&lt;br /&gt;
* Add encryption capabilities&lt;br /&gt;
* Add more OWASP tools&lt;br /&gt;
* Add more pen-test tools such as;&lt;br /&gt;
 VOIP, RFID, BlueTooth, Wireless, etc..&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* '''Why I should be sponsored for the project''':&lt;br /&gt;
&lt;br /&gt;
I had the idea of the LiveCD about a year ago and have worked very hard to get the first version developed. This was driven by my vision to make all of the OWASP tools available on a portable medium. The main difference in the OWASP liveCD vs. other live CDs is going to be the regularity of updates. If sponsorship can be obtained the CD could be updated on a monthly basis. Not once a year like other liveCDs. The CD will also include specialty tools and documentation to perform VOIP, RFID,Bluetooth, and wireless security assessments.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
== Mark Curphey – The OWASP Web Security Certification Framework ==&lt;br /&gt;
&lt;br /&gt;
'''Problem'''&lt;br /&gt;
 &lt;br /&gt;
PCI DSS is attracting a lot of criticism for a lot of valid reasons. &lt;br /&gt;
 &lt;br /&gt;
http://securitybuddha.com/2007/03/23/the-problems-with-the-pci-data-security-standard-part-1/&lt;br /&gt;
&lt;br /&gt;
http://blogs.csoonline.com/node/210&lt;br /&gt;
&lt;br /&gt;
http://www.computerweekly.com/blogs/stuart_king/2007/03/more-on-pci---the-audit-guide.html&lt;br /&gt;
&lt;br /&gt;
The list is of course long and not appropriate here……and while its easy to knock PCI, there is nothing better out there. &lt;br /&gt;
&lt;br /&gt;
'''Solution and Deliverables'''&lt;br /&gt;
&lt;br /&gt;
As opposed to me continuing saying what’s wrong with PCI DSS, it seems to me that OWASP is a perfect forum to simply create and publish a “better criteria”. This can either be adopted and implemented by an organization like OWASP or considered to be incorporated into the PCI or other security standards. We won't get bogged down in the politics up-front, but hold something good up to the world for people to adopt. This project would of course draw on and bring together many of the other OWASP Projects including the Guide (What is a secure web app), Testing Guides (How to test for a secure web app), WebGoat (part of how to certify an individual understands and can find web app issues) etc. Many of those projects may not be complete or a perfect fit today, but this project can bring a common connecting theme to a lot of very valuable IP that OWASP has built over the years. I will also create it in such as way that a corporate could adopt/adapt it themseles as well as an industry. Where other OWASP projects are not complete or currently suitable I will build a requirements doc that can be considered by those teams if they feel appropriate. &lt;br /&gt;
&lt;br /&gt;
This project would address the;&lt;br /&gt;
&lt;br /&gt;
'''Standard''' &lt;br /&gt;
*A complete auditable (important) web site security standard suitable for modern e-commerce companies including&lt;br /&gt;
**The technical things people should care about&lt;br /&gt;
**The operational  / management things people should care about&lt;br /&gt;
'''Certification Model''' &lt;br /&gt;
*A complete framework for certification (ongoing) and implementation (including certifying auditors, ongoing validation etc). This will include for example the model for certifying auditors (including the actual test program); checklists and forms for auditors to complete and other supporting material. &lt;br /&gt;
&lt;br /&gt;
Essentially its a complete blueprint for an organisation like OWASP or a regulatory body need to run a web site security certification program complete with the supporting material to implement it.&lt;br /&gt;
&lt;br /&gt;
Note:  This is no trivial task to get right. I would need to ensure I can commit to completing the work to a good quality. I think this will take at least 2 months from start to finish to complete but I think is very important for the industry and for potentially for OWASP.  I wanted to gauge the interest by first posting this.&lt;br /&gt;
&lt;br /&gt;
== Erwin Geirnaert - OWASP Java Project ==&lt;br /&gt;
&lt;br /&gt;
* '''Executive Summary''':&lt;br /&gt;
I would like to help the OWASP Java Project to gather all Java security related information and to document any domains that lack documentation.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* '''Objectives and Deliverables''':&lt;br /&gt;
The main objective I see is to gather all information in one place, where security experts and developers can find the information they need.&lt;br /&gt;
In order to get there, I need to collect all information in the OWASP Wiki, ask people if they want to donate it to OWASP so that we can include it as public material, add URLs, white-papers, references to books, ... And if time permits, write some documentation myself.&lt;br /&gt;
&lt;br /&gt;
One deliverable is the OWASP Top 10 for J2EE applications with clear examples of vulnerabilities and mitigations.&lt;br /&gt;
&lt;br /&gt;
* '''Why you should be sponsored for the project''':&lt;br /&gt;
I have more then 10 years experience in Java and J2EE and the last 6 years I have tested and broke a lot of web applications. I gave also some very successful J2EE security courses and web security courses. I spoke at different conferences about application security in Europe.&lt;br /&gt;
And I am responsible for the security track at Javapolis, one of the biggest Jave conferences in Europe.&lt;br /&gt;
I am the co-founder of ZION SECURITY where we do security testing, code review, design reviews, training,...&lt;br /&gt;
I'm also member of the OWASP Belgium board that started in March 2007.&lt;br /&gt;
&lt;br /&gt;
== Erwin Geirnaert - OWASP WebGoat Solutions Guide ==&lt;br /&gt;
&lt;br /&gt;
* '''Executive Summary''':&lt;br /&gt;
WebGoat is used by a lot of people to learn about web application security and the different vulnerabilities. But it takes a lot of time to grasp how the tools like WebScarab work and how to use them effectively in WebGoat. I propose to create a walkthrough of the lessons in WebGoat so that people can learn from the solutions, without spoiling the fun.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* '''Objectives and Deliverables''':&lt;br /&gt;
The WebGoat Solutions Guide is a document that can be bundled with WebGoat. Each lesson contains a detailed solution with screenshots and tools. I created a PDF with the solution for WebGoat 4.0 but this is too big to load (15 MB) and is not very practical.&lt;br /&gt;
&lt;br /&gt;
After a discussion with Bruce about this, we think that the solutions should be made like the existing Lessons Plan so it is easier to maintain and update when a lesson changes. This means that there will be documentation folder and an individual solution for each lesson. &lt;br /&gt;
&lt;br /&gt;
* '''Why you should be sponsored for the project''':&lt;br /&gt;
I have more then 10 years experience in Java and J2EE and the last 6 years I have tested and broke a lot of web applications. I gave also some very successful J2EE security courses and web security courses. I spoke at different conferences about application security in Europe.&lt;br /&gt;
And I am responsible for the security track at Javapolis, one of the biggest Jave conferences in Europe.&lt;br /&gt;
I am the co-founder of ZION SECURITY where we do security testing, code review, design reviews, training,...&lt;br /&gt;
I'm also member of the OWASP Belgium board that started in March 2007.&lt;br /&gt;
&lt;br /&gt;
== Bunyamin Demir – OWASP WeBekci Project ==&lt;br /&gt;
&lt;br /&gt;
==== Executive Summary: ====&lt;br /&gt;
&lt;br /&gt;
Web application firewalls (WAF) are gaining importance among the information security technologies designed to protect web sites from attack. WAF solutions prevent attacks that network firewalls and intrusion detection systems can't and they require no modification of application source code. ModSecurity [http://www.modsecurity.org/] is an open source web application firewall that runs as an Apache module. It is an embeddable web application firewall and it provides protection from a range of attacks against web applications. It is an open source project available to everyone; it however does not come with an admin panel. &lt;br /&gt;
&lt;br /&gt;
I decided to provide this essential tool with a control panel which I believe will ease and thus encourage its usage.&lt;br /&gt;
&lt;br /&gt;
ModSecurity allows for HTTP traffic monitoring and real-time analysis with no changes to existing infrastructure. My main goal is to analyze attacks and generate rules to change the configuration of the ModSecurity accordingly.&lt;br /&gt;
&lt;br /&gt;
ModSecurity  has a feature called “flexible rule engine” as its heart of Attack Prevention capability . It uses ModSecurity’s “Rule Language,” (a programming language designed to work with HTTP transaction data). It is easy to use and flexible; yet the system administrators need to learn its own rules to create what is called “Certified ModSecurity Rules” to be implemented. My control panel will automate the major code-generation in Rule Language. &lt;br /&gt;
&lt;br /&gt;
==== Objectives and Deliverables: ====&lt;br /&gt;
&lt;br /&gt;
* '''Configuration''' : Will add all configuration parameter&lt;br /&gt;
* '''Rule Generator''': Will write all the Rules in Rule Language&lt;br /&gt;
* '''Logging'''       : Auditlog and debuglog will be added.&lt;br /&gt;
* '''Multiple-DB'''   : Will add PostgreSql and Sqlite support.&lt;br /&gt;
&lt;br /&gt;
==== Why I should be sponsored for the project: ====&lt;br /&gt;
&lt;br /&gt;
I am  involved with OWASP Turkey [http://www.owasp.org/index.php/Turkey] and interested very much in WAF. Even though this is my first project for OWASP, I am very much interested in every aspect of ModSecurity. With SpoC007’s support I will finalize my work on OWASP WeBekci [http://www.owasp.org/index.php/Category:OWASP_WeBekci_Project].&lt;br /&gt;
&lt;br /&gt;
== Eric Sheridan and Dr. Goran Trajkovski - The Scholastic Application Security Assessment Project ==&lt;br /&gt;
&lt;br /&gt;
=== ABSTRACT ===&lt;br /&gt;
&lt;br /&gt;
One of the major goals of the Open Web Application Security Project is to educate developers in the field of application software security. Understanding the risks and threats associated with web application software is pivotal in building a mature application security process. While OWASP has made a significant impact in the professional industry, more time and energy should be focused towards the academic community. It is an unfortunate fact that most universities do not require a stringent software security course for their computer science students. Consequently, most young developers do not have the ability to assess and mitigate the risks and threats for their own applications. It is for this reason that we believe the Open Web Application Security Project should fund an initiative to encourage the adaptation of application software security methodologies in the academic course curriculum.&lt;br /&gt;
&lt;br /&gt;
The Scholastic Application Security Project is intended to be the first step towards integrating security requirements in academic course curriculums. The primary goal of the project is to give students hands-on experience performing application security assessments using the tools and documentation found at http:///www.owasp.org. The assessment, lead by an application security professional, will demonstrate to students how the information and tools found at OWASP can be used to assess and ultimately increase the overall security posture of a web application. &lt;br /&gt;
&lt;br /&gt;
This project contributes towards bridging the gap between academia and industry, by equipping students with hands-on ready-for-the-job-market skills in the application software securing industry.&lt;br /&gt;
&lt;br /&gt;
=== PARTICIPANTS ===&lt;br /&gt;
&lt;br /&gt;
The Scholastic Application Security Assessment Project requires that college level students, lead by an application security professional, perform a security audit on an open source web application using the tools and information available at OWASP.&lt;br /&gt;
&lt;br /&gt;
::*'''Application Security Professional''' – Eric Sheridan ([http://www.aspectsecurity.com Aspect Security])&lt;br /&gt;
::*'''Towson University (TU) Partner''' – Dr. Goran Trajkovski, Towson University (http://www.towson.edu)&lt;br /&gt;
::*'''Students''' – Students of TU’s Application Software Security Course (COSC 458), nominated by the TU Partner&lt;br /&gt;
::*'''Web Application''' – The Open WebMail Project (http://openwebmail.org/)&lt;br /&gt;
&lt;br /&gt;
=== OWASP UTILIZATION ===&lt;br /&gt;
&lt;br /&gt;
The Scholastic Application Security Assessment Project requires heavy utilization of existing OWASP tools and utilities. Through this requirement, the project will illustrate the fact that existing OWASP resources can be used and heavily relied upon in a professional security audit. The following is a list of notable OWASP resources whose use will be documented throughout the assessment:&lt;br /&gt;
&lt;br /&gt;
::*'''OWASP Top Ten 2007''' - The security critical areas that the students will assess in the review&lt;br /&gt;
::*'''OWASP Testing Guide v2''' – The primary resource for building penetration testing cases&lt;br /&gt;
::*'''OWASP Guide''' – The primary resource for technical details pertaining to a technology and/or vulnerability&lt;br /&gt;
::*'''OWASP WebScarabNG''' – The primary proxy utility used throughout the assessment&lt;br /&gt;
&lt;br /&gt;
=== THE FINAL REPORT ===&lt;br /&gt;
&lt;br /&gt;
Students are required to follow the principle of “responsible disclosure” during the course of the security assessment. The developers of the open source application will be notified if any significant issues are found. Once the assessment is complete, a final report will be delivered to the application developers and the appropriate OWASP Spring of Code personnel. For each finding in the report, the students will be required to describe how the tools and information found at OWASP were used in the discovery.&lt;br /&gt;
&lt;br /&gt;
=== HOW DOES OWASP BENEFIT? ===&lt;br /&gt;
&lt;br /&gt;
The Scholastic Application Security Assessment Project is specifically designed to benefit the OWASP brand:&lt;br /&gt;
&lt;br /&gt;
''The OWASP Community…''&lt;br /&gt;
::*will be provided a case study proving that the resources available at OWASP can be utilized in an academic  environment, that can be later used in advertising the OWASP efforts to similar programs as the one at TU.&lt;br /&gt;
::*will be providing students a hands on experience in learning and testing for the latest web application security threats, thus potentially enlarging the OWASP community of contributors and supporters.&lt;br /&gt;
::*will be addressing the need to educate developers in the security critical areas.&lt;br /&gt;
::*will be seen as offering a professional level service to another open source project.&lt;br /&gt;
::*will be addressing one of the root causes of application software insecurity.&lt;br /&gt;
&lt;br /&gt;
=== BACKGROUND ===&lt;br /&gt;
&lt;br /&gt;
'''Eric Sheridan:'''&lt;br /&gt;
&lt;br /&gt;
::*Earned a Bachelor’s of Science in Computer Science from Towson University&lt;br /&gt;
::*Graduate Student in Information Security at Johns Hopkins University&lt;br /&gt;
::*Application Security Engineer at Aspect Security&lt;br /&gt;
::*Lead of the OWASP Stinger Project and the OWASP Validation Project&lt;br /&gt;
&lt;br /&gt;
'''Goran Trajkovski, PhD:'''&lt;br /&gt;
&lt;br /&gt;
::*Has been teaching the Application Software Security course for the Computer Security undergraduate and master-level majors at TU since 2004 (TU has been a Center of Excellence in Information Assurance, designated by the NSA since 2002).&lt;br /&gt;
::*Assistant professor of Computer and Information Sciences at Towson University, and Director of its Cognitive Agency and Robotics Lab (CARoL).&lt;br /&gt;
::*Has lead curricular efforts in integrating application software security topics throughout the Computer Science and Computer Information Sciences curriculum&lt;br /&gt;
::*12 years of full time teaching experience in higher ed.&lt;br /&gt;
&lt;br /&gt;
==Boris - OWASP Site Generator==&lt;br /&gt;
OWASP Site Generator is a great tool, but it could be even better and more widespread. There’s a lot room for improvements to both its functionality and user experience. The way I see it, main user needs to be addressed and specific development objectives for the next release of OWASP Site Generator would be:&lt;br /&gt;
===User Needs===&lt;br /&gt;
*Create multiple types of sites easily&lt;br /&gt;
*Track and analyze requests easily&lt;br /&gt;
*Change the look and feel of the resulting sites easily&lt;br /&gt;
*Create sites for multiple web backend technologies easily&lt;br /&gt;
*Learn how to use OWASP Site Generator easily&lt;br /&gt;
&lt;br /&gt;
===Development Objectives===&lt;br /&gt;
*Create a vulnerability library that can be used for web services, HTML forms, AJAX, etc. instead of having to craft the same attack for each&lt;br /&gt;
*Add support for logging of all received requests, as well as querying resulting log files&lt;br /&gt;
*&amp;amp;quot;Templatize&amp;amp;quot; the code generation process, so it can support skinning of the resulting sites&lt;br /&gt;
*&amp;amp;quot;Templatize&amp;amp;quot; the code generation process, so it can support different backend web technologies&lt;br /&gt;
*Fix all significant defects in the current release of OWASP Site Generator&lt;br /&gt;
*Redesign the GUI to make it more efficient and user friendly&lt;br /&gt;
*Create a smooth setup program which would install both client and server components as effortlessly as possible&lt;br /&gt;
*Write documentation and articles about it&lt;br /&gt;
*Make the development process open to the public and, hopefully, driven by its feedback from day one&lt;br /&gt;
&lt;br /&gt;
===Why should I be sponsored for this project===&lt;br /&gt;
Well, probably because of my past work on AoC (I just hope that won’t be the reason for me ''not'' to be sponsored :)&lt;br /&gt;
&lt;br /&gt;
==Boris - OWASP Report Generator==&lt;br /&gt;
There is no doubt that OWASP Report Generator is a very handy tool for penetration testers and other security researchers, but it would be even better if some enhancements were made:&lt;br /&gt;
===User Needs===&lt;br /&gt;
*More robustness&lt;br /&gt;
*Ease of use (more efficient and intuitive GUI)&lt;br /&gt;
*Automated reporting for some typical (or not so typical) scenarios&lt;br /&gt;
*More documentation&lt;br /&gt;
*More samples&lt;br /&gt;
&lt;br /&gt;
===Development Objectives===&lt;br /&gt;
*Redesign the GUI to make it more efficient and user friendly&lt;br /&gt;
*Clean up the code&lt;br /&gt;
*Add functionality to import, execute and create reports for OWASP Tiger automated tests&lt;br /&gt;
*Create some samples&lt;br /&gt;
*Create a smooth setup program&lt;br /&gt;
*Write documentation and articles about it&lt;br /&gt;
*Make the development process open to the public and, hopefully, driven by its feedback from day one&lt;br /&gt;
===Why should I be sponsored for this project===&lt;br /&gt;
Well, probably because of my past work on AoC (I just hope that won’t be the reason for me ''not'' to be sponsored :)&lt;br /&gt;
&lt;br /&gt;
==Boris - OWASP Tiger==&lt;br /&gt;
OWASP Tiger project is at its very beginning. Some new features are needed in order for it to become more useful. Here’s a short list:&lt;br /&gt;
===User Needs===&lt;br /&gt;
*Easier editing of test projects&lt;br /&gt;
*Support for testing sites that require authentication&lt;br /&gt;
*Support for testing sites that require use of cookies&lt;br /&gt;
*An easy way of specifying vulnerability data, ideally an automated one&lt;br /&gt;
*More flexible reporting&lt;br /&gt;
*More project templates&lt;br /&gt;
*More documentation&lt;br /&gt;
===Development Objectives===&lt;br /&gt;
*Add support for cookies&lt;br /&gt;
*Add support for standard authentication schemes&lt;br /&gt;
*Add support for importing vulnerability data from a test definition (or a vulnerability library)&lt;br /&gt;
*Make use of OWASP Report Generator for more advanced reports&lt;br /&gt;
*Create a setup program that would install both client and project templates and also allow for adding new templates after the initial installation&lt;br /&gt;
*Write documentation and articles about it&lt;br /&gt;
*Make the development process open to the public and, hopefully, driven by its feedback from day one&lt;br /&gt;
===Why should I be sponsored for this project===&lt;br /&gt;
Well, probably because of my past work on AoC (I just hope that won’t be the reason for me ''not'' to be sponsored :)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Heiko - Web Application Security put into practice==&lt;br /&gt;
I'm trying to make the OWASP Top Ten and Guide project known in the programming community, but I understand that clear examples in the specific programming language and best practices with explanation educate the best. I'm at the chair for secure software at my university and I want to contribute practical examples, because I believe not to teach secure programming is a great oversight in today's education. Not only the programmers in large companies have to be aware of security impacts, but also their future employees and their freelance programmers. I'm with a large organization of freelance programmers, which I want to make aware of security flaws.&lt;br /&gt;
&lt;br /&gt;
The Ruby on Rails Security project [http://www.rorsecurity.info/] started this year and is the only security initiative for Ruby on Rails. Ruby is the fastest growing level A programming language, according to the Tiobe programming community index [http://www.tiobe.com/tpci.htm], partly because of its advertised simplicity. This is dangerous, as programmers could be enticed to do cargo cult programming [http://en.wikipedia.org/wiki/Cargo_cult_programming] without knowing the security impacts. I found several security holes in popular modules, and even the Rails framework itself generates potentially insecure code. Nevertheless, Rails provides good means against many of the OWASP Top Ten security flaws, but I believe these means have to be popularized much more.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Objectives and Deliverables===&lt;br /&gt;
* Create a security guide to the most popular web server software, Apache&lt;br /&gt;
** Installation&lt;br /&gt;
** secure configuration, emphasis on Rails, but not limited to it&lt;br /&gt;
** file system privileges for Rails and Apache&lt;br /&gt;
** anti profiling techniques for Apache&lt;br /&gt;
** Modules and Mod_security configuration&lt;br /&gt;
&lt;br /&gt;
* Create a security guide to the popular database software, MySQL, as practical contribution to the OWASP Top 10 Insecure storage section&lt;br /&gt;
** Installation&lt;br /&gt;
** secure configuration, emphasis on Rails, but not limited to it&lt;br /&gt;
** file system privileges for Rails and MySQL&lt;br /&gt;
** MySQL access restriction techniques&lt;br /&gt;
** encryption methods&lt;br /&gt;
&lt;br /&gt;
* Ruby on Rails security guide and code examples, with at least the following topics:&lt;br /&gt;
** Anti profiling techniques&lt;br /&gt;
** Rails routes security&lt;br /&gt;
** error handling and presentation, as in OWASP Top 10 Improper Error Handling&lt;br /&gt;
** OWASP Top 10: XSS in Rails&lt;br /&gt;
** OWASP Top 10: SQL injection in Rails&lt;br /&gt;
** OWASP Top 10: Parameter injection in Rails&lt;br /&gt;
** OWASP Top 10: Session handling in Rails&lt;br /&gt;
** OWASP Top 10: Access control in Rails&lt;br /&gt;
** handling of files&lt;br /&gt;
** integrity&lt;br /&gt;
** encryption and SSL&lt;br /&gt;
** logging flaws&lt;br /&gt;
** Ajax security&lt;br /&gt;
&lt;br /&gt;
* Code &amp;amp; other&lt;br /&gt;
** means to check the security of MySQL&lt;br /&gt;
** input validation guide, and implement it in Ruby&lt;br /&gt;
** update the poorly documented guide at http://manuals.rubyonrails.com/read/chapter/40 which is the only official guide to security&lt;br /&gt;
** usage guide for OWASP tools, also in connection with Rails&lt;br /&gt;
** make the results known in the several communities I'm in&lt;br /&gt;
** if applicable: submit code to Rails for security holes found&lt;br /&gt;
&lt;br /&gt;
===Why I should be sponsored for the project===&lt;br /&gt;
I have been programming professionally for 10 years and created several software products, including Internet applications, and I always focused on security. I am currently graduating university, my thesis is about web application security. Recently, I started the Ruby on Rails security project, which is the only security project for Rails. I have always delivered my work on time, and I believe I have the knowledge to deliver good quality.&lt;br /&gt;
&lt;br /&gt;
===Long-term vision for the project===&lt;br /&gt;
Make it available to the community and accept security notices and best practices from other users to constantly improve it.&lt;br /&gt;
&lt;br /&gt;
===Benefits to the OWASP===&lt;br /&gt;
* practical guides on how to put security into practice: the most popular web server software Apache and the popular database software MySQL&lt;br /&gt;
* if applicable: additional examples and chapters for the OWASP Guide&lt;br /&gt;
* the first and only fully-fledged security guide to a programming language and framework which is used by many large companies&lt;br /&gt;
* security awareness of future employees and freelancers&lt;br /&gt;
* more exposure of the OWASP&lt;br /&gt;
&lt;br /&gt;
==Denis – Python Tainted Mode==&lt;br /&gt;
I am graduate student of Moscow State University, department of Computational Mathematics and Cybernetics.&lt;br /&gt;
My graduate work is dedicated to web-application security. The goal of my graduate work is to combine dynamic code analysis with penetration testing to provide more precise analysis.&lt;br /&gt;
This work will help to find security vulnerabilities in web-applications.&lt;br /&gt;
I successfully presented parts of my work at university conferences.&lt;br /&gt;
&lt;br /&gt;
===My Project===&lt;br /&gt;
The goal of my project is to create analog of Perl’s Taint Mode for Python programming language.&lt;br /&gt;
Taint mode is successfully used in Perl, PHP, and Ruby to find input validation vulnerabilities in web-applications (see for ex. PHPRevent[http://dependability.cs.virginia.edu/info/PHPrevent]).&lt;br /&gt;
Unfortunately there is no implementation of Taint Mode for Python language despite of wide spread of Python-based web-applications. Taint Mode for Python is highly claimed.&lt;br /&gt;
I plan to modify Python interpreter and add Taint label propagation. Then I’ll add three configuration lists:&lt;br /&gt;
* List of sources. All data emanating from sources must be marked tainted.&lt;br /&gt;
* List of critical functions, that shouldn’t receive tainted data.&lt;br /&gt;
* List of sanitizing functions that untaints data.&lt;br /&gt;
These three lists are dependent on technology that is used between web-server and web-applications in web server. In my project I plan to build such lists for mod_python and then broaden for other technologies. With switched on taint mode web-application will receive exceptions when critical function receives tainted data.&lt;br /&gt;
&lt;br /&gt;
===Why should I be selected===&lt;br /&gt;
I have strong mathematical &amp;amp; computer science background. I’m familiar with research publications on dynamic analysis and with implementation of taint mode in Perl and PHP (PHPrevent Project).&lt;br /&gt;
This project is part of my work at university. It will be made under mentoring of my scientific advisor.&lt;br /&gt;
This work is already practically done that’s why I’m sure I will finish my project in time.&lt;br /&gt;
I have strong skills in developing projects with Python, Java, C, C++, and Assembler. Then I plan to support, develop and enhance my project and increase its quality with penetration testing.&lt;br /&gt;
&lt;br /&gt;
If you have any questions or would like further information, feel free to contact me.&lt;br /&gt;
&lt;br /&gt;
Yours faithfully,&lt;br /&gt;
Denis&lt;br /&gt;
&lt;br /&gt;
== Darren Edmonds - WebScarab NG Security Test Automation ==&lt;br /&gt;
&lt;br /&gt;
=== Background ===&lt;br /&gt;
I am a 28 year old software developer from the UK with a background in java based web development and application security testing.  I have strong mathematical skills, a degree in software engineering, a SCJP qualification and 8 years of commercial development experience.  I have created many web based and standalone applications delivering on time and adhering to common software practices.&lt;br /&gt;
I'm an avid supporter of open source software and try to use it whenever possible in a commercial environment.  I've made contributions to the Geotools mapping project, written a securing tomcat article for OWASP and developed a full modification for the first person shooter Quake 3.&lt;br /&gt;
&lt;br /&gt;
=== Project Details ===&lt;br /&gt;
Having used numerous penetration testing applications I believe there is a need for an open source application which supports some, or all, of the features of the more expensive commercial products.  I propose to make WebScarab generate, record, and playback security test cases so that regression testing is possible.  If time permits I would also like to include some extra automated tests that are not always feasible during manual testing; searching for backup files (~, Copy of X), checking non-authorised access to authorised areas, common and brute force name directory searching, etc.  Perhaps include the ability to read the test database of other scanning tools such as nikto.&lt;br /&gt;
I have already made contact with Rogan Dawes, original WebScarab NG author, to discuss some initial ideas.  I believe it is important that Rogan is consulted during the initial planning phase to make sure the project keeps to a set of consistent guidelines.&lt;br /&gt;
&lt;br /&gt;
=== Milestones ===&lt;br /&gt;
* Research regression testing features in other applications&lt;br /&gt;
* Create a functional specification&lt;br /&gt;
* Build testing framework (possible inclusion of scripting language for user defined tests)&lt;br /&gt;
* Testing&lt;br /&gt;
&lt;br /&gt;
=== Why I Should be Sponsored ===&lt;br /&gt;
I believe I am an ideal candidate to develop the proposed additions to WebScarab NG, not just because of my qualifications and experience, but because I plan to use WebScarab NG in my work to help perform the initial testing of web applications.  As well as my own time my current employer will allocate me a set amount of time to ensure the project achieves its milestones.&lt;br /&gt;
The end result will make WebScarab NG a much more powerful testing tool and will be a great asset to the OWASP community.  With continued development and input from the community I see no reason why WebScarab NG cannot rival commercial testing application features, usability, and business benefit.  Increasing WebScarab's features will result in increased community awareness bringing in extra developers, ensuring continual development and so the cycle starts again.&lt;/div&gt;</summary>
		<author><name>Dledmonds</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Securing_tomcat&amp;diff=15145</id>
		<title>Securing tomcat</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Securing_tomcat&amp;diff=15145"/>
				<updated>2007-01-09T11:07:24Z</updated>
		
		<summary type="html">&lt;p&gt;Dledmonds: /* Logging */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
Most weaknesses in [http://tomcat.apache.org/ Apache Tomcat] come from incorrect or inappropiate configuration.  It is nearly always possible to make Tomcat more secure than the default out of the box installation.  What follows documents best practices and recommendations on securing a production Tomcat server, whether it be hosted on a Windows or Unix based operating system.  ''Please note that the section ordering is not a representation of the section importance.''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Software Versions ==&lt;br /&gt;
&lt;br /&gt;
The first step is to make sure you are running the latest stable releases of software;&lt;br /&gt;
* Java Runtime Environment (JRE) or SDK&lt;br /&gt;
* Tomcat&lt;br /&gt;
* Third party libraries&lt;br /&gt;
This does not mean you have to upgrade all your production servers to a new (and potentially buggy) release which has just been made available to the public.  What you must do is download the latest stable bugfix release that has continual support.  For the JRE and Tomcat you should be looking at the last digits in the version number (5.5.'''X''') as it represents the bugfix information.  The bugs fixed in these releases are publicly available so if you don't upgrade you could be providing attackers with a very easy route to compromise your server.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Installation of Apache Tomcat 5.5 ==&lt;br /&gt;
&lt;br /&gt;
=== UNIX ===&lt;br /&gt;
&lt;br /&gt;
* Create a tomcat user/group&lt;br /&gt;
* Download and unpack the core distribution (referenced as '''CATALINA_HOME''' from now on)&lt;br /&gt;
* Change '''CATALINA_HOME''' ownership to tomcat user and tomcat group&lt;br /&gt;
* Change files in '''CATALINA_HOME'''/conf to be readonly (400)&lt;br /&gt;
* Make sure tomcat user has read/write access to /tmp and write (300 - yes, only write/execute) access to '''CATALINA_HOME'''/logs&lt;br /&gt;
&lt;br /&gt;
=== Windows ===&lt;br /&gt;
&lt;br /&gt;
* Download the core windows service installer&lt;br /&gt;
* Start the installation, click ''Next'' and ''Agree'' to the licence&lt;br /&gt;
* Untick ''native'', ''documentation'', ''examples'' and ''webapps'' then click ''Next''&lt;br /&gt;
* Choose an installation directory (referenced as '''CATALINA_HOME''' from now on), preferably on a different drive to the OS.  &lt;br /&gt;
* Choose an administrator username (NOT admin) and a secure password that complies with your organisations password policy.&lt;br /&gt;
* Complete tomcat installation, but do not start service.&lt;br /&gt;
&lt;br /&gt;
=== Common ===&lt;br /&gt;
&lt;br /&gt;
* Remove everything from '''CATALINA_HOME'''/webapps (ROOT, balancer, jsp-examples, servlet-examples, tomcat-docs, webdav)&lt;br /&gt;
&lt;br /&gt;
* Remove everything from '''CATALINA_HOME'''/server/webapps (host-manager, manager).  Note that it can be useful to keep the manager webapp installed if you need the ability to redeploy without restarting Tomcat.  If you choose to keep it please read the section on Securing the Manager WebApp.&lt;br /&gt;
&lt;br /&gt;
* Remove '''CATALINA_HOME'''/conf/Catalina/localhost/host-manager.xml and '''CATALINA_HOME'''/conf/Catalina/localhost/manager.xml (again, if you are keeping the manager application, do not remove this).&lt;br /&gt;
&lt;br /&gt;
* Make sure the default servlet is configured '''not''' to serve index pages when a welcome file is not present.  In '''CATALINA_HOME'''/conf/web.xml&lt;br /&gt;
  &amp;lt;servlet&amp;gt;&lt;br /&gt;
    &amp;lt;servlet-name&amp;gt;default&amp;lt;/servlet-name&amp;gt;&lt;br /&gt;
    &amp;lt;servlet-class&amp;gt;org.apache.catalina.servlets.DefaultServlet&amp;lt;/servlet-class&amp;gt;&lt;br /&gt;
    &amp;lt;init-param&amp;gt;&lt;br /&gt;
      &amp;lt;param-name&amp;gt;debug&amp;lt;/param-name&amp;gt;&lt;br /&gt;
      &amp;lt;param-value&amp;gt;0&amp;lt;/param-value&amp;gt;&lt;br /&gt;
    &amp;lt;/init-param&amp;gt;&lt;br /&gt;
    &amp;lt;init-param&amp;gt;&lt;br /&gt;
      &amp;lt;param-name&amp;gt;listings&amp;lt;/param-name&amp;gt;&lt;br /&gt;
      &amp;lt;param-value&amp;gt;'''false'''&amp;lt;/param-value&amp;gt;  &amp;amp;lt;!-- make sure this is false --&amp;amp;gt;&lt;br /&gt;
    &amp;lt;/init-param&amp;gt;&lt;br /&gt;
    &amp;lt;load-on-startup&amp;gt;1&amp;lt;/load-on-startup&amp;gt;&lt;br /&gt;
  &amp;lt;/servlet&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Remove version string from HTTP error messages by repacking '''CATALINA_HOME'''/server/lib/catalina.jar with an updated ServerInfo.properties file.&lt;br /&gt;
:unpack catalina.jar&lt;br /&gt;
  cd CATALINA_HOME/server/lib&lt;br /&gt;
  jar xf catalina.jar org/apache/catalina/util/ServerInfo.properties&lt;br /&gt;
:update ServerInfo.properties by changing server.info line to server.info=Apache Tomcat&lt;br /&gt;
:repackage catalina.jar&lt;br /&gt;
  jar uf catalina.jar org/apache/catalina/util/ServerInfo.properties&lt;br /&gt;
:remove CATALINA_HOME/server/lib/org (created when extracting the ServerInfo.properties file)&lt;br /&gt;
&lt;br /&gt;
* Replace default error page (default is stacktrace) by adding the following into '''CATALINA_HOME'''/conf/web.xml.  The default error page shows a full stacktrace which is a disclosure of sensitive information.  ''The following solution is not ideal as it produces a blank page because Tomcat cannot find the file specified, but without a better solution this, at least, achieves the desired result.  A well configured web application will override this default in CATALINA_HOME/webapps/APP_NAME/WEB-INF/web.xml so it won't cause problems.''&lt;br /&gt;
  &amp;lt;error-page&amp;gt;&lt;br /&gt;
    &amp;lt;exception-type&amp;gt;java.lang.Exception&amp;lt;/exception-type&amp;gt;&lt;br /&gt;
    &amp;lt;location&amp;gt;/error.jsp&amp;lt;/location&amp;gt;&lt;br /&gt;
  &amp;lt;/error-page&amp;gt;&lt;br /&gt;
* Rename '''CATALINA_HOME'''/conf/server.xml to '''CATALINA_HOME'''/conf/server-original.xml and rename '''CATALINA_HOME'''/conf/server-minimal.xml to '''CATALINA_HOME'''/conf/server.xml.  The minimal configuration provides the same basic configuration, but without the nested comments is much easier to maintain and understand.  Do not delete the original file as the comments make it useful for reference if you ever need to make changes - e.g. enable SSL.&lt;br /&gt;
&lt;br /&gt;
* Replace the server version string from HTTP headers in server responses, by adding the server keyword in your Connectors in '''CATALINA_HOME'''/conf/server.xml&lt;br /&gt;
  &amp;lt;Connector port=&amp;quot;8080&amp;quot; ...&lt;br /&gt;
             server=&amp;quot;Apache&amp;quot; /&amp;gt;  &amp;amp;lt;!-- server header is now Apache --&amp;amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Start Tomcat, deploy your applications into '''CATALINA_HOME'''/webapps and hope it works!&lt;br /&gt;
&lt;br /&gt;
== Protecting the Shutdown Port ==&lt;br /&gt;
Tomcat uses a port (defaults to 8005) as a shutdown port.  What this means is that to stop all webapps and stop Tomcat cleanly the shutdown scripts make a connection to this port and send the ''shutdown'' command.  This is not as huge a security problem as it may sound considering the connection to the port must be made from the machine running tomcat and the ''shutdown'' command can be changed to something other than the string ''SHUTDOWN''.  However, it's wise to take the following precautions;&lt;br /&gt;
* if you are running a publicly accessible server make sure you prevent external access to the shutdown port by using a suitable firewall.&lt;br /&gt;
* change the shutdown command in '''CATALINA_HOME'''/conf/server.xml and make sure that file is only readable by the tomcat user.&lt;br /&gt;
  &amp;amp;lt;Server port=&amp;quot;8005&amp;quot; shutdown=&amp;quot;ReallyComplexWord&amp;quot;&amp;amp;gt;&lt;br /&gt;
* if this is still a big problem for you then check [http://marc.theaimsgroup.com/?l=tomcat-user&amp;amp;m=104400608619118&amp;amp;w=2 this thread], from the Tomcat mailing list, for alternatives (they all involve code customisation though).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Securing Manager WebApp ==&lt;br /&gt;
&lt;br /&gt;
* By default there are no users with the manager role.  To make use of the manager webapp you need to add a new role and user into the '''CATALINA_HOME'''/conf/tomcat-users.xml file.&lt;br /&gt;
  &amp;lt;role rolename=&amp;quot;manager&amp;quot;/&amp;gt;&lt;br /&gt;
  &amp;lt;user username=&amp;quot;darren&amp;quot; password=&amp;quot;ReallyComplexPassword&amp;quot; roles=&amp;quot;manager&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Using a [http://tomcat.apache.org/tomcat-5.5-doc/config/valve.html valve] to filter by IP or hostname to only allow a subset of machines to connect (i.e. LAN machines).  Add one of the following within the Context tag in '''CATALINA_HOME'''/conf/Catalina/localhost/manager.xml&lt;br /&gt;
  &amp;amp;lt;!-- allow only LAN IPs to connect to the manager webapp --&amp;amp;gt;&lt;br /&gt;
  &amp;amp;lt;!-- contrary to the current Tomcat 5.5 documation the value for '''allow''' is not a regular expression --&amp;amp;gt;&lt;br /&gt;
  &amp;amp;lt;!-- future versions may have to be specified as 192\.168\.1\.* --&amp;amp;gt;&lt;br /&gt;
  &amp;lt;Valve className=&amp;quot;org.apache.catalina.valves.RemoteAddrValve&amp;quot;&lt;br /&gt;
         allow=&amp;quot;192.168.1.*&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  &amp;amp;lt;!-- allow only LAN hosts to connect to the manager webapp --&amp;amp;gt;&lt;br /&gt;
  &amp;amp;lt;!-- contrary to the current Tomcat 5.5 documation the value for '''allow''' is not a regular expression --&amp;amp;gt;&lt;br /&gt;
  &amp;amp;lt;!-- future versions may have to be specified as *\.localdomain\.com --&amp;amp;gt;&lt;br /&gt;
  &amp;lt;Valve className=&amp;quot;org.apache.catalina.valves.RemoteHostValve&amp;quot;&lt;br /&gt;
         allow=&amp;quot;*.localdomain.com&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* You can rename the manager webapp to something else, e.g. ''foobar''&lt;br /&gt;
** Move '''CATALINA_HOME'''/conf/Catalina/localhost/'''manager.xml''' to '''CATALINA_HOME'''/conf/Catalina/localhost/'''foobar.xml'''&lt;br /&gt;
** Update the '''docBase''' attribute within '''CATALINA_HOME'''/conf/Catalina/localhost/'''foobar.xml''' to ${catalina.home}/server/webapps/foobar&lt;br /&gt;
** Move '''CATALINA_HOME'''/server/webapps/'''manager''' to '''CATALINA_HOME'''/server/webapps/'''foobar'''&lt;br /&gt;
&lt;br /&gt;
== Logging ==&lt;br /&gt;
&lt;br /&gt;
As of tomcat 5.5 logging is now handled by the commons-logging framework allowing you to choose your preferred logging implementation - log4j or standard JDK logging.  By default the standard JDK logging is used (or a compatible extension called juli to be more precise), storing daily log files in '''CATALINA_HOME'''/logs.&lt;br /&gt;
&lt;br /&gt;
By default additional webapp log entries are added to '''CATALINA_HOME'''/logs/catalina.YYYY-MM-DD.log and System.out/System.err are redirected to '''CATALINA_HOME'''/logs/catalina.out.  To place webapp log entries in individual log files create a ''logging.properties'' file similar to the following within '''CATALINA_HOME'''/webapps/''APP_NAME''/WEB-INF/classes (change the ''APP_NAME'' value to create a unique file for each webapp)&lt;br /&gt;
&lt;br /&gt;
  handlers = org.apache.juli.FileHandler, java.util.logging.ConsoleHandler&lt;br /&gt;
  org.apache.juli.FileHandler.level = ALL&lt;br /&gt;
  org.apache.juli.FileHandler.directory = ${catalina.base}/logs&lt;br /&gt;
  org.apache.juli.FileHandler.prefix = APP_NAME.&lt;br /&gt;
  java.util.logging.ConsoleHandler.level = ALL&lt;br /&gt;
  java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter&lt;br /&gt;
&lt;br /&gt;
Further details on logging configuration can be found in the [http://tomcat.apache.org/tomcat-5.5-doc/logging.html tomcat logging documentation.]&lt;br /&gt;
&lt;br /&gt;
''TODO - details on disabling most of catalina.out output''&lt;br /&gt;
&lt;br /&gt;
== Encryption ==&lt;br /&gt;
&lt;br /&gt;
* SSL for password or other sensitive data exchange (''bordering on application security, not specific to tomcat'')&lt;br /&gt;
* SSL for connections (JDBC, LDAP, etc ..)&lt;br /&gt;
* The Tomcat documentation clearly explains how to [http://tomcat.apache.org/tomcat-5.5-doc/ssl-howto.html enable SSL.]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Java Security ==&lt;br /&gt;
&lt;br /&gt;
=== Running Tomcat with a Security Manager=== &lt;br /&gt;
The default Tomcat configuration provides good protection for most requirements, but does not prevent a malicious application from compromising the security of other applications running in the same instance.  To prevent this sort of attack, Tomcat can be run with a Security Manager enabled which strictly controls access to server resources.&lt;br /&gt;
Tomcat documentation has a good section on [http://tomcat.apache.org/tomcat-5.5-doc/security-manager-howto.html enabling the Security Manager.]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Miscellaneous ==&lt;br /&gt;
&lt;br /&gt;
* [http://tomcat.apache.org/faq/security.html Tomcat Security FAQ]&lt;br /&gt;
&lt;br /&gt;
=== Using Port 80 ===&lt;br /&gt;
&lt;br /&gt;
If you are on a Windows machine you will be able to change the port attribute of the connector within the ''Catalina'' service from 8080 to 80.  This allows you to use tomcat directly to serve all requests.  Depending on your requirements it may not be good enough to serve directly from Tomcat so you may like to consider;&lt;br /&gt;
* Use IIS / Apache running on port 80 and mod_jk to proxy requests to Tomcat&lt;br /&gt;
&lt;br /&gt;
On a UNIX machine only root is allowed to run services on ports below 1024 (kernel recompilation can overcome this).  It is a very bad idea to run Tomcat as root, so the options are;&lt;br /&gt;
* Use Apache running on port 80 and mod_jk (or mod_proxy_ajp) to proxy requests to Tomcat&lt;br /&gt;
* Run Tomcat as root, but in a chroot jail&lt;br /&gt;
* Use a tool like authbind to enable a non root user to bind to ports below 1024&lt;br /&gt;
* Use a port forwarder such as [http://www.netfilter.org/projects/iptables/index.html Iptables] to redirect incoming requests from 8080 to 80.  This has the disadvantage that internal redirects still need to use 8080.&lt;br /&gt;
* Run [http://www.squid-cache.org/ Squid] as a web accelerator in front of Tomcat&lt;br /&gt;
* Use JSVC/procrun&lt;br /&gt;
&lt;br /&gt;
=== Cleartext Passwords in CATALINA_HOME/conf/server.xml ===&lt;br /&gt;
&lt;br /&gt;
When configuring a resource, such as a JDBC pool, it is necessary to include clear text username and password in CATALINA_HOME/conf/server.xml  Best practices advice us never to store clear text passwords, but the following paragraphs highlight it is very difficult to avoid.&lt;br /&gt;
&lt;br /&gt;
If one way encryption was used on the password it must be possible for a database connection to be established using a username and encrypted password - so the encrypted password is just as valuable as the clear text one to an attacker.&lt;br /&gt;
&lt;br /&gt;
If two way encryption was used a keyfile is needed which must also live on the filesystem.  To make it more secure a passphase is added to the keyfile which then has to be stored in the configuration as clear text - no improvement.&lt;br /&gt;
&lt;br /&gt;
Encoding is security by obscurity and offers no form of protection (algorithms can be reverse engineered).  What encoding does do is make huge amounts of overhead work - you need to customise Tomcat and the commons digester it uses to parse the config files.  You'd also need a way to create encoded passwords.&lt;br /&gt;
&lt;br /&gt;
In the case of a JDBC pool what you can do is;&lt;br /&gt;
* make sure the database user only has access to the databases and tables they need (also limit rights as necessary).&lt;br /&gt;
* make sure the raw database files are only accessible to the user running the database services (e.g. mysql/postgresql user)&lt;br /&gt;
* make sure the Tomcat configuration files are only accessible to the tomcat user&lt;br /&gt;
&lt;br /&gt;
[[Category:OWASP Java Project]]&lt;br /&gt;
[[Category:Java]]&lt;/div&gt;</summary>
		<author><name>Dledmonds</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Securing_tomcat&amp;diff=15143</id>
		<title>Securing tomcat</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Securing_tomcat&amp;diff=15143"/>
				<updated>2007-01-09T10:13:39Z</updated>
		
		<summary type="html">&lt;p&gt;Dledmonds: /* Securing Manager WebApp */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
Most weaknesses in [http://tomcat.apache.org/ Apache Tomcat] come from incorrect or inappropiate configuration.  It is nearly always possible to make Tomcat more secure than the default out of the box installation.  What follows documents best practices and recommendations on securing a production Tomcat server, whether it be hosted on a Windows or Unix based operating system.  ''Please note that the section ordering is not a representation of the section importance.''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Software Versions ==&lt;br /&gt;
&lt;br /&gt;
The first step is to make sure you are running the latest stable releases of software;&lt;br /&gt;
* Java Runtime Environment (JRE) or SDK&lt;br /&gt;
* Tomcat&lt;br /&gt;
* Third party libraries&lt;br /&gt;
This does not mean you have to upgrade all your production servers to a new (and potentially buggy) release which has just been made available to the public.  What you must do is download the latest stable bugfix release that has continual support.  For the JRE and Tomcat you should be looking at the last digits in the version number (5.5.'''X''') as it represents the bugfix information.  The bugs fixed in these releases are publicly available so if you don't upgrade you could be providing attackers with a very easy route to compromise your server.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Installation of Apache Tomcat 5.5 ==&lt;br /&gt;
&lt;br /&gt;
=== UNIX ===&lt;br /&gt;
&lt;br /&gt;
* Create a tomcat user/group&lt;br /&gt;
* Download and unpack the core distribution (referenced as '''CATALINA_HOME''' from now on)&lt;br /&gt;
* Change '''CATALINA_HOME''' ownership to tomcat user and tomcat group&lt;br /&gt;
* Change files in '''CATALINA_HOME'''/conf to be readonly (400)&lt;br /&gt;
* Make sure tomcat user has read/write access to /tmp and write (300 - yes, only write/execute) access to '''CATALINA_HOME'''/logs&lt;br /&gt;
&lt;br /&gt;
=== Windows ===&lt;br /&gt;
&lt;br /&gt;
* Download the core windows service installer&lt;br /&gt;
* Start the installation, click ''Next'' and ''Agree'' to the licence&lt;br /&gt;
* Untick ''native'', ''documentation'', ''examples'' and ''webapps'' then click ''Next''&lt;br /&gt;
* Choose an installation directory (referenced as '''CATALINA_HOME''' from now on), preferably on a different drive to the OS.  &lt;br /&gt;
* Choose an administrator username (NOT admin) and a secure password that complies with your organisations password policy.&lt;br /&gt;
* Complete tomcat installation, but do not start service.&lt;br /&gt;
&lt;br /&gt;
=== Common ===&lt;br /&gt;
&lt;br /&gt;
* Remove everything from '''CATALINA_HOME'''/webapps (ROOT, balancer, jsp-examples, servlet-examples, tomcat-docs, webdav)&lt;br /&gt;
&lt;br /&gt;
* Remove everything from '''CATALINA_HOME'''/server/webapps (host-manager, manager).  Note that it can be useful to keep the manager webapp installed if you need the ability to redeploy without restarting Tomcat.  If you choose to keep it please read the section on Securing the Manager WebApp.&lt;br /&gt;
&lt;br /&gt;
* Remove '''CATALINA_HOME'''/conf/Catalina/localhost/host-manager.xml and '''CATALINA_HOME'''/conf/Catalina/localhost/manager.xml (again, if you are keeping the manager application, do not remove this).&lt;br /&gt;
&lt;br /&gt;
* Make sure the default servlet is configured '''not''' to serve index pages when a welcome file is not present.  In '''CATALINA_HOME'''/conf/web.xml&lt;br /&gt;
  &amp;lt;servlet&amp;gt;&lt;br /&gt;
    &amp;lt;servlet-name&amp;gt;default&amp;lt;/servlet-name&amp;gt;&lt;br /&gt;
    &amp;lt;servlet-class&amp;gt;org.apache.catalina.servlets.DefaultServlet&amp;lt;/servlet-class&amp;gt;&lt;br /&gt;
    &amp;lt;init-param&amp;gt;&lt;br /&gt;
      &amp;lt;param-name&amp;gt;debug&amp;lt;/param-name&amp;gt;&lt;br /&gt;
      &amp;lt;param-value&amp;gt;0&amp;lt;/param-value&amp;gt;&lt;br /&gt;
    &amp;lt;/init-param&amp;gt;&lt;br /&gt;
    &amp;lt;init-param&amp;gt;&lt;br /&gt;
      &amp;lt;param-name&amp;gt;listings&amp;lt;/param-name&amp;gt;&lt;br /&gt;
      &amp;lt;param-value&amp;gt;'''false'''&amp;lt;/param-value&amp;gt;  &amp;amp;lt;!-- make sure this is false --&amp;amp;gt;&lt;br /&gt;
    &amp;lt;/init-param&amp;gt;&lt;br /&gt;
    &amp;lt;load-on-startup&amp;gt;1&amp;lt;/load-on-startup&amp;gt;&lt;br /&gt;
  &amp;lt;/servlet&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Remove version string from HTTP error messages by repacking '''CATALINA_HOME'''/server/lib/catalina.jar with an updated ServerInfo.properties file.&lt;br /&gt;
:unpack catalina.jar&lt;br /&gt;
  cd CATALINA_HOME/server/lib&lt;br /&gt;
  jar xf catalina.jar org/apache/catalina/util/ServerInfo.properties&lt;br /&gt;
:update ServerInfo.properties by changing server.info line to server.info=Apache Tomcat&lt;br /&gt;
:repackage catalina.jar&lt;br /&gt;
  jar uf catalina.jar org/apache/catalina/util/ServerInfo.properties&lt;br /&gt;
:remove CATALINA_HOME/server/lib/org (created when extracting the ServerInfo.properties file)&lt;br /&gt;
&lt;br /&gt;
* Replace default error page (default is stacktrace) by adding the following into '''CATALINA_HOME'''/conf/web.xml.  The default error page shows a full stacktrace which is a disclosure of sensitive information.  ''The following solution is not ideal as it produces a blank page because Tomcat cannot find the file specified, but without a better solution this, at least, achieves the desired result.  A well configured web application will override this default in CATALINA_HOME/webapps/APP_NAME/WEB-INF/web.xml so it won't cause problems.''&lt;br /&gt;
  &amp;lt;error-page&amp;gt;&lt;br /&gt;
    &amp;lt;exception-type&amp;gt;java.lang.Exception&amp;lt;/exception-type&amp;gt;&lt;br /&gt;
    &amp;lt;location&amp;gt;/error.jsp&amp;lt;/location&amp;gt;&lt;br /&gt;
  &amp;lt;/error-page&amp;gt;&lt;br /&gt;
* Rename '''CATALINA_HOME'''/conf/server.xml to '''CATALINA_HOME'''/conf/server-original.xml and rename '''CATALINA_HOME'''/conf/server-minimal.xml to '''CATALINA_HOME'''/conf/server.xml.  The minimal configuration provides the same basic configuration, but without the nested comments is much easier to maintain and understand.  Do not delete the original file as the comments make it useful for reference if you ever need to make changes - e.g. enable SSL.&lt;br /&gt;
&lt;br /&gt;
* Replace the server version string from HTTP headers in server responses, by adding the server keyword in your Connectors in '''CATALINA_HOME'''/conf/server.xml&lt;br /&gt;
  &amp;lt;Connector port=&amp;quot;8080&amp;quot; ...&lt;br /&gt;
             server=&amp;quot;Apache&amp;quot; /&amp;gt;  &amp;amp;lt;!-- server header is now Apache --&amp;amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Start Tomcat, deploy your applications into '''CATALINA_HOME'''/webapps and hope it works!&lt;br /&gt;
&lt;br /&gt;
== Protecting the Shutdown Port ==&lt;br /&gt;
Tomcat uses a port (defaults to 8005) as a shutdown port.  What this means is that to stop all webapps and stop Tomcat cleanly the shutdown scripts make a connection to this port and send the ''shutdown'' command.  This is not as huge a security problem as it may sound considering the connection to the port must be made from the machine running tomcat and the ''shutdown'' command can be changed to something other than the string ''SHUTDOWN''.  However, it's wise to take the following precautions;&lt;br /&gt;
* if you are running a publicly accessible server make sure you prevent external access to the shutdown port by using a suitable firewall.&lt;br /&gt;
* change the shutdown command in '''CATALINA_HOME'''/conf/server.xml and make sure that file is only readable by the tomcat user.&lt;br /&gt;
  &amp;amp;lt;Server port=&amp;quot;8005&amp;quot; shutdown=&amp;quot;ReallyComplexWord&amp;quot;&amp;amp;gt;&lt;br /&gt;
* if this is still a big problem for you then check [http://marc.theaimsgroup.com/?l=tomcat-user&amp;amp;m=104400608619118&amp;amp;w=2 this thread], from the Tomcat mailing list, for alternatives (they all involve code customisation though).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Securing Manager WebApp ==&lt;br /&gt;
&lt;br /&gt;
* By default there are no users with the manager role.  To make use of the manager webapp you need to add a new role and user into the '''CATALINA_HOME'''/conf/tomcat-users.xml file.&lt;br /&gt;
  &amp;lt;role rolename=&amp;quot;manager&amp;quot;/&amp;gt;&lt;br /&gt;
  &amp;lt;user username=&amp;quot;darren&amp;quot; password=&amp;quot;ReallyComplexPassword&amp;quot; roles=&amp;quot;manager&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Using a [http://tomcat.apache.org/tomcat-5.5-doc/config/valve.html valve] to filter by IP or hostname to only allow a subset of machines to connect (i.e. LAN machines).  Add one of the following within the Context tag in '''CATALINA_HOME'''/conf/Catalina/localhost/manager.xml&lt;br /&gt;
  &amp;amp;lt;!-- allow only LAN IPs to connect to the manager webapp --&amp;amp;gt;&lt;br /&gt;
  &amp;amp;lt;!-- contrary to the current Tomcat 5.5 documation the value for '''allow''' is not a regular expression --&amp;amp;gt;&lt;br /&gt;
  &amp;amp;lt;!-- future versions may have to be specified as 192\.168\.1\.* --&amp;amp;gt;&lt;br /&gt;
  &amp;lt;Valve className=&amp;quot;org.apache.catalina.valves.RemoteAddrValve&amp;quot;&lt;br /&gt;
         allow=&amp;quot;192.168.1.*&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  &amp;amp;lt;!-- allow only LAN hosts to connect to the manager webapp --&amp;amp;gt;&lt;br /&gt;
  &amp;amp;lt;!-- contrary to the current Tomcat 5.5 documation the value for '''allow''' is not a regular expression --&amp;amp;gt;&lt;br /&gt;
  &amp;amp;lt;!-- future versions may have to be specified as *\.localdomain\.com --&amp;amp;gt;&lt;br /&gt;
  &amp;lt;Valve className=&amp;quot;org.apache.catalina.valves.RemoteHostValve&amp;quot;&lt;br /&gt;
         allow=&amp;quot;*.localdomain.com&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* You can rename the manager webapp to something else, e.g. ''foobar''&lt;br /&gt;
** Move '''CATALINA_HOME'''/conf/Catalina/localhost/'''manager.xml''' to '''CATALINA_HOME'''/conf/Catalina/localhost/'''foobar.xml'''&lt;br /&gt;
** Update the '''docBase''' attribute within '''CATALINA_HOME'''/conf/Catalina/localhost/'''foobar.xml''' to ${catalina.home}/server/webapps/foobar&lt;br /&gt;
** Move '''CATALINA_HOME'''/server/webapps/'''manager''' to '''CATALINA_HOME'''/server/webapps/'''foobar'''&lt;br /&gt;
&lt;br /&gt;
== Logging ==&lt;br /&gt;
&lt;br /&gt;
As of tomcat 5.5 logging is now handled by the commons-logging framework allowing you to choose your preferred logging implementation - log4j or standard JDK logging.  By default the standard JDK logging is used (or a compatible extension called juli to be more precise), storing daily log files in '''CATALINA_HOME'''/logs.&lt;br /&gt;
&lt;br /&gt;
By default additional webapp log entries are added to '''CATALINA_HOME'''/logs/catalina.YYYY-MM-DD.log and System.out/System.err are redirected to '''CATALINA_HOME'''/logs/catalina.out.  To place webapp log entries in individual log files create a ''logging.properties'' file similar to the following within '''CATALINA_HOME'''/webapps/''APP_NAME''/WEB-INF/classes (change the ''APP_NAME'' value to create a unquie file for each webapp)&lt;br /&gt;
&lt;br /&gt;
  handlers = org.apache.juli.FileHandler, java.util.logging.ConsoleHandler&lt;br /&gt;
  org.apache.juli.FileHandler.level = ALL&lt;br /&gt;
  org.apache.juli.FileHandler.directory = ${catalina.base}/logs&lt;br /&gt;
  org.apache.juli.FileHandler.prefix = APP_NAME.&lt;br /&gt;
  java.util.logging.ConsoleHandler.level = ALL&lt;br /&gt;
  java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter&lt;br /&gt;
&lt;br /&gt;
Further details on logging configuration can be found in the [http://tomcat.apache.org/tomcat-5.5-doc/logging.html tomcat logging documentation.]&lt;br /&gt;
&lt;br /&gt;
''TODO - details on disabling most of catalina.out output''&lt;br /&gt;
&lt;br /&gt;
== Encryption ==&lt;br /&gt;
&lt;br /&gt;
* SSL for password or other sensitive data exchange (''bordering on application security, not specific to tomcat'')&lt;br /&gt;
* SSL for connections (JDBC, LDAP, etc ..)&lt;br /&gt;
* The Tomcat documentation clearly explains how to [http://tomcat.apache.org/tomcat-5.5-doc/ssl-howto.html enable SSL.]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Java Security ==&lt;br /&gt;
&lt;br /&gt;
=== Running Tomcat with a Security Manager=== &lt;br /&gt;
The default Tomcat configuration provides good protection for most requirements, but does not prevent a malicious application from compromising the security of other applications running in the same instance.  To prevent this sort of attack, Tomcat can be run with a Security Manager enabled which strictly controls access to server resources.&lt;br /&gt;
Tomcat documentation has a good section on [http://tomcat.apache.org/tomcat-5.5-doc/security-manager-howto.html enabling the Security Manager.]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Miscellaneous ==&lt;br /&gt;
&lt;br /&gt;
* [http://tomcat.apache.org/faq/security.html Tomcat Security FAQ]&lt;br /&gt;
&lt;br /&gt;
=== Using Port 80 ===&lt;br /&gt;
&lt;br /&gt;
If you are on a Windows machine you will be able to change the port attribute of the connector within the ''Catalina'' service from 8080 to 80.  This allows you to use tomcat directly to serve all requests.  Depending on your requirements it may not be good enough to serve directly from Tomcat so you may like to consider;&lt;br /&gt;
* Use IIS / Apache running on port 80 and mod_jk to proxy requests to Tomcat&lt;br /&gt;
&lt;br /&gt;
On a UNIX machine only root is allowed to run services on ports below 1024 (kernel recompilation can overcome this).  It is a very bad idea to run Tomcat as root, so the options are;&lt;br /&gt;
* Use Apache running on port 80 and mod_jk (or mod_proxy_ajp) to proxy requests to Tomcat&lt;br /&gt;
* Run Tomcat as root, but in a chroot jail&lt;br /&gt;
* Use a tool like authbind to enable a non root user to bind to ports below 1024&lt;br /&gt;
* Use a port forwarder such as [http://www.netfilter.org/projects/iptables/index.html Iptables] to redirect incoming requests from 8080 to 80.  This has the disadvantage that internal redirects still need to use 8080.&lt;br /&gt;
* Run [http://www.squid-cache.org/ Squid] as a web accelerator in front of Tomcat&lt;br /&gt;
* Use JSVC/procrun&lt;br /&gt;
&lt;br /&gt;
=== Cleartext Passwords in CATALINA_HOME/conf/server.xml ===&lt;br /&gt;
&lt;br /&gt;
When configuring a resource, such as a JDBC pool, it is necessary to include clear text username and password in CATALINA_HOME/conf/server.xml  Best practices advice us never to store clear text passwords, but the following paragraphs highlight it is very difficult to avoid.&lt;br /&gt;
&lt;br /&gt;
If one way encryption was used on the password it must be possible for a database connection to be established using a username and encrypted password - so the encrypted password is just as valuable as the clear text one to an attacker.&lt;br /&gt;
&lt;br /&gt;
If two way encryption was used a keyfile is needed which must also live on the filesystem.  To make it more secure a passphase is added to the keyfile which then has to be stored in the configuration as clear text - no improvement.&lt;br /&gt;
&lt;br /&gt;
Encoding is security by obscurity and offers no form of protection (algorithms can be reverse engineered).  What encoding does do is make huge amounts of overhead work - you need to customise Tomcat and the commons digester it uses to parse the config files.  You'd also need a way to create encoded passwords.&lt;br /&gt;
&lt;br /&gt;
In the case of a JDBC pool what you can do is;&lt;br /&gt;
* make sure the database user only has access to the databases and tables they need (also limit rights as necessary).&lt;br /&gt;
* make sure the raw database files are only accessible to the user running the database services (e.g. mysql/postgresql user)&lt;br /&gt;
* make sure the Tomcat configuration files are only accessible to the tomcat user&lt;br /&gt;
&lt;br /&gt;
[[Category:OWASP Java Project]]&lt;br /&gt;
[[Category:Java]]&lt;/div&gt;</summary>
		<author><name>Dledmonds</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Securing_tomcat&amp;diff=15142</id>
		<title>Securing tomcat</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Securing_tomcat&amp;diff=15142"/>
				<updated>2007-01-09T10:11:45Z</updated>
		
		<summary type="html">&lt;p&gt;Dledmonds: /* Common */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
Most weaknesses in [http://tomcat.apache.org/ Apache Tomcat] come from incorrect or inappropiate configuration.  It is nearly always possible to make Tomcat more secure than the default out of the box installation.  What follows documents best practices and recommendations on securing a production Tomcat server, whether it be hosted on a Windows or Unix based operating system.  ''Please note that the section ordering is not a representation of the section importance.''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Software Versions ==&lt;br /&gt;
&lt;br /&gt;
The first step is to make sure you are running the latest stable releases of software;&lt;br /&gt;
* Java Runtime Environment (JRE) or SDK&lt;br /&gt;
* Tomcat&lt;br /&gt;
* Third party libraries&lt;br /&gt;
This does not mean you have to upgrade all your production servers to a new (and potentially buggy) release which has just been made available to the public.  What you must do is download the latest stable bugfix release that has continual support.  For the JRE and Tomcat you should be looking at the last digits in the version number (5.5.'''X''') as it represents the bugfix information.  The bugs fixed in these releases are publicly available so if you don't upgrade you could be providing attackers with a very easy route to compromise your server.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Installation of Apache Tomcat 5.5 ==&lt;br /&gt;
&lt;br /&gt;
=== UNIX ===&lt;br /&gt;
&lt;br /&gt;
* Create a tomcat user/group&lt;br /&gt;
* Download and unpack the core distribution (referenced as '''CATALINA_HOME''' from now on)&lt;br /&gt;
* Change '''CATALINA_HOME''' ownership to tomcat user and tomcat group&lt;br /&gt;
* Change files in '''CATALINA_HOME'''/conf to be readonly (400)&lt;br /&gt;
* Make sure tomcat user has read/write access to /tmp and write (300 - yes, only write/execute) access to '''CATALINA_HOME'''/logs&lt;br /&gt;
&lt;br /&gt;
=== Windows ===&lt;br /&gt;
&lt;br /&gt;
* Download the core windows service installer&lt;br /&gt;
* Start the installation, click ''Next'' and ''Agree'' to the licence&lt;br /&gt;
* Untick ''native'', ''documentation'', ''examples'' and ''webapps'' then click ''Next''&lt;br /&gt;
* Choose an installation directory (referenced as '''CATALINA_HOME''' from now on), preferably on a different drive to the OS.  &lt;br /&gt;
* Choose an administrator username (NOT admin) and a secure password that complies with your organisations password policy.&lt;br /&gt;
* Complete tomcat installation, but do not start service.&lt;br /&gt;
&lt;br /&gt;
=== Common ===&lt;br /&gt;
&lt;br /&gt;
* Remove everything from '''CATALINA_HOME'''/webapps (ROOT, balancer, jsp-examples, servlet-examples, tomcat-docs, webdav)&lt;br /&gt;
&lt;br /&gt;
* Remove everything from '''CATALINA_HOME'''/server/webapps (host-manager, manager).  Note that it can be useful to keep the manager webapp installed if you need the ability to redeploy without restarting Tomcat.  If you choose to keep it please read the section on Securing the Manager WebApp.&lt;br /&gt;
&lt;br /&gt;
* Remove '''CATALINA_HOME'''/conf/Catalina/localhost/host-manager.xml and '''CATALINA_HOME'''/conf/Catalina/localhost/manager.xml (again, if you are keeping the manager application, do not remove this).&lt;br /&gt;
&lt;br /&gt;
* Make sure the default servlet is configured '''not''' to serve index pages when a welcome file is not present.  In '''CATALINA_HOME'''/conf/web.xml&lt;br /&gt;
  &amp;lt;servlet&amp;gt;&lt;br /&gt;
    &amp;lt;servlet-name&amp;gt;default&amp;lt;/servlet-name&amp;gt;&lt;br /&gt;
    &amp;lt;servlet-class&amp;gt;org.apache.catalina.servlets.DefaultServlet&amp;lt;/servlet-class&amp;gt;&lt;br /&gt;
    &amp;lt;init-param&amp;gt;&lt;br /&gt;
      &amp;lt;param-name&amp;gt;debug&amp;lt;/param-name&amp;gt;&lt;br /&gt;
      &amp;lt;param-value&amp;gt;0&amp;lt;/param-value&amp;gt;&lt;br /&gt;
    &amp;lt;/init-param&amp;gt;&lt;br /&gt;
    &amp;lt;init-param&amp;gt;&lt;br /&gt;
      &amp;lt;param-name&amp;gt;listings&amp;lt;/param-name&amp;gt;&lt;br /&gt;
      &amp;lt;param-value&amp;gt;'''false'''&amp;lt;/param-value&amp;gt;  &amp;amp;lt;!-- make sure this is false --&amp;amp;gt;&lt;br /&gt;
    &amp;lt;/init-param&amp;gt;&lt;br /&gt;
    &amp;lt;load-on-startup&amp;gt;1&amp;lt;/load-on-startup&amp;gt;&lt;br /&gt;
  &amp;lt;/servlet&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Remove version string from HTTP error messages by repacking '''CATALINA_HOME'''/server/lib/catalina.jar with an updated ServerInfo.properties file.&lt;br /&gt;
:unpack catalina.jar&lt;br /&gt;
  cd CATALINA_HOME/server/lib&lt;br /&gt;
  jar xf catalina.jar org/apache/catalina/util/ServerInfo.properties&lt;br /&gt;
:update ServerInfo.properties by changing server.info line to server.info=Apache Tomcat&lt;br /&gt;
:repackage catalina.jar&lt;br /&gt;
  jar uf catalina.jar org/apache/catalina/util/ServerInfo.properties&lt;br /&gt;
:remove CATALINA_HOME/server/lib/org (created when extracting the ServerInfo.properties file)&lt;br /&gt;
&lt;br /&gt;
* Replace default error page (default is stacktrace) by adding the following into '''CATALINA_HOME'''/conf/web.xml.  The default error page shows a full stacktrace which is a disclosure of sensitive information.  ''The following solution is not ideal as it produces a blank page because Tomcat cannot find the file specified, but without a better solution this, at least, achieves the desired result.  A well configured web application will override this default in CATALINA_HOME/webapps/APP_NAME/WEB-INF/web.xml so it won't cause problems.''&lt;br /&gt;
  &amp;lt;error-page&amp;gt;&lt;br /&gt;
    &amp;lt;exception-type&amp;gt;java.lang.Exception&amp;lt;/exception-type&amp;gt;&lt;br /&gt;
    &amp;lt;location&amp;gt;/error.jsp&amp;lt;/location&amp;gt;&lt;br /&gt;
  &amp;lt;/error-page&amp;gt;&lt;br /&gt;
* Rename '''CATALINA_HOME'''/conf/server.xml to '''CATALINA_HOME'''/conf/server-original.xml and rename '''CATALINA_HOME'''/conf/server-minimal.xml to '''CATALINA_HOME'''/conf/server.xml.  The minimal configuration provides the same basic configuration, but without the nested comments is much easier to maintain and understand.  Do not delete the original file as the comments make it useful for reference if you ever need to make changes - e.g. enable SSL.&lt;br /&gt;
&lt;br /&gt;
* Replace the server version string from HTTP headers in server responses, by adding the server keyword in your Connectors in '''CATALINA_HOME'''/conf/server.xml&lt;br /&gt;
  &amp;lt;Connector port=&amp;quot;8080&amp;quot; ...&lt;br /&gt;
             server=&amp;quot;Apache&amp;quot; /&amp;gt;  &amp;amp;lt;!-- server header is now Apache --&amp;amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Start Tomcat, deploy your applications into '''CATALINA_HOME'''/webapps and hope it works!&lt;br /&gt;
&lt;br /&gt;
== Protecting the Shutdown Port ==&lt;br /&gt;
Tomcat uses a port (defaults to 8005) as a shutdown port.  What this means is that to stop all webapps and stop Tomcat cleanly the shutdown scripts make a connection to this port and send the ''shutdown'' command.  This is not as huge a security problem as it may sound considering the connection to the port must be made from the machine running tomcat and the ''shutdown'' command can be changed to something other than the string ''SHUTDOWN''.  However, it's wise to take the following precautions;&lt;br /&gt;
* if you are running a publicly accessible server make sure you prevent external access to the shutdown port by using a suitable firewall.&lt;br /&gt;
* change the shutdown command in '''CATALINA_HOME'''/conf/server.xml and make sure that file is only readable by the tomcat user.&lt;br /&gt;
  &amp;amp;lt;Server port=&amp;quot;8005&amp;quot; shutdown=&amp;quot;ReallyComplexWord&amp;quot;&amp;amp;gt;&lt;br /&gt;
* if this is still a big problem for you then check [http://marc.theaimsgroup.com/?l=tomcat-user&amp;amp;m=104400608619118&amp;amp;w=2 this thread], from the Tomcat mailing list, for alternatives (they all involve code customisation though).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Securing Manager WebApp ==&lt;br /&gt;
&lt;br /&gt;
* By default there are no users with the manager role.  To make use of the manager webapp you need to add a new user into the '''CATALINA_HOME'''/conf/tomcat-users.xml file.&lt;br /&gt;
  &amp;lt;user username=&amp;quot;darren&amp;quot; password=&amp;quot;ReallyComplexPassword&amp;quot; roles=&amp;quot;manager&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Using a [http://tomcat.apache.org/tomcat-5.5-doc/config/valve.html valve] to filter by IP or hostname to only allow a subset of machines to connect (i.e. LAN machines).  Add one of the following within the Context tag in '''CATALINA_HOME'''/conf/Catalina/localhost/manager.xml&lt;br /&gt;
  &amp;amp;lt;!-- allow only LAN IPs to connect to the manager webapp --&amp;amp;gt;&lt;br /&gt;
  &amp;amp;lt;!-- contrary to the current Tomcat 5.5 documation the value for '''allow''' is not a regular expression --&amp;amp;gt;&lt;br /&gt;
  &amp;amp;lt;!-- future versions may have to be specified as 192\.168\.1\.* --&amp;amp;gt;&lt;br /&gt;
  &amp;lt;Valve className=&amp;quot;org.apache.catalina.valves.RemoteAddrValve&amp;quot;&lt;br /&gt;
         allow=&amp;quot;192.168.1.*&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  &amp;amp;lt;!-- allow only LAN hosts to connect to the manager webapp --&amp;amp;gt;&lt;br /&gt;
  &amp;amp;lt;!-- contrary to the current Tomcat 5.5 documation the value for '''allow''' is not a regular expression --&amp;amp;gt;&lt;br /&gt;
  &amp;amp;lt;!-- future versions may have to be specified as *\.localdomain\.com --&amp;amp;gt;&lt;br /&gt;
  &amp;lt;Valve className=&amp;quot;org.apache.catalina.valves.RemoteHostValve&amp;quot;&lt;br /&gt;
         allow=&amp;quot;*.localdomain.com&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* You can rename the manager webapp to something else, e.g. ''foobar''&lt;br /&gt;
** Move '''CATALINA_HOME'''/conf/Catalina/localhost/'''manager.xml''' to '''CATALINA_HOME'''/conf/Catalina/localhost/'''foobar.xml'''&lt;br /&gt;
** Update the '''docBase''' attribute within '''CATALINA_HOME'''/conf/Catalina/localhost/'''foobar.xml''' to ${catalina.home}/server/webapps/foobar&lt;br /&gt;
** Move '''CATALINA_HOME'''/server/webapps/'''manager''' to '''CATALINA_HOME'''/server/webapps/'''foobar'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Logging ==&lt;br /&gt;
&lt;br /&gt;
As of tomcat 5.5 logging is now handled by the commons-logging framework allowing you to choose your preferred logging implementation - log4j or standard JDK logging.  By default the standard JDK logging is used (or a compatible extension called juli to be more precise), storing daily log files in '''CATALINA_HOME'''/logs.&lt;br /&gt;
&lt;br /&gt;
By default additional webapp log entries are added to '''CATALINA_HOME'''/logs/catalina.YYYY-MM-DD.log and System.out/System.err are redirected to '''CATALINA_HOME'''/logs/catalina.out.  To place webapp log entries in individual log files create a ''logging.properties'' file similar to the following within '''CATALINA_HOME'''/webapps/''APP_NAME''/WEB-INF/classes (change the ''APP_NAME'' value to create a unquie file for each webapp)&lt;br /&gt;
&lt;br /&gt;
  handlers = org.apache.juli.FileHandler, java.util.logging.ConsoleHandler&lt;br /&gt;
  org.apache.juli.FileHandler.level = ALL&lt;br /&gt;
  org.apache.juli.FileHandler.directory = ${catalina.base}/logs&lt;br /&gt;
  org.apache.juli.FileHandler.prefix = APP_NAME.&lt;br /&gt;
  java.util.logging.ConsoleHandler.level = ALL&lt;br /&gt;
  java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter&lt;br /&gt;
&lt;br /&gt;
Further details on logging configuration can be found in the [http://tomcat.apache.org/tomcat-5.5-doc/logging.html tomcat logging documentation.]&lt;br /&gt;
&lt;br /&gt;
''TODO - details on disabling most of catalina.out output''&lt;br /&gt;
&lt;br /&gt;
== Encryption ==&lt;br /&gt;
&lt;br /&gt;
* SSL for password or other sensitive data exchange (''bordering on application security, not specific to tomcat'')&lt;br /&gt;
* SSL for connections (JDBC, LDAP, etc ..)&lt;br /&gt;
* The Tomcat documentation clearly explains how to [http://tomcat.apache.org/tomcat-5.5-doc/ssl-howto.html enable SSL.]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Java Security ==&lt;br /&gt;
&lt;br /&gt;
=== Running Tomcat with a Security Manager=== &lt;br /&gt;
The default Tomcat configuration provides good protection for most requirements, but does not prevent a malicious application from compromising the security of other applications running in the same instance.  To prevent this sort of attack, Tomcat can be run with a Security Manager enabled which strictly controls access to server resources.&lt;br /&gt;
Tomcat documentation has a good section on [http://tomcat.apache.org/tomcat-5.5-doc/security-manager-howto.html enabling the Security Manager.]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Miscellaneous ==&lt;br /&gt;
&lt;br /&gt;
* [http://tomcat.apache.org/faq/security.html Tomcat Security FAQ]&lt;br /&gt;
&lt;br /&gt;
=== Using Port 80 ===&lt;br /&gt;
&lt;br /&gt;
If you are on a Windows machine you will be able to change the port attribute of the connector within the ''Catalina'' service from 8080 to 80.  This allows you to use tomcat directly to serve all requests.  Depending on your requirements it may not be good enough to serve directly from Tomcat so you may like to consider;&lt;br /&gt;
* Use IIS / Apache running on port 80 and mod_jk to proxy requests to Tomcat&lt;br /&gt;
&lt;br /&gt;
On a UNIX machine only root is allowed to run services on ports below 1024 (kernel recompilation can overcome this).  It is a very bad idea to run Tomcat as root, so the options are;&lt;br /&gt;
* Use Apache running on port 80 and mod_jk (or mod_proxy_ajp) to proxy requests to Tomcat&lt;br /&gt;
* Run Tomcat as root, but in a chroot jail&lt;br /&gt;
* Use a tool like authbind to enable a non root user to bind to ports below 1024&lt;br /&gt;
* Use a port forwarder such as [http://www.netfilter.org/projects/iptables/index.html Iptables] to redirect incoming requests from 8080 to 80.  This has the disadvantage that internal redirects still need to use 8080.&lt;br /&gt;
* Run [http://www.squid-cache.org/ Squid] as a web accelerator in front of Tomcat&lt;br /&gt;
* Use JSVC/procrun&lt;br /&gt;
&lt;br /&gt;
=== Cleartext Passwords in CATALINA_HOME/conf/server.xml ===&lt;br /&gt;
&lt;br /&gt;
When configuring a resource, such as a JDBC pool, it is necessary to include clear text username and password in CATALINA_HOME/conf/server.xml  Best practices advice us never to store clear text passwords, but the following paragraphs highlight it is very difficult to avoid.&lt;br /&gt;
&lt;br /&gt;
If one way encryption was used on the password it must be possible for a database connection to be established using a username and encrypted password - so the encrypted password is just as valuable as the clear text one to an attacker.&lt;br /&gt;
&lt;br /&gt;
If two way encryption was used a keyfile is needed which must also live on the filesystem.  To make it more secure a passphase is added to the keyfile which then has to be stored in the configuration as clear text - no improvement.&lt;br /&gt;
&lt;br /&gt;
Encoding is security by obscurity and offers no form of protection (algorithms can be reverse engineered).  What encoding does do is make huge amounts of overhead work - you need to customise Tomcat and the commons digester it uses to parse the config files.  You'd also need a way to create encoded passwords.&lt;br /&gt;
&lt;br /&gt;
In the case of a JDBC pool what you can do is;&lt;br /&gt;
* make sure the database user only has access to the databases and tables they need (also limit rights as necessary).&lt;br /&gt;
* make sure the raw database files are only accessible to the user running the database services (e.g. mysql/postgresql user)&lt;br /&gt;
* make sure the Tomcat configuration files are only accessible to the tomcat user&lt;br /&gt;
&lt;br /&gt;
[[Category:OWASP Java Project]]&lt;br /&gt;
[[Category:Java]]&lt;/div&gt;</summary>
		<author><name>Dledmonds</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Securing_tomcat&amp;diff=15141</id>
		<title>Securing tomcat</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Securing_tomcat&amp;diff=15141"/>
				<updated>2007-01-09T10:05:40Z</updated>
		
		<summary type="html">&lt;p&gt;Dledmonds: /* Logging */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
Most weaknesses in [http://tomcat.apache.org/ Apache Tomcat] come from incorrect or inappropiate configuration.  It is nearly always possible to make Tomcat more secure than the default out of the box installation.  What follows documents best practices and recommendations on securing a production Tomcat server, whether it be hosted on a Windows or Unix based operating system.  ''Please note that the section ordering is not a representation of the section importance.''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Software Versions ==&lt;br /&gt;
&lt;br /&gt;
The first step is to make sure you are running the latest stable releases of software;&lt;br /&gt;
* Java Runtime Environment (JRE) or SDK&lt;br /&gt;
* Tomcat&lt;br /&gt;
* Third party libraries&lt;br /&gt;
This does not mean you have to upgrade all your production servers to a new (and potentially buggy) release which has just been made available to the public.  What you must do is download the latest stable bugfix release that has continual support.  For the JRE and Tomcat you should be looking at the last digits in the version number (5.5.'''X''') as it represents the bugfix information.  The bugs fixed in these releases are publicly available so if you don't upgrade you could be providing attackers with a very easy route to compromise your server.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Installation of Apache Tomcat 5.5 ==&lt;br /&gt;
&lt;br /&gt;
=== UNIX ===&lt;br /&gt;
&lt;br /&gt;
* Create a tomcat user/group&lt;br /&gt;
* Download and unpack the core distribution (referenced as '''CATALINA_HOME''' from now on)&lt;br /&gt;
* Change '''CATALINA_HOME''' ownership to tomcat user and tomcat group&lt;br /&gt;
* Change files in '''CATALINA_HOME'''/conf to be readonly (400)&lt;br /&gt;
* Make sure tomcat user has read/write access to /tmp and write (300 - yes, only write/execute) access to '''CATALINA_HOME'''/logs&lt;br /&gt;
&lt;br /&gt;
=== Windows ===&lt;br /&gt;
&lt;br /&gt;
* Download the core windows service installer&lt;br /&gt;
* Start the installation, click ''Next'' and ''Agree'' to the licence&lt;br /&gt;
* Untick ''native'', ''documentation'', ''examples'' and ''webapps'' then click ''Next''&lt;br /&gt;
* Choose an installation directory (referenced as '''CATALINA_HOME''' from now on), preferably on a different drive to the OS.  &lt;br /&gt;
* Choose an administrator username (NOT admin) and a secure password that complies with your organisations password policy.&lt;br /&gt;
* Complete tomcat installation, but do not start service.&lt;br /&gt;
&lt;br /&gt;
=== Common ===&lt;br /&gt;
&lt;br /&gt;
* Remove everything from '''CATALINA_HOME'''/webapps (ROOT, balancer, jsp-examples, servlet-examples, tomcat-docs, webdav)&lt;br /&gt;
&lt;br /&gt;
* Remove everything from '''CATALINA_HOME'''/server/webapps (host-manager, manager).  Note that it can be useful to keep the manager webapp installed if you need the ability to redeploy without restarting Tomcat.  If you choose to keep it please read the section on Securing the Manager WebApp.&lt;br /&gt;
&lt;br /&gt;
* Remove '''CATALINA_HOME'''/conf/Catalina/localhost/host-manager.xml and '''CATALINA_HOME'''/conf/Catalina/localhost/manager.xml (again, if you are keeping the manager application, do not remove this).&lt;br /&gt;
&lt;br /&gt;
* Make sure the default servlet is configured '''not''' to serve index pages when a welcome file is not present.  In '''CATALINA_HOME'''/conf/web.xml&lt;br /&gt;
  &amp;lt;servlet&amp;gt;&lt;br /&gt;
    &amp;lt;servlet-name&amp;gt;default&amp;lt;/servlet-name&amp;gt;&lt;br /&gt;
    &amp;lt;servlet-class&amp;gt;org.apache.catalina.servlets.DefaultServlet&amp;lt;/servlet-class&amp;gt;&lt;br /&gt;
    &amp;lt;init-param&amp;gt;&lt;br /&gt;
      &amp;lt;param-name&amp;gt;debug&amp;lt;/param-name&amp;gt;&lt;br /&gt;
      &amp;lt;param-value&amp;gt;0&amp;lt;/param-value&amp;gt;&lt;br /&gt;
    &amp;lt;/init-param&amp;gt;&lt;br /&gt;
    &amp;lt;init-param&amp;gt;&lt;br /&gt;
      &amp;lt;param-name&amp;gt;listings&amp;lt;/param-name&amp;gt;&lt;br /&gt;
      &amp;lt;param-value&amp;gt;'''false'''&amp;lt;/param-value&amp;gt;  &amp;amp;lt;!-- make sure this is false --&amp;amp;gt;&lt;br /&gt;
    &amp;lt;/init-param&amp;gt;&lt;br /&gt;
    &amp;lt;load-on-startup&amp;gt;1&amp;lt;/load-on-startup&amp;gt;&lt;br /&gt;
  &amp;lt;/servlet&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Remove version string from HTTP error messages by repacking '''CATALINA_HOME'''/server/lib/catalina.jar with an updated ServerInfo.properties file.&lt;br /&gt;
:unpack catalina.jar&lt;br /&gt;
  cd CATALINA_HOME/server/lib&lt;br /&gt;
  jar xf catalina.jar org/apache/catalina/util/ServerInfo.properties&lt;br /&gt;
:update ServerInfo.properties by changing server.info line to server.info=Apache Tomcat&lt;br /&gt;
:repackage catalina.jar&lt;br /&gt;
  jar uf catalina.jar org/apache/catalina/util/ServerInfo.properties&lt;br /&gt;
:remove CATALINA_HOME/server/lib/org (created when extracting the ServerInfo.properties file)&lt;br /&gt;
&lt;br /&gt;
* Replace default error page (default is stacktrace) by adding the following into '''CATALINA_HOME'''/conf/web.xml.  The default error page shows a full stacktrace which is a disclosure of sensitive information.  ''The following solution is not ideal as it produces a blank page because Tomcat cannot find the file specified, but without a better solution this, at least, achieves the desired result.  A well configured web application will override this default in CATALINA_HOME/webapps/APP_NAME/WEB-INF/web.xml so it won't cause problems.''&lt;br /&gt;
  &amp;lt;error-page&amp;gt;&lt;br /&gt;
    &amp;lt;exception-type&amp;gt;java.lang.Exception&amp;lt;/exception-type&amp;gt;&lt;br /&gt;
    &amp;lt;location&amp;gt;/error.jsp&amp;lt;/location&amp;gt;&lt;br /&gt;
  &amp;lt;/error-page&amp;gt;&lt;br /&gt;
* Consider replacing '''CATALINA_HOME'''/conf/server.xml with '''CATALINA_HOME'''/conf/server-minimal.xml - ''work out what we lose''&lt;br /&gt;
&lt;br /&gt;
* Replace the server version string from HTTP headers in server responses, by adding the server keyword in your Connectors in '''CATALINA_HOME'''/conf/server.xml&lt;br /&gt;
  &amp;lt;Connector port=&amp;quot;8080&amp;quot; ...&lt;br /&gt;
             server=&amp;quot;Apache&amp;quot; /&amp;gt;  &amp;amp;lt;!-- server header is now Apache --&amp;amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Start Tomcat, deploy your applications into '''CATALINA_HOME'''/webapps and hope it works!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Protecting the Shutdown Port ==&lt;br /&gt;
Tomcat uses a port (defaults to 8005) as a shutdown port.  What this means is that to stop all webapps and stop Tomcat cleanly the shutdown scripts make a connection to this port and send the ''shutdown'' command.  This is not as huge a security problem as it may sound considering the connection to the port must be made from the machine running tomcat and the ''shutdown'' command can be changed to something other than the string ''SHUTDOWN''.  However, it's wise to take the following precautions;&lt;br /&gt;
* if you are running a publicly accessible server make sure you prevent external access to the shutdown port by using a suitable firewall.&lt;br /&gt;
* change the shutdown command in '''CATALINA_HOME'''/conf/server.xml and make sure that file is only readable by the tomcat user.&lt;br /&gt;
  &amp;amp;lt;Server port=&amp;quot;8005&amp;quot; shutdown=&amp;quot;ReallyComplexWord&amp;quot;&amp;amp;gt;&lt;br /&gt;
* if this is still a big problem for you then check [http://marc.theaimsgroup.com/?l=tomcat-user&amp;amp;m=104400608619118&amp;amp;w=2 this thread], from the Tomcat mailing list, for alternatives (they all involve code customisation though).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Securing Manager WebApp ==&lt;br /&gt;
&lt;br /&gt;
* By default there are no users with the manager role.  To make use of the manager webapp you need to add a new user into the '''CATALINA_HOME'''/conf/tomcat-users.xml file.&lt;br /&gt;
  &amp;lt;user username=&amp;quot;darren&amp;quot; password=&amp;quot;ReallyComplexPassword&amp;quot; roles=&amp;quot;manager&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Using a [http://tomcat.apache.org/tomcat-5.5-doc/config/valve.html valve] to filter by IP or hostname to only allow a subset of machines to connect (i.e. LAN machines).  Add one of the following within the Context tag in '''CATALINA_HOME'''/conf/Catalina/localhost/manager.xml&lt;br /&gt;
  &amp;amp;lt;!-- allow only LAN IPs to connect to the manager webapp --&amp;amp;gt;&lt;br /&gt;
  &amp;amp;lt;!-- contrary to the current Tomcat 5.5 documation the value for '''allow''' is not a regular expression --&amp;amp;gt;&lt;br /&gt;
  &amp;amp;lt;!-- future versions may have to be specified as 192\.168\.1\.* --&amp;amp;gt;&lt;br /&gt;
  &amp;lt;Valve className=&amp;quot;org.apache.catalina.valves.RemoteAddrValve&amp;quot;&lt;br /&gt;
         allow=&amp;quot;192.168.1.*&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  &amp;amp;lt;!-- allow only LAN hosts to connect to the manager webapp --&amp;amp;gt;&lt;br /&gt;
  &amp;amp;lt;!-- contrary to the current Tomcat 5.5 documation the value for '''allow''' is not a regular expression --&amp;amp;gt;&lt;br /&gt;
  &amp;amp;lt;!-- future versions may have to be specified as *\.localdomain\.com --&amp;amp;gt;&lt;br /&gt;
  &amp;lt;Valve className=&amp;quot;org.apache.catalina.valves.RemoteHostValve&amp;quot;&lt;br /&gt;
         allow=&amp;quot;*.localdomain.com&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* You can rename the manager webapp to something else, e.g. ''foobar''&lt;br /&gt;
** Move '''CATALINA_HOME'''/conf/Catalina/localhost/'''manager.xml''' to '''CATALINA_HOME'''/conf/Catalina/localhost/'''foobar.xml'''&lt;br /&gt;
** Update the '''docBase''' attribute within '''CATALINA_HOME'''/conf/Catalina/localhost/'''foobar.xml''' to ${catalina.home}/server/webapps/foobar&lt;br /&gt;
** Move '''CATALINA_HOME'''/server/webapps/'''manager''' to '''CATALINA_HOME'''/server/webapps/'''foobar'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Logging ==&lt;br /&gt;
&lt;br /&gt;
As of tomcat 5.5 logging is now handled by the commons-logging framework allowing you to choose your preferred logging implementation - log4j or standard JDK logging.  By default the standard JDK logging is used (or a compatible extension called juli to be more precise), storing daily log files in '''CATALINA_HOME'''/logs.&lt;br /&gt;
&lt;br /&gt;
By default additional webapp log entries are added to '''CATALINA_HOME'''/logs/catalina.YYYY-MM-DD.log and System.out/System.err are redirected to '''CATALINA_HOME'''/logs/catalina.out.  To place webapp log entries in individual log files create a ''logging.properties'' file similar to the following within '''CATALINA_HOME'''/webapps/''APP_NAME''/WEB-INF/classes (change the ''APP_NAME'' value to create a unquie file for each webapp)&lt;br /&gt;
&lt;br /&gt;
  handlers = org.apache.juli.FileHandler, java.util.logging.ConsoleHandler&lt;br /&gt;
  org.apache.juli.FileHandler.level = ALL&lt;br /&gt;
  org.apache.juli.FileHandler.directory = ${catalina.base}/logs&lt;br /&gt;
  org.apache.juli.FileHandler.prefix = APP_NAME.&lt;br /&gt;
  java.util.logging.ConsoleHandler.level = ALL&lt;br /&gt;
  java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter&lt;br /&gt;
&lt;br /&gt;
Further details on logging configuration can be found in the [http://tomcat.apache.org/tomcat-5.5-doc/logging.html tomcat logging documentation.]&lt;br /&gt;
&lt;br /&gt;
''TODO - details on disabling most of catalina.out output''&lt;br /&gt;
&lt;br /&gt;
== Encryption ==&lt;br /&gt;
&lt;br /&gt;
* SSL for password or other sensitive data exchange (''bordering on application security, not specific to tomcat'')&lt;br /&gt;
* SSL for connections (JDBC, LDAP, etc ..)&lt;br /&gt;
* The Tomcat documentation clearly explains how to [http://tomcat.apache.org/tomcat-5.5-doc/ssl-howto.html enable SSL.]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Java Security ==&lt;br /&gt;
&lt;br /&gt;
=== Running Tomcat with a Security Manager=== &lt;br /&gt;
The default Tomcat configuration provides good protection for most requirements, but does not prevent a malicious application from compromising the security of other applications running in the same instance.  To prevent this sort of attack, Tomcat can be run with a Security Manager enabled which strictly controls access to server resources.&lt;br /&gt;
Tomcat documentation has a good section on [http://tomcat.apache.org/tomcat-5.5-doc/security-manager-howto.html enabling the Security Manager.]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Miscellaneous ==&lt;br /&gt;
&lt;br /&gt;
* [http://tomcat.apache.org/faq/security.html Tomcat Security FAQ]&lt;br /&gt;
&lt;br /&gt;
=== Using Port 80 ===&lt;br /&gt;
&lt;br /&gt;
If you are on a Windows machine you will be able to change the port attribute of the connector within the ''Catalina'' service from 8080 to 80.  This allows you to use tomcat directly to serve all requests.  Depending on your requirements it may not be good enough to serve directly from Tomcat so you may like to consider;&lt;br /&gt;
* Use IIS / Apache running on port 80 and mod_jk to proxy requests to Tomcat&lt;br /&gt;
&lt;br /&gt;
On a UNIX machine only root is allowed to run services on ports below 1024 (kernel recompilation can overcome this).  It is a very bad idea to run Tomcat as root, so the options are;&lt;br /&gt;
* Use Apache running on port 80 and mod_jk (or mod_proxy_ajp) to proxy requests to Tomcat&lt;br /&gt;
* Run Tomcat as root, but in a chroot jail&lt;br /&gt;
* Use a tool like authbind to enable a non root user to bind to ports below 1024&lt;br /&gt;
* Use a port forwarder such as [http://www.netfilter.org/projects/iptables/index.html Iptables] to redirect incoming requests from 8080 to 80.  This has the disadvantage that internal redirects still need to use 8080.&lt;br /&gt;
* Run [http://www.squid-cache.org/ Squid] as a web accelerator in front of Tomcat&lt;br /&gt;
* Use JSVC/procrun&lt;br /&gt;
&lt;br /&gt;
=== Cleartext Passwords in CATALINA_HOME/conf/server.xml ===&lt;br /&gt;
&lt;br /&gt;
When configuring a resource, such as a JDBC pool, it is necessary to include clear text username and password in CATALINA_HOME/conf/server.xml  Best practices advice us never to store clear text passwords, but the following paragraphs highlight it is very difficult to avoid.&lt;br /&gt;
&lt;br /&gt;
If one way encryption was used on the password it must be possible for a database connection to be established using a username and encrypted password - so the encrypted password is just as valuable as the clear text one to an attacker.&lt;br /&gt;
&lt;br /&gt;
If two way encryption was used a keyfile is needed which must also live on the filesystem.  To make it more secure a passphase is added to the keyfile which then has to be stored in the configuration as clear text - no improvement.&lt;br /&gt;
&lt;br /&gt;
Encoding is security by obscurity and offers no form of protection (algorithms can be reverse engineered).  What encoding does do is make huge amounts of overhead work - you need to customise Tomcat and the commons digester it uses to parse the config files.  You'd also need a way to create encoded passwords.&lt;br /&gt;
&lt;br /&gt;
In the case of a JDBC pool what you can do is;&lt;br /&gt;
* make sure the database user only has access to the databases and tables they need (also limit rights as necessary).&lt;br /&gt;
* make sure the raw database files are only accessible to the user running the database services (e.g. mysql/postgresql user)&lt;br /&gt;
* make sure the Tomcat configuration files are only accessible to the tomcat user&lt;br /&gt;
&lt;br /&gt;
[[Category:OWASP Java Project]]&lt;br /&gt;
[[Category:Java]]&lt;/div&gt;</summary>
		<author><name>Dledmonds</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Talk:Securing_tomcat&amp;diff=15140</id>
		<title>Talk:Securing tomcat</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Talk:Securing_tomcat&amp;diff=15140"/>
				<updated>2007-01-09T09:35:53Z</updated>
		
		<summary type="html">&lt;p&gt;Dledmonds: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;What's the best way to acknowledge the contributions of others as I'd like to add some thanks to Kris Easter, Michel Prunet and Stephen More.  This discussion area?  In brackets after the article link from [https://www.owasp.org/index.php/OWASP_Java_Project_Roadmap#Securing_Popular_J2EE_Servers Java Project Roadmap] ? [[User:Dledmonds|Darren]] 08:58, 27 October 2006 (EDT)&lt;br /&gt;
&lt;br /&gt;
==UNIX Permissions==&lt;br /&gt;
&lt;br /&gt;
&amp;gt; Change files in CATALINA_HOME/conf to be readonly (440)&lt;br /&gt;
&lt;br /&gt;
Initially these are 600 (except for tomcat-users.xml which is 644 and Tomcat keeps it that way). Is there a need to make them group-readable?&lt;br /&gt;
&lt;br /&gt;
&amp;gt; Make sure tomcat user has ... write (220 - yes, only write) access to CATALINA_HOME/logs&lt;br /&gt;
&lt;br /&gt;
This doesn't work. I think the best that can be done here is 750 or 700.&lt;br /&gt;
&lt;br /&gt;
[[User:Combatopera|Combatopera]] 15:53, 12 November 2006 (EST)&lt;br /&gt;
&lt;br /&gt;
CATALINA_HOME/conf files updated to recommend chmod 400.  tomcat-user.xml the same as tomcat doesn't write to it.  Original file permissions for all these conf files were 600 when 5.5.20 was unpacked on a debian box.&lt;br /&gt;
&lt;br /&gt;
CATALINA_HOME/logs directory updated to recommend chmod 300.  Prevents tomcat user reading the logs within, but writing works fine for me - again after 5.5.20 was unpacked on a debian box.&lt;br /&gt;
&lt;br /&gt;
[[User:Dledmonds|Darren]] 04:35, 9 January 2007 (EST)&lt;/div&gt;</summary>
		<author><name>Dledmonds</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Securing_tomcat&amp;diff=15137</id>
		<title>Securing tomcat</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Securing_tomcat&amp;diff=15137"/>
				<updated>2007-01-09T09:30:15Z</updated>
		
		<summary type="html">&lt;p&gt;Dledmonds: /* UNIX */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
Most weaknesses in [http://tomcat.apache.org/ Apache Tomcat] come from incorrect or inappropiate configuration.  It is nearly always possible to make Tomcat more secure than the default out of the box installation.  What follows documents best practices and recommendations on securing a production Tomcat server, whether it be hosted on a Windows or Unix based operating system.  ''Please note that the section ordering is not a representation of the section importance.''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Software Versions ==&lt;br /&gt;
&lt;br /&gt;
The first step is to make sure you are running the latest stable releases of software;&lt;br /&gt;
* Java Runtime Environment (JRE) or SDK&lt;br /&gt;
* Tomcat&lt;br /&gt;
* Third party libraries&lt;br /&gt;
This does not mean you have to upgrade all your production servers to a new (and potentially buggy) release which has just been made available to the public.  What you must do is download the latest stable bugfix release that has continual support.  For the JRE and Tomcat you should be looking at the last digits in the version number (5.5.'''X''') as it represents the bugfix information.  The bugs fixed in these releases are publicly available so if you don't upgrade you could be providing attackers with a very easy route to compromise your server.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Installation of Apache Tomcat 5.5 ==&lt;br /&gt;
&lt;br /&gt;
=== UNIX ===&lt;br /&gt;
&lt;br /&gt;
* Create a tomcat user/group&lt;br /&gt;
* Download and unpack the core distribution (referenced as '''CATALINA_HOME''' from now on)&lt;br /&gt;
* Change '''CATALINA_HOME''' ownership to tomcat user and tomcat group&lt;br /&gt;
* Change files in '''CATALINA_HOME'''/conf to be readonly (400)&lt;br /&gt;
* Make sure tomcat user has read/write access to /tmp and write (300 - yes, only write/execute) access to '''CATALINA_HOME'''/logs&lt;br /&gt;
&lt;br /&gt;
=== Windows ===&lt;br /&gt;
&lt;br /&gt;
* Download the core windows service installer&lt;br /&gt;
* Start the installation, click ''Next'' and ''Agree'' to the licence&lt;br /&gt;
* Untick ''native'', ''documentation'', ''examples'' and ''webapps'' then click ''Next''&lt;br /&gt;
* Choose an installation directory (referenced as '''CATALINA_HOME''' from now on), preferably on a different drive to the OS.  &lt;br /&gt;
* Choose an administrator username (NOT admin) and a secure password that complies with your organisations password policy.&lt;br /&gt;
* Complete tomcat installation, but do not start service.&lt;br /&gt;
&lt;br /&gt;
=== Common ===&lt;br /&gt;
&lt;br /&gt;
* Remove everything from '''CATALINA_HOME'''/webapps (ROOT, balancer, jsp-examples, servlet-examples, tomcat-docs, webdav)&lt;br /&gt;
&lt;br /&gt;
* Remove everything from '''CATALINA_HOME'''/server/webapps (host-manager, manager).  Note that it can be useful to keep the manager webapp installed if you need the ability to redeploy without restarting Tomcat.  If you choose to keep it please read the section on Securing the Manager WebApp.&lt;br /&gt;
&lt;br /&gt;
* Remove '''CATALINA_HOME'''/conf/Catalina/localhost/host-manager.xml and '''CATALINA_HOME'''/conf/Catalina/localhost/manager.xml (again, if you are keeping the manager application, do not remove this).&lt;br /&gt;
&lt;br /&gt;
* Make sure the default servlet is configured '''not''' to serve index pages when a welcome file is not present.  In '''CATALINA_HOME'''/conf/web.xml&lt;br /&gt;
  &amp;lt;servlet&amp;gt;&lt;br /&gt;
    &amp;lt;servlet-name&amp;gt;default&amp;lt;/servlet-name&amp;gt;&lt;br /&gt;
    &amp;lt;servlet-class&amp;gt;org.apache.catalina.servlets.DefaultServlet&amp;lt;/servlet-class&amp;gt;&lt;br /&gt;
    &amp;lt;init-param&amp;gt;&lt;br /&gt;
      &amp;lt;param-name&amp;gt;debug&amp;lt;/param-name&amp;gt;&lt;br /&gt;
      &amp;lt;param-value&amp;gt;0&amp;lt;/param-value&amp;gt;&lt;br /&gt;
    &amp;lt;/init-param&amp;gt;&lt;br /&gt;
    &amp;lt;init-param&amp;gt;&lt;br /&gt;
      &amp;lt;param-name&amp;gt;listings&amp;lt;/param-name&amp;gt;&lt;br /&gt;
      &amp;lt;param-value&amp;gt;'''false'''&amp;lt;/param-value&amp;gt;  &amp;amp;lt;!-- make sure this is false --&amp;amp;gt;&lt;br /&gt;
    &amp;lt;/init-param&amp;gt;&lt;br /&gt;
    &amp;lt;load-on-startup&amp;gt;1&amp;lt;/load-on-startup&amp;gt;&lt;br /&gt;
  &amp;lt;/servlet&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Remove version string from HTTP error messages by repacking '''CATALINA_HOME'''/server/lib/catalina.jar with an updated ServerInfo.properties file.&lt;br /&gt;
:unpack catalina.jar&lt;br /&gt;
  cd CATALINA_HOME/server/lib&lt;br /&gt;
  jar xf catalina.jar org/apache/catalina/util/ServerInfo.properties&lt;br /&gt;
:update ServerInfo.properties by changing server.info line to server.info=Apache Tomcat&lt;br /&gt;
:repackage catalina.jar&lt;br /&gt;
  jar uf catalina.jar org/apache/catalina/util/ServerInfo.properties&lt;br /&gt;
:remove CATALINA_HOME/server/lib/org (created when extracting the ServerInfo.properties file)&lt;br /&gt;
&lt;br /&gt;
* Replace default error page (default is stacktrace) by adding the following into '''CATALINA_HOME'''/conf/web.xml.  The default error page shows a full stacktrace which is a disclosure of sensitive information.  ''The following solution is not ideal as it produces a blank page because Tomcat cannot find the file specified, but without a better solution this, at least, achieves the desired result.  A well configured web application will override this default in CATALINA_HOME/webapps/APP_NAME/WEB-INF/web.xml so it won't cause problems.''&lt;br /&gt;
  &amp;lt;error-page&amp;gt;&lt;br /&gt;
    &amp;lt;exception-type&amp;gt;java.lang.Exception&amp;lt;/exception-type&amp;gt;&lt;br /&gt;
    &amp;lt;location&amp;gt;/error.jsp&amp;lt;/location&amp;gt;&lt;br /&gt;
  &amp;lt;/error-page&amp;gt;&lt;br /&gt;
* Consider replacing '''CATALINA_HOME'''/conf/server.xml with '''CATALINA_HOME'''/conf/server-minimal.xml - ''work out what we lose''&lt;br /&gt;
&lt;br /&gt;
* Replace the server version string from HTTP headers in server responses, by adding the server keyword in your Connectors in '''CATALINA_HOME'''/conf/server.xml&lt;br /&gt;
  &amp;lt;Connector port=&amp;quot;8080&amp;quot; ...&lt;br /&gt;
             server=&amp;quot;Apache&amp;quot; /&amp;gt;  &amp;amp;lt;!-- server header is now Apache --&amp;amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Start Tomcat, deploy your applications into '''CATALINA_HOME'''/webapps and hope it works!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Protecting the Shutdown Port ==&lt;br /&gt;
Tomcat uses a port (defaults to 8005) as a shutdown port.  What this means is that to stop all webapps and stop Tomcat cleanly the shutdown scripts make a connection to this port and send the ''shutdown'' command.  This is not as huge a security problem as it may sound considering the connection to the port must be made from the machine running tomcat and the ''shutdown'' command can be changed to something other than the string ''SHUTDOWN''.  However, it's wise to take the following precautions;&lt;br /&gt;
* if you are running a publicly accessible server make sure you prevent external access to the shutdown port by using a suitable firewall.&lt;br /&gt;
* change the shutdown command in '''CATALINA_HOME'''/conf/server.xml and make sure that file is only readable by the tomcat user.&lt;br /&gt;
  &amp;amp;lt;Server port=&amp;quot;8005&amp;quot; shutdown=&amp;quot;ReallyComplexWord&amp;quot;&amp;amp;gt;&lt;br /&gt;
* if this is still a big problem for you then check [http://marc.theaimsgroup.com/?l=tomcat-user&amp;amp;m=104400608619118&amp;amp;w=2 this thread], from the Tomcat mailing list, for alternatives (they all involve code customisation though).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Securing Manager WebApp ==&lt;br /&gt;
&lt;br /&gt;
* By default there are no users with the manager role.  To make use of the manager webapp you need to add a new user into the '''CATALINA_HOME'''/conf/tomcat-users.xml file.&lt;br /&gt;
  &amp;lt;user username=&amp;quot;darren&amp;quot; password=&amp;quot;ReallyComplexPassword&amp;quot; roles=&amp;quot;manager&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Using a [http://tomcat.apache.org/tomcat-5.5-doc/config/valve.html valve] to filter by IP or hostname to only allow a subset of machines to connect (i.e. LAN machines).  Add one of the following within the Context tag in '''CATALINA_HOME'''/conf/Catalina/localhost/manager.xml&lt;br /&gt;
  &amp;amp;lt;!-- allow only LAN IPs to connect to the manager webapp --&amp;amp;gt;&lt;br /&gt;
  &amp;amp;lt;!-- contrary to the current Tomcat 5.5 documation the value for '''allow''' is not a regular expression --&amp;amp;gt;&lt;br /&gt;
  &amp;amp;lt;!-- future versions may have to be specified as 192\.168\.1\.* --&amp;amp;gt;&lt;br /&gt;
  &amp;lt;Valve className=&amp;quot;org.apache.catalina.valves.RemoteAddrValve&amp;quot;&lt;br /&gt;
         allow=&amp;quot;192.168.1.*&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  &amp;amp;lt;!-- allow only LAN hosts to connect to the manager webapp --&amp;amp;gt;&lt;br /&gt;
  &amp;amp;lt;!-- contrary to the current Tomcat 5.5 documation the value for '''allow''' is not a regular expression --&amp;amp;gt;&lt;br /&gt;
  &amp;amp;lt;!-- future versions may have to be specified as *\.localdomain\.com --&amp;amp;gt;&lt;br /&gt;
  &amp;lt;Valve className=&amp;quot;org.apache.catalina.valves.RemoteHostValve&amp;quot;&lt;br /&gt;
         allow=&amp;quot;*.localdomain.com&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* You can rename the manager webapp to something else, e.g. ''foobar''&lt;br /&gt;
** Move '''CATALINA_HOME'''/conf/Catalina/localhost/'''manager.xml''' to '''CATALINA_HOME'''/conf/Catalina/localhost/'''foobar.xml'''&lt;br /&gt;
** Update the '''docBase''' attribute within '''CATALINA_HOME'''/conf/Catalina/localhost/'''foobar.xml''' to ${catalina.home}/server/webapps/foobar&lt;br /&gt;
** Move '''CATALINA_HOME'''/server/webapps/'''manager''' to '''CATALINA_HOME'''/server/webapps/'''foobar'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Logging ==&lt;br /&gt;
&lt;br /&gt;
* TODO: Audit trails&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Encryption ==&lt;br /&gt;
&lt;br /&gt;
* SSL for password or other sensitive data exchange (''bordering on application security, not specific to tomcat'')&lt;br /&gt;
* SSL for connections (JDBC, LDAP, etc ..)&lt;br /&gt;
* The Tomcat documentation clearly explains how to [http://tomcat.apache.org/tomcat-5.5-doc/ssl-howto.html enable SSL.]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Java Security ==&lt;br /&gt;
&lt;br /&gt;
=== Running Tomcat with a Security Manager=== &lt;br /&gt;
The default Tomcat configuration provides good protection for most requirements, but does not prevent a malicious application from compromising the security of other applications running in the same instance.  To prevent this sort of attack, Tomcat can be run with a Security Manager enabled which strictly controls access to server resources.&lt;br /&gt;
Tomcat documentation has a good section on [http://tomcat.apache.org/tomcat-5.5-doc/security-manager-howto.html enabling the Security Manager.]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Miscellaneous ==&lt;br /&gt;
&lt;br /&gt;
* [http://tomcat.apache.org/faq/security.html Tomcat Security FAQ]&lt;br /&gt;
&lt;br /&gt;
=== Using Port 80 ===&lt;br /&gt;
&lt;br /&gt;
If you are on a Windows machine you will be able to change the port attribute of the connector within the ''Catalina'' service from 8080 to 80.  This allows you to use tomcat directly to serve all requests.  Depending on your requirements it may not be good enough to serve directly from Tomcat so you may like to consider;&lt;br /&gt;
* Use IIS / Apache running on port 80 and mod_jk to proxy requests to Tomcat&lt;br /&gt;
&lt;br /&gt;
On a UNIX machine only root is allowed to run services on ports below 1024 (kernel recompilation can overcome this).  It is a very bad idea to run Tomcat as root, so the options are;&lt;br /&gt;
* Use Apache running on port 80 and mod_jk (or mod_proxy_ajp) to proxy requests to Tomcat&lt;br /&gt;
* Run Tomcat as root, but in a chroot jail&lt;br /&gt;
* Use a tool like authbind to enable a non root user to bind to ports below 1024&lt;br /&gt;
* Use a port forwarder such as [http://www.netfilter.org/projects/iptables/index.html Iptables] to redirect incoming requests from 8080 to 80.  This has the disadvantage that internal redirects still need to use 8080.&lt;br /&gt;
* Run [http://www.squid-cache.org/ Squid] as a web accelerator in front of Tomcat&lt;br /&gt;
* Use JSVC/procrun&lt;br /&gt;
&lt;br /&gt;
=== Cleartext Passwords in CATALINA_HOME/conf/server.xml ===&lt;br /&gt;
&lt;br /&gt;
When configuring a resource, such as a JDBC pool, it is necessary to include clear text username and password in CATALINA_HOME/conf/server.xml  Best practices advice us never to store clear text passwords, but the following paragraphs highlight it is very difficult to avoid.&lt;br /&gt;
&lt;br /&gt;
If one way encryption was used on the password it must be possible for a database connection to be established using a username and encrypted password - so the encrypted password is just as valuable as the clear text one to an attacker.&lt;br /&gt;
&lt;br /&gt;
If two way encryption was used a keyfile is needed which must also live on the filesystem.  To make it more secure a passphase is added to the keyfile which then has to be stored in the configuration as clear text - no improvement.&lt;br /&gt;
&lt;br /&gt;
Encoding is security by obscurity and offers no form of protection (algorithms can be reverse engineered).  What encoding does do is make huge amounts of overhead work - you need to customise Tomcat and the commons digester it uses to parse the config files.  You'd also need a way to create encoded passwords.&lt;br /&gt;
&lt;br /&gt;
In the case of a JDBC pool what you can do is;&lt;br /&gt;
* make sure the database user only has access to the databases and tables they need (also limit rights as necessary).&lt;br /&gt;
* make sure the raw database files are only accessible to the user running the database services (e.g. mysql/postgresql user)&lt;br /&gt;
* make sure the Tomcat configuration files are only accessible to the tomcat user&lt;br /&gt;
&lt;br /&gt;
[[Category:OWASP Java Project]]&lt;br /&gt;
[[Category:Java]]&lt;/div&gt;</summary>
		<author><name>Dledmonds</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Talk:Securing_tomcat&amp;diff=13188</id>
		<title>Talk:Securing tomcat</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Talk:Securing_tomcat&amp;diff=13188"/>
				<updated>2006-11-17T11:45:51Z</updated>
		
		<summary type="html">&lt;p&gt;Dledmonds: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;What's the best way to acknowledge the contributions of others as I'd like to add some thanks to Kris Easter, Michel Prunet and Stephen More.  This discussion area?  In brackets after the article link from [https://www.owasp.org/index.php/OWASP_Java_Project_Roadmap#Securing_Popular_J2EE_Servers Java Project Roadmap] ? [[User:Dledmonds|Darren]] 08:58, 27 October 2006 (EDT)&lt;br /&gt;
&lt;br /&gt;
==UNIX Permissions==&lt;br /&gt;
&lt;br /&gt;
&amp;gt; Change files in CATALINA_HOME/conf to be readonly (440)&lt;br /&gt;
&lt;br /&gt;
Initially these are 600 (except for tomcat-users.xml which is 644 and Tomcat keeps it that way). Is there a need to make them group-readable?&lt;br /&gt;
&lt;br /&gt;
&amp;gt; Make sure tomcat user has ... write (220 - yes, only write) access to CATALINA_HOME/logs&lt;br /&gt;
&lt;br /&gt;
This doesn't work. I think the best that can be done here is 750 or 700.&lt;br /&gt;
&lt;br /&gt;
[[User:Combatopera|Combatopera]] 15:53, 12 November 2006 (EST)&lt;br /&gt;
&lt;br /&gt;
You're right, those permission values were a hasty addition without being tested correctly.  I'll test them properly and update the documentation accordingly.  You mention 750 or 700 for the logs dir, what problems did you find with 300? [[User:Dledmonds|Darren]] 06:45, 17 November 2006 (EST)&lt;/div&gt;</summary>
		<author><name>Dledmonds</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Securing_tomcat&amp;diff=12244</id>
		<title>Securing tomcat</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Securing_tomcat&amp;diff=12244"/>
				<updated>2006-11-10T17:43:24Z</updated>
		
		<summary type="html">&lt;p&gt;Dledmonds: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
Most weaknesses in [http://tomcat.apache.org/ Apache Tomcat] come from incorrect or inappropiate configuration.  It is nearly always possible to make Tomcat more secure than the default out of the box installation.  What follows documents best practices and recommendations on securing a production Tomcat server, whether it be hosted on a Windows or Unix based operating system.  ''Please note that the section ordering is not a representation of the section importance.''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Software Versions ==&lt;br /&gt;
&lt;br /&gt;
The first step is to make sure you are running the latest stable releases of software;&lt;br /&gt;
* Java Runtime Environment (JRE) or SDK&lt;br /&gt;
* Tomcat&lt;br /&gt;
* Third party libraries&lt;br /&gt;
This does not mean you have to upgrade all your production servers to a new (and potentially buggy) release which has just been made available to the public.  What you must do is download the latest stable bugfix release that has continual support.  For the JRE and Tomcat you should be looking at the last digits in the version number (5.5.'''X''') as it represents the bugfix information.  The bugs fixed in these releases are publicly available so if you don't upgrade you could be providing attackers with a very easy route to compromise your server.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Installation of Apache Tomcat 5.5 ==&lt;br /&gt;
&lt;br /&gt;
=== UNIX ===&lt;br /&gt;
&lt;br /&gt;
* Create a tomcat user/group&lt;br /&gt;
* Download and unpack the core distribution (referenced as '''CATALINA_HOME''' from now on)&lt;br /&gt;
* Change '''CATALINA_HOME''' ownership to tomcat user and tomcat group&lt;br /&gt;
* Change files in '''CATALINA_HOME'''/conf to be readonly (440)&lt;br /&gt;
* Make sure tomcat user has read/write access (660) to /tmp and write (220 - yes, only write) access to '''CATALINA_HOME'''/log&lt;br /&gt;
&lt;br /&gt;
=== Windows ===&lt;br /&gt;
&lt;br /&gt;
* Download the core windows service installer&lt;br /&gt;
* Start the installation, click ''Next'' and ''Agree'' to the licence&lt;br /&gt;
* Untick ''native'', ''documentation'', ''examples'' and ''webapps'' then click ''Next''&lt;br /&gt;
* Choose an installation directory (referenced as '''CATALINA_HOME''' from now on), preferably on a different drive to the OS.  &lt;br /&gt;
* Choose an administrator username (NOT admin) and a secure password that complies with your organisations password policy.&lt;br /&gt;
* Complete tomcat installation, but do not start service.&lt;br /&gt;
&lt;br /&gt;
=== Common ===&lt;br /&gt;
&lt;br /&gt;
* Remove everything from '''CATALINA_HOME'''/webapps (ROOT, balancer, jsp-examples, servlet-examples, tomcat-docs, webdav)&lt;br /&gt;
&lt;br /&gt;
* Remove everything from '''CATALINA_HOME'''/server/webapps (host-manager, manager).  Note that it can be useful to keep the manager webapp installed if you need the ability to redeploy without restarting Tomcat.  If you choose to keep it please read the section on Securing the Manager WebApp.&lt;br /&gt;
&lt;br /&gt;
* Remove '''CATALINA_HOME'''/conf/Catalina/localhost/host-manager.xml and '''CATALINA_HOME'''/conf/Catalina/localhost/manager.xml (again, if you are keeping the manager application, do not remove this).&lt;br /&gt;
&lt;br /&gt;
* Make sure the default servlet is configured '''not''' to serve index pages when a welcome file is not present.  In '''CATALINA_HOME'''/conf/web.xml&lt;br /&gt;
  &amp;lt;servlet&amp;gt;&lt;br /&gt;
    &amp;lt;servlet-name&amp;gt;default&amp;lt;/servlet-name&amp;gt;&lt;br /&gt;
    &amp;lt;servlet-class&amp;gt;org.apache.catalina.servlets.DefaultServlet&amp;lt;/servlet-class&amp;gt;&lt;br /&gt;
    &amp;lt;init-param&amp;gt;&lt;br /&gt;
      &amp;lt;param-name&amp;gt;debug&amp;lt;/param-name&amp;gt;&lt;br /&gt;
      &amp;lt;param-value&amp;gt;0&amp;lt;/param-value&amp;gt;&lt;br /&gt;
    &amp;lt;/init-param&amp;gt;&lt;br /&gt;
    &amp;lt;init-param&amp;gt;&lt;br /&gt;
      &amp;lt;param-name&amp;gt;listings&amp;lt;/param-name&amp;gt;&lt;br /&gt;
      &amp;lt;param-value&amp;gt;'''false'''&amp;lt;/param-value&amp;gt;  &amp;amp;lt;!-- make sure this is false --&amp;amp;gt;&lt;br /&gt;
    &amp;lt;/init-param&amp;gt;&lt;br /&gt;
    &amp;lt;load-on-startup&amp;gt;1&amp;lt;/load-on-startup&amp;gt;&lt;br /&gt;
  &amp;lt;/servlet&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Remove version string from HTTP error messages by repacking '''CATALINA_HOME'''/server/lib/catalina.jar with an updated ServerInfo.properties file.&lt;br /&gt;
:unpack catalina.jar&lt;br /&gt;
  cd CATALINA_HOME/server/lib&lt;br /&gt;
  jar xf catalina.jar org/apache/catalina/util/ServerInfo.properties&lt;br /&gt;
:update ServerInfo.properties by changing server.info line to server.info=Apache Tomcat&lt;br /&gt;
:repackage catalina.jar&lt;br /&gt;
  jar uf catalina.jar org/apache/catalina/util/ServerInfo.properties&lt;br /&gt;
:remove CATALINA_HOME/server/lib/org (created when extracting the ServerInfo.properties file)&lt;br /&gt;
&lt;br /&gt;
* Replace default error page (default is stacktrace) by adding the following into '''CATALINA_HOME'''/conf/web.xml.  The default error page shows a full stacktrace which is a disclosure of sensitive information.  ''The following solution is not ideal as it produces a blank page because Tomcat cannot find the file specified, but without a better solution this, at least, achieves the desired result.  A well configured web application will override this default in CATALINA_HOME/webapps/APP_NAME/WEB-INF/web.xml so it won't cause problems.''&lt;br /&gt;
  &amp;lt;error-page&amp;gt;&lt;br /&gt;
    &amp;lt;exception-type&amp;gt;java.lang.Exception&amp;lt;/exception-type&amp;gt;&lt;br /&gt;
    &amp;lt;location&amp;gt;/error.jsp&amp;lt;/location&amp;gt;&lt;br /&gt;
  &amp;lt;/error-page&amp;gt;&lt;br /&gt;
* Consider replacing '''CATALINA_HOME'''/conf/server.xml with '''CATALINA_HOME'''/conf/server-minimal.xml - ''work out what we lose''&lt;br /&gt;
&lt;br /&gt;
* Replace the server version string from HTTP headers in server responses, by adding the server keyword in your Connectors in '''CATALINA_HOME'''/conf/server.xml&lt;br /&gt;
  &amp;lt;Connector port=&amp;quot;8080&amp;quot; ...&lt;br /&gt;
             server=&amp;quot;Apache&amp;quot; /&amp;gt;  &amp;amp;lt;!-- server header is now Apache --&amp;amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Start Tomcat, deploy your applications into '''CATALINA_HOME'''/webapps and hope it works!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Protecting the Shutdown Port ==&lt;br /&gt;
Tomcat uses a port (defaults to 8005) as a shutdown port.  What this means is that to stop all webapps and stop Tomcat cleanly the shutdown scripts make a connection to this port and send the ''shutdown'' command.  This is not as huge a security problem as it may sound considering the connection to the port must be made from the machine running tomcat and the ''shutdown'' command can be changed to something other than the string ''SHUTDOWN''.  However, it's wise to take the following precautions;&lt;br /&gt;
* if you are running a publicly accessible server make sure you prevent external access to the shutdown port by using a suitable firewall.&lt;br /&gt;
* change the shutdown command in '''CATALINA_HOME'''/conf/server.xml and make sure that file is only readable by the tomcat user.&lt;br /&gt;
  &amp;amp;lt;Server port=&amp;quot;8005&amp;quot; shutdown=&amp;quot;ReallyComplexWord&amp;quot;&amp;amp;gt;&lt;br /&gt;
* if this is still a big problem for you then check [http://marc.theaimsgroup.com/?l=tomcat-user&amp;amp;m=104400608619118&amp;amp;w=2 this thread], from the Tomcat mailing list, for alternatives (they all involve code customisation though).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Securing Manager WebApp ==&lt;br /&gt;
&lt;br /&gt;
* By default there are no users with the manager role.  To make use of the manager webapp you need to add a new user into the '''CATALINA_HOME'''/conf/tomcat-users.xml file.&lt;br /&gt;
  &amp;lt;user username=&amp;quot;darren&amp;quot; password=&amp;quot;ReallyComplexPassword&amp;quot; roles=&amp;quot;manager&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Using a [http://tomcat.apache.org/tomcat-5.5-doc/config/valve.html valve] to filter by IP or hostname to only allow a subset of machines to connect (i.e. LAN machines).  Add one of the following within the Context tag in '''CATALINA_HOME'''/conf/Catalina/localhost/manager.xml&lt;br /&gt;
  &amp;amp;lt;!-- allow only LAN IPs to connect to the manager webapp --&amp;amp;gt;&lt;br /&gt;
  &amp;amp;lt;!-- contrary to the current Tomcat 5.5 documation the value for '''allow''' is not a regular expression --&amp;amp;gt;&lt;br /&gt;
  &amp;amp;lt;!-- future versions may have to be specified as 192\.168\.1\.* --&amp;amp;gt;&lt;br /&gt;
  &amp;lt;Valve className=&amp;quot;org.apache.catalina.valves.RemoteAddrValve&amp;quot;&lt;br /&gt;
         allow=&amp;quot;192.168.1.*&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  &amp;amp;lt;!-- allow only LAN hosts to connect to the manager webapp --&amp;amp;gt;&lt;br /&gt;
  &amp;amp;lt;!-- contrary to the current Tomcat 5.5 documation the value for '''allow''' is not a regular expression --&amp;amp;gt;&lt;br /&gt;
  &amp;amp;lt;!-- future versions may have to be specified as *\.localdomain\.com --&amp;amp;gt;&lt;br /&gt;
  &amp;lt;Valve className=&amp;quot;org.apache.catalina.valves.RemoteHostValve&amp;quot;&lt;br /&gt;
         allow=&amp;quot;*.localdomain.com&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* You can rename the manager webapp to something else, e.g. ''foobar''&lt;br /&gt;
** Move '''CATALINA_HOME'''/conf/Catalina/localhost/'''manager.xml''' to '''CATALINA_HOME'''/conf/Catalina/localhost/'''foobar.xml'''&lt;br /&gt;
** Update the '''docBase''' attribute within '''CATALINA_HOME'''/conf/Catalina/localhost/'''foobar.xml''' to ${catalina.home}/server/webapps/foobar&lt;br /&gt;
** Move '''CATALINA_HOME'''/server/webapps/'''manager''' to '''CATALINA_HOME'''/server/webapps/'''foobar'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Logging ==&lt;br /&gt;
&lt;br /&gt;
* TODO: Audit trails&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Encryption ==&lt;br /&gt;
&lt;br /&gt;
* SSL for password or other sensitive data exchange (''bordering on application security, not specific to tomcat'')&lt;br /&gt;
* SSL for connections (JDBC, LDAP, etc ..)&lt;br /&gt;
* The Tomcat documentation clearly explains how to [http://tomcat.apache.org/tomcat-5.5-doc/ssl-howto.html enable SSL.]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Java Security ==&lt;br /&gt;
&lt;br /&gt;
=== Running Tomcat with a Security Manager=== &lt;br /&gt;
The default Tomcat configuration provides good protection for most requirements, but does not prevent a malicious application from compromising the security of other applications running in the same instance.  To prevent this sort of attack, Tomcat can be run with a Security Manager enabled which strictly controls access to server resources.&lt;br /&gt;
Tomcat documentation has a good section on [http://tomcat.apache.org/tomcat-5.5-doc/security-manager-howto.html enabling the Security Manager.]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Miscellaneous ==&lt;br /&gt;
&lt;br /&gt;
* [http://tomcat.apache.org/faq/security.html Tomcat Security FAQ]&lt;br /&gt;
&lt;br /&gt;
=== Using Port 80 ===&lt;br /&gt;
&lt;br /&gt;
If you are on a Windows machine you will be able to change the port attribute of the connector within the ''Catalina'' service from 8080 to 80.  This allows you to use tomcat directly to serve all requests.  Depending on your requirements it may not be good enough to serve directly from Tomcat so you may like to consider;&lt;br /&gt;
* Use IIS / Apache running on port 80 and mod_jk to proxy requests to Tomcat&lt;br /&gt;
&lt;br /&gt;
On a UNIX machine only root is allowed to run services on ports below 1024 (kernel recompilation can overcome this).  It is a very bad idea to run Tomcat as root, so the options are;&lt;br /&gt;
* Use Apache running on port 80 and mod_jk (or mod_proxy_ajp) to proxy requests to Tomcat&lt;br /&gt;
* Run Tomcat as root, but in a chroot jail&lt;br /&gt;
* Use a tool like authbind to enable a non root user to bind to ports below 1024&lt;br /&gt;
* Use a port forwarder such as [http://www.netfilter.org/projects/iptables/index.html Iptables] to redirect incoming requests from 8080 to 80.  This has the disadvantage that internal redirects still need to use 8080.&lt;br /&gt;
* Run [http://www.squid-cache.org/ Squid] as a web accelerator in front of Tomcat&lt;br /&gt;
* Use JSVC/procrun&lt;br /&gt;
&lt;br /&gt;
=== Cleartext Passwords in CATALINA_HOME/conf/server.xml ===&lt;br /&gt;
&lt;br /&gt;
When configuring a resource, such as a JDBC pool, it is necessary to include clear text username and password in CATALINA_HOME/conf/server.xml  Best practices advice us never to store clear text passwords, but the following paragraphs highlight it is very difficult to avoid.&lt;br /&gt;
&lt;br /&gt;
If one way encryption was used on the password it must be possible for a database connection to be established using a username and encrypted password - so the encrypted password is just as valuable as the clear text one to an attacker.&lt;br /&gt;
&lt;br /&gt;
If two way encryption was used a keyfile is needed which must also live on the filesystem.  To make it more secure a passphase is added to the keyfile which then has to be stored in the configuration as clear text - no improvement.&lt;br /&gt;
&lt;br /&gt;
Encoding is security by obscurity and offers no form of protection (algorithms can be reverse engineered).  What encoding does do is make huge amounts of overhead work - you need to customise Tomcat and the commons digester it uses to parse the config files.  You'd also need a way to create encoded passwords.&lt;br /&gt;
&lt;br /&gt;
In the case of a JDBC pool what you can do is;&lt;br /&gt;
* make sure the database user only has access to the databases and tables they need (also limit rights as necessary).&lt;br /&gt;
* make sure the raw database files are only accessible to the user running the database services (e.g. mysql/postgresql user)&lt;br /&gt;
* make sure the Tomcat configuration files are only accessible to the tomcat user&lt;br /&gt;
&lt;br /&gt;
[[Category:OWASP Java Project]]&lt;br /&gt;
[[Category:Java]]&lt;/div&gt;</summary>
		<author><name>Dledmonds</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Talk:Securing_tomcat&amp;diff=12243</id>
		<title>Talk:Securing tomcat</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Talk:Securing_tomcat&amp;diff=12243"/>
				<updated>2006-11-10T17:32:42Z</updated>
		
		<summary type="html">&lt;p&gt;Dledmonds: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;What's the best way to acknowledge the contributions of others as I'd like to add some thanks to Kris Easter, Michel Prunet and Stephen More.  This discussion area?  In brackets after the article link from [https://www.owasp.org/index.php/OWASP_Java_Project_Roadmap#Securing_Popular_J2EE_Servers Java Project Roadmap] ? [[User:Dledmonds|Darren]] 08:58, 27 October 2006 (EDT)&lt;/div&gt;</summary>
		<author><name>Dledmonds</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Securing_tomcat&amp;diff=12242</id>
		<title>Securing tomcat</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Securing_tomcat&amp;diff=12242"/>
				<updated>2006-11-10T17:32:00Z</updated>
		
		<summary type="html">&lt;p&gt;Dledmonds: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
Most weaknesses in [http://tomcat.apache.org/ Apache Tomcat] come from incorrect or inappropiate configuration.  It is nearly always possible to make Tomcat more secure than the default out of the box installation.  What follows documents best practices and recommendations on securing a production Tomcat server, whether it be hosted on a Windows or Unix based operating system.  ''Please note that the section ordering is not a representation of the section importance.''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Software Versions ==&lt;br /&gt;
&lt;br /&gt;
The first step is to make sure you are running the latest stable releases of software;&lt;br /&gt;
* Java Runtime Environment (JRE) or SDK&lt;br /&gt;
* Tomcat&lt;br /&gt;
* Third party libraries&lt;br /&gt;
This does not mean you have to upgrade all your production servers to a new (and potentially buggy) release which has just been made available to the public.  What you must do is download the latest stable bugfix release that has continual support.  For the JRE and Tomcat you should be looking at the last digits in the version number (5.5.'''X''') as it represents the bugfix information.  The bugs fixed in these releases are publicly available so if you don't upgrade you could be providing attackers with a very easy route to compromise your server.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Installation of Apache Tomcat 5.5 ==&lt;br /&gt;
&lt;br /&gt;
=== UNIX ===&lt;br /&gt;
&lt;br /&gt;
* Create a tomcat user/group&lt;br /&gt;
* Download and unpack the core distribution (referenced as '''CATALINA_HOME''' from now on)&lt;br /&gt;
* Change '''CATALINA_HOME''' ownership to tomcat user and tomcat group&lt;br /&gt;
* Change files in '''CATALINA_HOME'''/conf to be readonly (440)&lt;br /&gt;
* Make sure tomcat user has read/write access (660) to /tmp and write (220 - yes, only write) access to '''CATALINA_HOME'''/log&lt;br /&gt;
&lt;br /&gt;
=== Windows ===&lt;br /&gt;
&lt;br /&gt;
* Download the core windows service installer&lt;br /&gt;
* Start the installation, click ''Next'' and ''Agree'' to the licence&lt;br /&gt;
* Untick ''native'', ''documentation'', ''examples'' and ''webapps'' then click ''Next''&lt;br /&gt;
* Choose an installation directory (referenced as '''CATALINA_HOME''' from now on), preferably on a different drive to the OS.  &lt;br /&gt;
* Choose an administrator username (NOT admin) and a secure password that complies with your organisations password policy.&lt;br /&gt;
* Complete tomcat installation, but do not start service.&lt;br /&gt;
&lt;br /&gt;
=== Common ===&lt;br /&gt;
&lt;br /&gt;
* Remove everything from '''CATALINA_HOME'''/webapps (ROOT, balancer, jsp-examples, servlet-examples, tomcat-docs, webdav)&lt;br /&gt;
&lt;br /&gt;
* Remove everything from '''CATALINA_HOME'''/server/webapps (host-manager, manager).  Note that it can be useful to keep the manager webapp installed if you need the ability to redeploy without restarting Tomcat.  If you choose to keep it please read the section on Securing the Manager WebApp.&lt;br /&gt;
&lt;br /&gt;
* Remove '''CATALINA_HOME'''/conf/Catalina/localhost/host-manager.xml and '''CATALINA_HOME'''/conf/Catalina/localhost/manager.xml (again, if you are keeping the manager application, do not remove this).&lt;br /&gt;
&lt;br /&gt;
* Make sure the default servlet is configured '''not''' to serve index pages when a welcome file is not present.  In '''CATALINA_HOME'''/conf/web.xml&lt;br /&gt;
  &amp;lt;servlet&amp;gt;&lt;br /&gt;
    &amp;lt;servlet-name&amp;gt;default&amp;lt;/servlet-name&amp;gt;&lt;br /&gt;
    &amp;lt;servlet-class&amp;gt;org.apache.catalina.servlets.DefaultServlet&amp;lt;/servlet-class&amp;gt;&lt;br /&gt;
    &amp;lt;init-param&amp;gt;&lt;br /&gt;
      &amp;lt;param-name&amp;gt;debug&amp;lt;/param-name&amp;gt;&lt;br /&gt;
      &amp;lt;param-value&amp;gt;0&amp;lt;/param-value&amp;gt;&lt;br /&gt;
    &amp;lt;/init-param&amp;gt;&lt;br /&gt;
    &amp;lt;init-param&amp;gt;&lt;br /&gt;
      &amp;lt;param-name&amp;gt;listings&amp;lt;/param-name&amp;gt;&lt;br /&gt;
      &amp;lt;param-value&amp;gt;'''false'''&amp;lt;/param-value&amp;gt;  &amp;amp;lt;!-- make sure this is false --&amp;amp;gt;&lt;br /&gt;
    &amp;lt;/init-param&amp;gt;&lt;br /&gt;
    &amp;lt;load-on-startup&amp;gt;1&amp;lt;/load-on-startup&amp;gt;&lt;br /&gt;
  &amp;lt;/servlet&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Remove version string from HTTP error messages by repacking '''CATALINA_HOME'''/server/lib/catalina.jar with an updated ServerInfo.properties file.&lt;br /&gt;
:unpack catalina.jar&lt;br /&gt;
  cd CATALINA_HOME/server/lib&lt;br /&gt;
  jar xf catalina.jar org/apache/catalina/util/ServerInfo.properties&lt;br /&gt;
:update ServerInfo.properties by changing server.info line to server.info=Apache Tomcat&lt;br /&gt;
:repackage catalina.jar&lt;br /&gt;
  jar uf catalina.jar org/apache/catalina/util/ServerInfo.properties&lt;br /&gt;
:remove CATALINA_HOME/server/lib/org (created when extracting the ServerInfo.properties file)&lt;br /&gt;
&lt;br /&gt;
* Replace default error page (default is stacktrace) by adding the following into '''CATALINA_HOME'''/conf/web.xml.  The default error page shows a full stacktrace which is a disclosure of sensitive information.  ''The following solution is not ideal as it produces a blank page because Tomcat cannot find the file specified, but without a better solution this, at least, achieves the desired result.  A well configured web application will override this default in CATALINA_HOME/webapps/APP_NAME/WEB-INF/web.xml so it won't cause problems.''&lt;br /&gt;
  &amp;lt;error-page&amp;gt;&lt;br /&gt;
    &amp;lt;exception-type&amp;gt;java.lang.Exception&amp;lt;/exception-type&amp;gt;&lt;br /&gt;
    &amp;lt;location&amp;gt;/error.jsp&amp;lt;/location&amp;gt;&lt;br /&gt;
  &amp;lt;/error-page&amp;gt;&lt;br /&gt;
* Consider replacing '''CATALINA_HOME'''/conf/server.xml with '''CATALINA_HOME'''/conf/server-minimal.xml - ''work out what we lose''&lt;br /&gt;
&lt;br /&gt;
* Replace the server version string from HTTP headers in server responses, by adding the server keyword in your Connectors in '''CATALINA_HOME'''/conf/server.xml&lt;br /&gt;
  &amp;lt;Connector port=&amp;quot;8080&amp;quot; ...&lt;br /&gt;
             server=&amp;quot;Apache&amp;quot; /&amp;gt;  &amp;amp;lt;!-- server header is now Apache --&amp;amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Start Tomcat, deploy your applications into '''CATALINA_HOME'''/webapps and hope it works!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Protecting the Shutdown Port ==&lt;br /&gt;
Tomcat uses a port (defaults to 8005) as a shutdown port.  What this means is that to stop all webapps and stop tomcat cleanly the shutdown scripts make a connection to this port and send the ''shutdown'' command.  This is not as huge a security problem as it may sound considering the connection to the port must be made from the machine running tomcat and the ''shutdown'' command can be changed to something other than the string ''SHUTDOWN''.  However, it's wise to take the following precautions;&lt;br /&gt;
* if you are running a publicly accessible server make sure you prevent external access to the shutdown port by using a suitable firewall.&lt;br /&gt;
* change the shutdown command in '''CATALINA_HOME'''/conf/server.xml and make sure that file is only readable by the tomcat user.&lt;br /&gt;
  &amp;amp;lt;Server port=&amp;quot;8005&amp;quot; shutdown=&amp;quot;ReallyComplexWord&amp;quot;&amp;amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Securing Manager WebApp ==&lt;br /&gt;
&lt;br /&gt;
* By default there are no users with the manager role.  To make use of the manager webapp you need to add a new user into the '''CATALINA_HOME'''/conf/tomcat-users.xml file.&lt;br /&gt;
  &amp;lt;user username=&amp;quot;darren&amp;quot; password=&amp;quot;ReallyComplexPassword&amp;quot; roles=&amp;quot;manager&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Using a [http://tomcat.apache.org/tomcat-5.5-doc/config/valve.html valve] to filter by IP or hostname to only allow a subset of machines to connect (i.e. LAN machines).  Add one of the following within the Context tag in '''CATALINA_HOME'''/conf/Catalina/localhost/manager.xml&lt;br /&gt;
  &amp;amp;lt;!-- allow only LAN IPs to connect to the manager webapp --&amp;amp;gt;&lt;br /&gt;
  &amp;amp;lt;!-- contrary to the current Tomcat 5.5 documation the value for '''allow''' is not a regular expression --&amp;amp;gt;&lt;br /&gt;
  &amp;amp;lt;!-- future versions may have to be specified as 192\.168\.1\.* --&amp;amp;gt;&lt;br /&gt;
  &amp;lt;Valve className=&amp;quot;org.apache.catalina.valves.RemoteAddrValve&amp;quot;&lt;br /&gt;
         allow=&amp;quot;192.168.1.*&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  &amp;amp;lt;!-- allow only LAN hosts to connect to the manager webapp --&amp;amp;gt;&lt;br /&gt;
  &amp;amp;lt;!-- contrary to the current Tomcat 5.5 documation the value for '''allow''' is not a regular expression --&amp;amp;gt;&lt;br /&gt;
  &amp;amp;lt;!-- future versions may have to be specified as *\.localdomain\.com --&amp;amp;gt;&lt;br /&gt;
  &amp;lt;Valve className=&amp;quot;org.apache.catalina.valves.RemoteHostValve&amp;quot;&lt;br /&gt;
         allow=&amp;quot;*.localdomain.com&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* You can rename the manager webapp to something else, e.g. ''foobar''&lt;br /&gt;
** Move '''CATALINA_HOME'''/conf/Catalina/localhost/'''manager.xml''' to '''CATALINA_HOME'''/conf/Catalina/localhost/'''foobar.xml'''&lt;br /&gt;
** Update the '''docBase''' attribute within '''CATALINA_HOME'''/conf/Catalina/localhost/'''foobar.xml''' to ${catalina.home}/server/webapps/foobar&lt;br /&gt;
** Move '''CATALINA_HOME'''/server/webapps/'''manager''' to '''CATALINA_HOME'''/server/webapps/'''foobar'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Logging ==&lt;br /&gt;
&lt;br /&gt;
* TODO: Audit trails&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Encryption ==&lt;br /&gt;
&lt;br /&gt;
* SSL for password or other sensitive data exchange (''bordering on application security, not specific to tomcat'')&lt;br /&gt;
* SSL for connections (JDBC, LDAP, etc ..)&lt;br /&gt;
* The Tomcat documentation clearly explains how to [http://tomcat.apache.org/tomcat-5.5-doc/ssl-howto.html enable SSL.]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Java Security ==&lt;br /&gt;
&lt;br /&gt;
=== Running Tomcat with a Security Manager=== &lt;br /&gt;
The default Tomcat configuration provides good protection for most requirements, but does not prevent a malicious application from compromising the security of other applications running in the same instance.  To prevent this sort of attack, Tomcat can be run with a Security Manager enabled which strictly controls access to server resources.&lt;br /&gt;
Tomcat documentation has a good section on [http://tomcat.apache.org/tomcat-5.5-doc/security-manager-howto.html enabling the Security Manager.]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Miscellaneous ==&lt;br /&gt;
&lt;br /&gt;
* [http://tomcat.apache.org/faq/security.html Tomcat Security FAQ]&lt;br /&gt;
&lt;br /&gt;
=== Using Port 80 ===&lt;br /&gt;
&lt;br /&gt;
If you are on a Windows machine you will be able to change the port attribute of the connector within the ''Catalina'' service from 8080 to 80.  This allows you to use tomcat directly to serve all requests.  Depending on your requirements it may not be good enough to serve directly from Tomcat so you may like to consider;&lt;br /&gt;
* Use IIS / Apache running on port 80 and mod_jk to proxy requests to Tomcat&lt;br /&gt;
&lt;br /&gt;
On a UNIX machine only root is allowed to run services on ports below 1024 (kernel recompilation can overcome this).  It is a very bad idea to run Tomcat as root, so the options are;&lt;br /&gt;
* Use Apache running on port 80 and mod_jk (or mod_proxy_ajp) to proxy requests to Tomcat&lt;br /&gt;
* Run Tomcat as root, but in a chroot jail&lt;br /&gt;
* Use a tool like authbind to enable a non root user to bind to ports below 1024&lt;br /&gt;
* Use a port forwarder such as [http://www.netfilter.org/projects/iptables/index.html Iptables] to redirect incoming requests from 8080 to 80.  This has the disadvantage that internal redirects still need to use 8080.&lt;br /&gt;
* Run [http://www.squid-cache.org/ Squid] as a web accelerator in front of Tomcat&lt;br /&gt;
* Use JSVC/procrun&lt;br /&gt;
&lt;br /&gt;
=== Cleartext Passwords in CATALINA_HOME/conf/server.xml ===&lt;br /&gt;
&lt;br /&gt;
When configuring a resource, such as a JDBC pool, it is necessary to include clear text username and password in CATALINA_HOME/conf/server.xml  Best practices advice us never to store clear text passwords, but the following paragraphs highlight it is very difficult to avoid.&lt;br /&gt;
&lt;br /&gt;
If one way encryption was used on the password it must be possible for a database connection to be established using a username and encrypted password - so the encrypted password is just as valuable as the clear text one to an attacker.&lt;br /&gt;
&lt;br /&gt;
If two way encryption was used a keyfile is needed which must also live on the filesystem.  To make it more secure a passphase is added to the keyfile which then has to be stored in the configuration as clear text - no improvement.&lt;br /&gt;
&lt;br /&gt;
Encoding is security by obscurity and offers no form of protection (algorithms can be reverse engineered).  What encoding does do is make huge amounts of overhead work - you need to customise Tomcat and the commons digester it uses to parse the config files.  You'd also need a way to create encoded passwords.&lt;br /&gt;
&lt;br /&gt;
In the case of a JDBC pool what you can do is;&lt;br /&gt;
* make sure the database user only has access to the databases and tables they need (also limit rights as necessary).&lt;br /&gt;
* make sure the raw database files are only accessible to the user running the database services (e.g. mysql/postgresql user)&lt;br /&gt;
* make sure the Tomcat configuration files are only accessible to the tomcat user&lt;br /&gt;
&lt;br /&gt;
[[Category:OWASP Java Project]]&lt;br /&gt;
[[Category:Java]]&lt;/div&gt;</summary>
		<author><name>Dledmonds</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Securing_tomcat&amp;diff=12240</id>
		<title>Securing tomcat</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Securing_tomcat&amp;diff=12240"/>
				<updated>2006-11-10T16:05:00Z</updated>
		
		<summary type="html">&lt;p&gt;Dledmonds: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
Most weaknesses in [http://tomcat.apache.org/ Apache Tomcat] come from incorrect or inappropiate configuration.  It is nearly always possible to make Tomcat more secure than the default out of the box installation.  What follows documents best practices and recommendations on securing a production Tomcat server, whether it be hosted on a Windows or Unix based operating system.  ''Please note that the section ordering is not a representation of the section importance.''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Software Versions ==&lt;br /&gt;
&lt;br /&gt;
The first step is to make sure you are running the latest stable releases of software;&lt;br /&gt;
* Java Runtime Environment (JRE) or SDK&lt;br /&gt;
* Tomcat&lt;br /&gt;
* Third party libraries&lt;br /&gt;
This does not mean you have to upgrade all your production servers to a new (and potentially buggy) release which has just been made available to the public.  What you must do is download the latest stable bugfix release that has continual support.  For the JRE and Tomcat you should be looking at the last digits in the version number (5.5.'''X''') as it represents the bugfix information.  The bugs fixed in these releases are publicly available so if you don't upgrade you could be providing attackers with a very easy route to compromise your server.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Installation of Apache Tomcat 5.5 ==&lt;br /&gt;
&lt;br /&gt;
=== UNIX ===&lt;br /&gt;
&lt;br /&gt;
* Create a tomcat user/group&lt;br /&gt;
* Download and unpack the core distribution (referenced as '''CATALINA_HOME''' from now on)&lt;br /&gt;
* Change '''CATALINA_HOME''' ownership to tomcat user and tomcat group&lt;br /&gt;
* Change files in '''CATALINA_HOME'''/conf to be readonly&lt;br /&gt;
* Make sure tomcat user has read/write access to /tmp and write (yes, only write) access to '''CATALINA_HOME'''/log&lt;br /&gt;
&lt;br /&gt;
=== Windows ===&lt;br /&gt;
&lt;br /&gt;
* Download the core windows service installer&lt;br /&gt;
* Start the installation, click ''Next'' and ''Agree'' to the licence&lt;br /&gt;
* Untick ''native'', ''documentation'', ''examples'' and ''webapps'' then click ''Next''&lt;br /&gt;
* Choose an installation directory (referenced as '''CATALINA_HOME''' from now on), preferably on a different drive to the OS.  &lt;br /&gt;
* Choose an administrator username (NOT admin) and a secure password that complies with your organisations password policy.&lt;br /&gt;
* Complete tomcat installation, but do not start service.&lt;br /&gt;
&lt;br /&gt;
=== Common ===&lt;br /&gt;
&lt;br /&gt;
* Remove everything from '''CATALINA_HOME'''/webapps (ROOT, balancer, jsp-examples, servlet-examples, tomcat-docs, webdav)&lt;br /&gt;
&lt;br /&gt;
* Remove everything from '''CATALINA_HOME'''/server/webapps (host-manager, manager).  Note that it can be useful to keep the manager webapp installed if you need the ability to redeploy without restarting Tomcat.  If you choose to keep it please read the section on Securing the Manager WebApp.&lt;br /&gt;
&lt;br /&gt;
* Remove '''CATALINA_HOME'''/conf/Catalina/localhost/host-manager.xml and '''CATALINA_HOME'''/conf/Catalina/localhost/manager.xml (again, if you are keeping the manager application, do not remove this).&lt;br /&gt;
&lt;br /&gt;
* Make sure the default servlet is configured '''not''' to serve index pages when a welcome file is not present.  In '''CATALINA_HOME'''/conf/web.xml&lt;br /&gt;
  &amp;lt;servlet&amp;gt;&lt;br /&gt;
    &amp;lt;servlet-name&amp;gt;default&amp;lt;/servlet-name&amp;gt;&lt;br /&gt;
    &amp;lt;servlet-class&amp;gt;org.apache.catalina.servlets.DefaultServlet&amp;lt;/servlet-class&amp;gt;&lt;br /&gt;
    &amp;lt;init-param&amp;gt;&lt;br /&gt;
      &amp;lt;param-name&amp;gt;debug&amp;lt;/param-name&amp;gt;&lt;br /&gt;
      &amp;lt;param-value&amp;gt;0&amp;lt;/param-value&amp;gt;&lt;br /&gt;
    &amp;lt;/init-param&amp;gt;&lt;br /&gt;
    &amp;lt;init-param&amp;gt;&lt;br /&gt;
      &amp;lt;param-name&amp;gt;listings&amp;lt;/param-name&amp;gt;&lt;br /&gt;
      &amp;lt;param-value&amp;gt;'''false'''&amp;lt;/param-value&amp;gt;  &amp;amp;lt;!-- make sure this is false --&amp;amp;gt;&lt;br /&gt;
    &amp;lt;/init-param&amp;gt;&lt;br /&gt;
    &amp;lt;load-on-startup&amp;gt;1&amp;lt;/load-on-startup&amp;gt;&lt;br /&gt;
  &amp;lt;/servlet&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Remove version string from HTTP error messages by repacking '''CATALINA_HOME'''/server/lib/catalina.jar with an updated ServerInfo.properties file.&lt;br /&gt;
:unpack catalina.jar&lt;br /&gt;
  cd CATALINA_HOME/server/lib&lt;br /&gt;
  jar xf catalina.jar org/apache/catalina/util/ServerInfo.properties&lt;br /&gt;
:update ServerInfo.properties by changing server.info line to server.info=Apache Tomcat&lt;br /&gt;
:repackage catalina.jar&lt;br /&gt;
  jar uf catalina.jar org/apache/catalina/util/ServerInfo.properties&lt;br /&gt;
:remove CATALINA_HOME/server/lib/org (created when extracting the ServerInfo.properties file)&lt;br /&gt;
&lt;br /&gt;
* Replace default error page (default is stacktrace) by adding the following into '''CATALINA_HOME'''/conf/web.xml.  The default error page shows a full stacktrace which is a disclosure of sensitive information.  ''The following solution is not ideal as it produces a blank page because Tomcat cannot find the file specified, but without a better solution this, at least, achieves the desired result.  A well configured web application will override this default in CATALINA_HOME/webapps/APP_NAME/WEB-INF/web.xml so it won't cause problems.''&lt;br /&gt;
  &amp;lt;error-page&amp;gt;&lt;br /&gt;
    &amp;lt;exception-type&amp;gt;java.lang.Exception&amp;lt;/exception-type&amp;gt;&lt;br /&gt;
    &amp;lt;location&amp;gt;/error.jsp&amp;lt;/location&amp;gt;&lt;br /&gt;
  &amp;lt;/error-page&amp;gt;&lt;br /&gt;
* Consider replacing '''CATALINA_HOME'''/conf/server.xml with '''CATALINA_HOME'''/conf/server-minimal.xml - ''work out what we lose''&lt;br /&gt;
&lt;br /&gt;
* Replace the server version string from HTTP headers in server responses, by adding the server keyword in your Connectors in '''CATALINA_HOME'''/conf/server.xml&lt;br /&gt;
  &amp;lt;Connector port=&amp;quot;8080&amp;quot; ...&lt;br /&gt;
             server=&amp;quot;Apache&amp;quot; /&amp;gt;  &amp;amp;lt;!-- server header is now Apache --&amp;amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Start Tomcat, deploy your applications into '''CATALINA_HOME'''/webapps and hope it works!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Securing Manager WebApp ==&lt;br /&gt;
&lt;br /&gt;
* By default there are no users with the manager role.  To make use of the manager webapp you need to add a new user into the '''CATALINA_HOME'''/conf/tomcat-users.xml file.&lt;br /&gt;
  &amp;lt;user username=&amp;quot;darren&amp;quot; password=&amp;quot;ReallyComplexPassword&amp;quot; roles=&amp;quot;manager&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Using a [http://tomcat.apache.org/tomcat-5.5-doc/config/valve.html valve] to filter by IP or hostname to only allow a subset of machines to connect (i.e. LAN machines).  Add one of the following within the Context tag in '''CATALINA_HOME'''/conf/Catalina/localhost/manager.xml&lt;br /&gt;
  &amp;amp;lt;!-- allow only LAN IPs to connect to the manager webapp --&amp;amp;gt;&lt;br /&gt;
  &amp;amp;lt;!-- contrary to the current Tomcat 5.5 documation the value for '''allow''' is not a regular expression --&amp;amp;gt;&lt;br /&gt;
  &amp;amp;lt;!-- future versions may have to be specified as 192\.168\.1\.* --&amp;amp;gt;&lt;br /&gt;
  &amp;lt;Valve className=&amp;quot;org.apache.catalina.valves.RemoteAddrValve&amp;quot;&lt;br /&gt;
         allow=&amp;quot;192.168.1.*&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  &amp;amp;lt;!-- allow only LAN hosts to connect to the manager webapp --&amp;amp;gt;&lt;br /&gt;
  &amp;amp;lt;!-- contrary to the current Tomcat 5.5 documation the value for '''allow''' is not a regular expression --&amp;amp;gt;&lt;br /&gt;
  &amp;amp;lt;!-- future versions may have to be specified as *\.localdomain\.com --&amp;amp;gt;&lt;br /&gt;
  &amp;lt;Valve className=&amp;quot;org.apache.catalina.valves.RemoteHostValve&amp;quot;&lt;br /&gt;
         allow=&amp;quot;*.localdomain.com&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* You can rename the manager webapp to something else, e.g. ''foobar''&lt;br /&gt;
** Move '''CATALINA_HOME'''/conf/Catalina/localhost/'''manager.xml''' to '''CATALINA_HOME'''/conf/Catalina/localhost/'''foobar.xml'''&lt;br /&gt;
** Update the '''docBase''' attribute within '''CATALINA_HOME'''/conf/Catalina/localhost/'''foobar.xml''' to ${catalina.home}/server/webapps/foobar&lt;br /&gt;
** Move '''CATALINA_HOME'''/server/webapps/'''manager''' to '''CATALINA_HOME'''/server/webapps/'''foobar'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Logging ==&lt;br /&gt;
&lt;br /&gt;
* TODO: Audit trails&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Encryption ==&lt;br /&gt;
&lt;br /&gt;
* SSL for password or other sensitive data exchange (''bordering on application security, not specific to tomcat'')&lt;br /&gt;
* SSL for connections (JDBC, LDAP, etc ..)&lt;br /&gt;
* The Tomcat documentation clearly explains how to [http://tomcat.apache.org/tomcat-5.5-doc/ssl-howto.html enable SSL.]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Java Security ==&lt;br /&gt;
&lt;br /&gt;
=== Running Tomcat with a Security Manager=== &lt;br /&gt;
The default Tomcat configuration provides good protection for most requirements, but does not prevent a malicious application from compromising the security of other applications running in the same instance.  To prevent this sort of attack, Tomcat can be run with a Security Manager enabled which strictly controls access to server resources.&lt;br /&gt;
Tomcat documentation has a good section on [http://tomcat.apache.org/tomcat-5.5-doc/security-manager-howto.html enabling the Security Manager.]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Miscellaneous ==&lt;br /&gt;
&lt;br /&gt;
* [http://tomcat.apache.org/faq/security.html Tomcat Security FAQ]&lt;br /&gt;
&lt;br /&gt;
=== Using Port 80 ===&lt;br /&gt;
&lt;br /&gt;
If you are on a Windows machine you will be able to change the port attribute of the connector within the ''Catalina'' service from 8080 to 80.  This allows you to use tomcat directly to serve all requests.  Depending on your requirements it may not be good enough to serve directly from Tomcat so you may like to consider;&lt;br /&gt;
* Use IIS / Apache running on port 80 and mod_jk to proxy requests to Tomcat&lt;br /&gt;
&lt;br /&gt;
On a UNIX machine only root is allowed to run services on ports below 1024 (kernel recompilation can overcome this).  It is a very bad idea to run Tomcat as root, so the options are;&lt;br /&gt;
* Use Apache running on port 80 and mod_jk (or mod_proxy_ajp) to proxy requests to Tomcat&lt;br /&gt;
* Run Tomcat as root, but in a chroot jail&lt;br /&gt;
* Use a tool like authbind to enable a non root user to bind to ports below 1024&lt;br /&gt;
* Use a port forwarder such as [http://www.netfilter.org/projects/iptables/index.html Iptables] to redirect incoming requests from 8080 to 80.  This has the disadvantage that internal redirects still need to use 8080.&lt;br /&gt;
* Run [http://www.squid-cache.org/ Squid] as a web accelerator in front of Tomcat&lt;br /&gt;
* Use JSVC/procrun&lt;br /&gt;
&lt;br /&gt;
=== Cleartext Passwords in CATALINA_HOME/conf/server.xml ===&lt;br /&gt;
&lt;br /&gt;
When configuring a resource, such as a JDBC pool, it is necessary to include clear text username and password in CATALINA_HOME/conf/server.xml  Best practices advice us never to store clear text passwords, but the following paragraphs highlight it is very difficult to avoid.&lt;br /&gt;
&lt;br /&gt;
If one way encryption was used on the password it must be possible for a database connection to be established using a username and encrypted password - so the encrypted password is just as valuable as the clear text one to an attacker.&lt;br /&gt;
&lt;br /&gt;
If two way encryption was used a keyfile is needed which must also live on the filesystem.  To make it more secure a passphase is added to the keyfile which then has to be stored in the configuration as clear text - no improvement.&lt;br /&gt;
&lt;br /&gt;
Encoding is security by obscurity and offers no form of protection (algorithms can be reverse engineered).  What encoding does do is make huge amounts of overhead work - you need to customise Tomcat and the commons digester it uses to parse the config files.  You'd also need a way to create encoded passwords.&lt;br /&gt;
&lt;br /&gt;
In the case of a JDBC pool what you can do is;&lt;br /&gt;
* make sure the database user only has access to the databases and tables they need (also limit rights as necessary).&lt;br /&gt;
* make sure the raw database files are only accessible to the user running the database services (e.g. mysql/postgresql user)&lt;br /&gt;
* make sure the Tomcat configuration files are only accessible to the tomcat user&lt;br /&gt;
&lt;br /&gt;
[[Category:OWASP Java Project]]&lt;br /&gt;
[[Category:Java]]&lt;/div&gt;</summary>
		<author><name>Dledmonds</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Securing_tomcat&amp;diff=12239</id>
		<title>Securing tomcat</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Securing_tomcat&amp;diff=12239"/>
				<updated>2006-11-10T15:44:38Z</updated>
		
		<summary type="html">&lt;p&gt;Dledmonds: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
Most weaknesses in [http://tomcat.apache.org/ Apache Tomcat] come from incorrect or inappropiate configuration.  It is nearly always possible to make Tomcat more secure than the default out of the box installation.  What follows documents best practices and recommendations on securing a production Tomcat server, whether it be hosted on a Windows or Unix based operating system.  ''Please note that the section ordering is not a representation of the section importance.''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Software Versions ==&lt;br /&gt;
&lt;br /&gt;
The first step is to make sure you are running the latest stable releases of software;&lt;br /&gt;
* Java Runtime Environment (JRE) or SDK&lt;br /&gt;
* Tomcat&lt;br /&gt;
* Third party libraries&lt;br /&gt;
This does not mean you have to upgrade all your production servers to a new (and potentially buggy) release which has just been made available to the public.  What you must do is download the latest stable bugfix release that has continual support.  For the JRE and Tomcat you should be looking at the last digits in the version number (5.5.'''X''') as it represents the bugfix information.  The bugs fixed in these releases are publicly available so if you don't upgrade you could be providing attackers with a very easy route to compromise your server.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Installation of Apache Tomcat 5.5 ==&lt;br /&gt;
&lt;br /&gt;
=== UNIX ===&lt;br /&gt;
&lt;br /&gt;
* Create a tomcat user/group&lt;br /&gt;
* Download and unpack the core distribution (referenced as '''CATALINA_HOME''' from now on)&lt;br /&gt;
* Change '''CATALINA_HOME''' ownership to tomcat user and tomcat group&lt;br /&gt;
* Change files in '''CATALINA_HOME'''/conf to be readonly&lt;br /&gt;
* Make sure tomcat user has read/write access to /tmp and write (yes, only write) access to '''CATALINA_HOME'''/log&lt;br /&gt;
&lt;br /&gt;
=== Windows ===&lt;br /&gt;
&lt;br /&gt;
* Download the core windows service installer&lt;br /&gt;
* Start the installation, click ''Next'' and ''Agree'' to the licence&lt;br /&gt;
* Untick ''native'', ''documentation'', ''examples'' and ''webapps'' then click ''Next''&lt;br /&gt;
* Choose an installation directory (referenced as '''CATALINA_HOME''' from now on), preferably on a different drive to the OS.  &lt;br /&gt;
* Choose an administrator username (NOT admin) and a secure password that complies with your organisations password policy.&lt;br /&gt;
* Complete tomcat installation, but do not start service.&lt;br /&gt;
&lt;br /&gt;
=== Common ===&lt;br /&gt;
&lt;br /&gt;
* Remove everything from '''CATALINA_HOME'''/webapps (ROOT, balancer, jsp-examples, servlet-examples, tomcat-docs, webdav)&lt;br /&gt;
* Remove everything from '''CATALINA_HOME'''/server/webapps (host-manager, manager).  Note that it can be useful to keep the manager webapp installed if you need the ability to redeploy without restarting Tomcat.  If you choose to keep it please read the section on Securing the Manager WebApp.&lt;br /&gt;
* Remove '''CATALINA_HOME'''/conf/Catalina/localhost/host-manager.xml and '''CATALINA_HOME'''/conf/Catalina/localhost/manager.xml (again, if you are keeping the manager application, do not remove this).&lt;br /&gt;
* Make sure the default servlet is configured '''not''' to serve index pages when a welcome file is not present.  In '''CATALINA_HOME'''/conf/web.xml&lt;br /&gt;
  &amp;lt;servlet&amp;gt;&lt;br /&gt;
    &amp;lt;servlet-name&amp;gt;default&amp;lt;/servlet-name&amp;gt;&lt;br /&gt;
    &amp;lt;servlet-class&amp;gt;org.apache.catalina.servlets.DefaultServlet&amp;lt;/servlet-class&amp;gt;&lt;br /&gt;
    &amp;lt;init-param&amp;gt;&lt;br /&gt;
      &amp;lt;param-name&amp;gt;debug&amp;lt;/param-name&amp;gt;&lt;br /&gt;
      &amp;lt;param-value&amp;gt;0&amp;lt;/param-value&amp;gt;&lt;br /&gt;
    &amp;lt;/init-param&amp;gt;&lt;br /&gt;
    &amp;lt;init-param&amp;gt;&lt;br /&gt;
      &amp;lt;param-name&amp;gt;listings&amp;lt;/param-name&amp;gt;&lt;br /&gt;
      &amp;lt;param-value&amp;gt;'''false'''&amp;lt;/param-value&amp;gt;  &amp;amp;lt;!-- make sure this is false --&amp;amp;gt;&lt;br /&gt;
    &amp;lt;/init-param&amp;gt;&lt;br /&gt;
    &amp;lt;load-on-startup&amp;gt;1&amp;lt;/load-on-startup&amp;gt;&lt;br /&gt;
  &amp;lt;/servlet&amp;gt;&lt;br /&gt;
* Remove version string from HTTP error messages by repacking '''CATALINA_HOME'''/server/lib/catalina.jar with an updated ServerInfo.properties file.&lt;br /&gt;
** unpack catalina.jar&lt;br /&gt;
  cd CATALINA_HOME/server/lib&lt;br /&gt;
  jar xf catalina.jar org/apache/catalina/util/ServerInfo.properties&lt;br /&gt;
** update ServerInfo.properties by changing server.info line to server.info=Apache Tomcat&lt;br /&gt;
** repackage catalina.jar&lt;br /&gt;
  jar uf catalina.jar org/apache/catalina/util/ServerInfo.properties&lt;br /&gt;
** remove CATALINA_HOME/server/lib/org (created when extracting the ServerInfo.properties file)&lt;br /&gt;
* Replace default error page (default is stacktrace) by adding the following into '''CATALINA_HOME'''/conf/web.xml.  The default error page shows a full stacktrace which is a disclosure of sensitive information.  ''The following solution is not ideal as it produces a blank page because Tomcat cannot find the file specified, but without a better solution this, at least, achieves the desired result.  A well configured web application will override this default in CATALINA_HOME/webapps/APP_NAME/WEB-INF/web.xml so it won't cause problems.''&lt;br /&gt;
  &amp;lt;error-page&amp;gt;&lt;br /&gt;
    &amp;lt;exception-type&amp;gt;java.lang.Exception&amp;lt;/exception-type&amp;gt;&lt;br /&gt;
    &amp;lt;location&amp;gt;/error.jsp&amp;lt;/location&amp;gt;&lt;br /&gt;
  &amp;lt;/error-page&amp;gt;&lt;br /&gt;
* Consider replacing '''CATALINA_HOME'''/conf/server.xml with '''CATALINA_HOME'''/conf/server-minimal.xml - ''work out what we lose''&lt;br /&gt;
* Replace the server version string from HTTP headers in server responses, by adding the server keyword in your Connectors in '''CATALINA_HOME'''/conf/server.xml&lt;br /&gt;
  &amp;lt;Connector port=&amp;quot;8080&amp;quot; ...&lt;br /&gt;
             server=&amp;quot;Apache&amp;quot; /&amp;gt;  &amp;amp;lt;!-- server header is now Apache --&amp;amp;gt;&lt;br /&gt;
* Start Tomcat, deploy your applications into '''CATALINA_HOME'''/webapps and hope it works!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Securing Manager WebApp ==&lt;br /&gt;
&lt;br /&gt;
* By default there are no users with the manager role.  To make use of the manager webapp you need to add a new user into the '''CATALINA_HOME'''/conf/tomcat-users.xml file.&lt;br /&gt;
  &amp;lt;user username=&amp;quot;darren&amp;quot; password=&amp;quot;ReallyComplexPassword&amp;quot; roles=&amp;quot;manager&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Using a [http://tomcat.apache.org/tomcat-5.5-doc/config/valve.html valve] to filter by IP or hostname to only allow a subset of machines to connect (i.e. LAN machines).  Add one of the following within the Context tag in '''CATALINA_HOME'''/conf/Catalina/localhost/manager.xml&lt;br /&gt;
  &amp;amp;lt;!-- allow only LAN IPs to connect to the manager webapp --&amp;amp;gt;&lt;br /&gt;
  &amp;amp;lt;!-- contrary to the current Tomcat 5.5 documation the value for '''allow''' is not a regular expression --&amp;amp;gt;&lt;br /&gt;
  &amp;amp;lt;!-- future versions may have to be specified as 192\.168\.1\.* --&amp;amp;gt;&lt;br /&gt;
  &amp;lt;Valve className=&amp;quot;org.apache.catalina.valves.RemoteAddrValve&amp;quot;&lt;br /&gt;
         allow=&amp;quot;192.168.1.*&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  &amp;amp;lt;!-- allow only LAN hosts to connect to the manager webapp --&amp;amp;gt;&lt;br /&gt;
  &amp;amp;lt;!-- contrary to the current Tomcat 5.5 documation the value for '''allow''' is not a regular expression --&amp;amp;gt;&lt;br /&gt;
  &amp;amp;lt;!-- future versions may have to be specified as *\.localdomain\.com --&amp;amp;gt;&lt;br /&gt;
  &amp;lt;Valve className=&amp;quot;org.apache.catalina.valves.RemoteHostValve&amp;quot;&lt;br /&gt;
         allow=&amp;quot;*.localdomain.com&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* You can rename the manager webapp to something else, e.g. ''foobar''&lt;br /&gt;
** Move '''CATALINA_HOME'''/conf/Catalina/localhost/'''manager.xml''' to '''CATALINA_HOME'''/conf/Catalina/localhost/'''foobar.xml'''&lt;br /&gt;
** Update the '''docBase''' attribute within '''CATALINA_HOME'''/conf/Catalina/localhost/'''foobar.xml''' to ${catalina.home}/server/webapps/foobar&lt;br /&gt;
** Move '''CATALINA_HOME'''/server/webapps/'''manager''' to '''CATALINA_HOME'''/server/webapps/'''foobar'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Logging ==&lt;br /&gt;
&lt;br /&gt;
* TODO: Audit trails&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Encryption ==&lt;br /&gt;
&lt;br /&gt;
* SSL for password or other sensitive data exchange (''bordering on application security, not specific to tomcat'')&lt;br /&gt;
* SSL for connections (JDBC, LDAP, etc ..)&lt;br /&gt;
* The Tomcat documentation clearly explains how to [http://tomcat.apache.org/tomcat-5.5-doc/ssl-howto.html enable SSL.]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Java Security ==&lt;br /&gt;
&lt;br /&gt;
=== Running Tomcat with a Security Manager=== &lt;br /&gt;
The default Tomcat configuration provides good protection for most requirements, but does not prevent a malicious application from compromising the security of other applications running in the same instance.  To prevent this sort of attack, Tomcat can be run with a Security Manager enabled which strictly controls access to server resources.&lt;br /&gt;
Tomcat documentation has a good section on [http://tomcat.apache.org/tomcat-5.5-doc/security-manager-howto.html enabling the Security Manager.]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Miscellaneous ==&lt;br /&gt;
&lt;br /&gt;
* [http://tomcat.apache.org/faq/security.html Tomcat Security FAQ]&lt;br /&gt;
&lt;br /&gt;
=== Using Port 80 ===&lt;br /&gt;
&lt;br /&gt;
If you are on a Windows machine you will be able to change the port attribute of the connector within the ''Catalina'' service from 8080 to 80.  This allows you to use tomcat directly to serve all requests.  Depending on your requirements it may not be good enough to serve directly from Tomcat so you may like to consider;&lt;br /&gt;
* Use IIS / Apache running on port 80 and mod_jk to proxy requests to Tomcat&lt;br /&gt;
&lt;br /&gt;
On a UNIX machine only root is allowed to run services on ports below 1024 (kernel recompilation can overcome this).  It is a very bad idea to run Tomcat as root, so the options are;&lt;br /&gt;
* Use Apache running on port 80 and mod_jk (or mod_proxy_ajp) to proxy requests to Tomcat&lt;br /&gt;
* Run Tomcat as root, but in a chroot jail&lt;br /&gt;
* Use a tool like authbind to enable a non root user to bind to ports below 1024&lt;br /&gt;
* Use a port forwarder such as [http://www.netfilter.org/projects/iptables/index.html Iptables] to redirect incoming requests from 8080 to 80.  This has the disadvantage that internal redirects still need to use 8080.&lt;br /&gt;
* Run [http://www.squid-cache.org/ Squid] as a web accelerator in front of Tomcat&lt;br /&gt;
* Use JSVC/procrun&lt;br /&gt;
&lt;br /&gt;
=== Cleartext Passwords in CATALINA_HOME/conf/server.xml ===&lt;br /&gt;
&lt;br /&gt;
When configuring a resource, such as a JDBC pool, it is necessary to include clear text username and password in CATALINA_HOME/conf/server.xml  Best practices advice us never to store clear text passwords, but the following paragraphs highlight it is very difficult to avoid.&lt;br /&gt;
&lt;br /&gt;
If one way encryption was used on the password it must be possible for a database connection to be established using a username and encrypted password - so the encrypted password is just as valuable as the clear text one to an attacker.&lt;br /&gt;
&lt;br /&gt;
If two way encryption was used a keyfile is needed which must also live on the filesystem.  To make it more secure a passphase is added to the keyfile which then has to be stored in the configuration as clear text - no improvement.&lt;br /&gt;
&lt;br /&gt;
Encoding is security by obscurity and offers no form of protection (algorithms can be reverse engineered).  What encoding does do is make huge amounts of overhead work - you need to customise Tomcat and the commons digester it uses to parse the config files.  You'd also need a way to create encoded passwords.&lt;br /&gt;
&lt;br /&gt;
In the case of a JDBC pool what you can do is;&lt;br /&gt;
* make sure the database user only has access to the databases and tables they need (also limit rights as necessary).&lt;br /&gt;
* make sure the raw database files are only accessible to the user running the database services (e.g. mysql/postgresql user)&lt;br /&gt;
* make sure the Tomcat configuration files are only accessible to the tomcat user&lt;br /&gt;
&lt;br /&gt;
[[Category:OWASP Java Project]]&lt;br /&gt;
[[Category:Java]]&lt;/div&gt;</summary>
		<author><name>Dledmonds</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Talk:Securing_tomcat&amp;diff=11170</id>
		<title>Talk:Securing tomcat</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Talk:Securing_tomcat&amp;diff=11170"/>
				<updated>2006-10-27T12:58:50Z</updated>
		
		<summary type="html">&lt;p&gt;Dledmonds: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Network Security ==&lt;br /&gt;
&lt;br /&gt;
Generic advice common to all server security (link).&lt;br /&gt;
&lt;br /&gt;
:Not sure what information should go here? [[User:Stephendv|Stephendv]] 04:21, 16 October 2006 (EDT)&lt;br /&gt;
::I was thinking of a firewall discussion in relation to protecting the server.  Perhaps this should be changed to only mention the shutdown port needs protecting in tomcat [[User:dledmonds|dledmonds]]&lt;br /&gt;
:::Ah, gotcha!  Yeah that would definitely be something worthwhile adding. [[User:Stephendv|Stephendv]] 06:53, 23 October 2006 (EDT)&lt;br /&gt;
::::Never actually used the shutdown port, so will investigate it's usefulness and document disabling and protecting [[User:Dledmonds|Darren]] 08:58, 27 October 2006 (EDT)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
What's the best way to acknowledge the contributions of others as I'd like to add some thanks to Kris Easter, Michel Prunet and Stephen More.  This discussion area?  In brackets after the article link from [https://www.owasp.org/index.php/OWASP_Java_Project_Roadmap#Securing_Popular_J2EE_Servers Java Project Roadmap] ? [[User:Dledmonds|Darren]] 08:58, 27 October 2006 (EDT)&lt;/div&gt;</summary>
		<author><name>Dledmonds</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Securing_tomcat&amp;diff=11166</id>
		<title>Securing tomcat</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Securing_tomcat&amp;diff=11166"/>
				<updated>2006-10-27T12:42:44Z</updated>
		
		<summary type="html">&lt;p&gt;Dledmonds: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
Most weaknesses in [http://tomcat.apache.org/ Apache Tomcat] come from incorrect or inappropiate configuration.  It is nearly always possible to make Tomcat more secure than the default out of the box installation.  What follows documents best practices and recommendations on securing a production Tomcat server, whether it be hosted on a Windows or Unix based operating system.  ''Please note that the section ordering is not a representation of the section importance.''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Software Versions ==&lt;br /&gt;
&lt;br /&gt;
The first step is to make sure you are running the latest stable releases of software;&lt;br /&gt;
* Java Runtime Environment (JRE) or SDK&lt;br /&gt;
* Tomcat&lt;br /&gt;
* Third party libraries&lt;br /&gt;
This does not mean you have to upgrade all your production servers to a new (and potentially buggy) release which has just been made available to the public.  What you must do is download the latest stable bugfix release that has continual support.  For the JRE and Tomcat you should be looking at the last digits in the version number (5.5.'''X''') as it represents the bugfix information.  The bugs fixed in these releases are publicly available so if you don't upgrade you could be providing attackers with a very easy route to compromise your server.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Installation of Apache Tomcat 5.5 ==&lt;br /&gt;
&lt;br /&gt;
=== UNIX ===&lt;br /&gt;
&lt;br /&gt;
* Create a tomcat user/group&lt;br /&gt;
* Download and unpack the core distribution (referenced as '''CATALINA_HOME''' from now on)&lt;br /&gt;
* Change '''CATALINA_HOME''' ownership to tomcat user and tomcat group&lt;br /&gt;
* Change files in '''CATALINA_HOME'''/conf to be readonly&lt;br /&gt;
* Make sure tomcat user has read/write access to /tmp and write (yes, only write) access to '''CATALINA_HOME'''/log&lt;br /&gt;
&lt;br /&gt;
=== Windows ===&lt;br /&gt;
&lt;br /&gt;
* Download the core windows service installer&lt;br /&gt;
* Start the installation, click ''Next'' and ''Agree'' to the licence&lt;br /&gt;
* Untick ''native'', ''documentation'', ''examples'' and ''webapps'' then click ''Next''&lt;br /&gt;
* Choose an installation directory (referenced as '''CATALINA_HOME''' from now on), preferably on a different drive to the OS.  &lt;br /&gt;
* Choose an administrator username (NOT admin) and a secure password that complies with your organisations password policy.&lt;br /&gt;
* Complete tomcat installation, but do not start service.&lt;br /&gt;
* TODO: ''filesystem security''&lt;br /&gt;
&lt;br /&gt;
=== Common ===&lt;br /&gt;
&lt;br /&gt;
* Remove everything from '''CATALINA_HOME'''/webapps (ROOT, balancer, jsp-examples, servlet-examples, tomcat-docs, webdav)&lt;br /&gt;
* Remove everything from '''CATALINA_HOME'''/server/webapps (host-manager, manager).  Note that it can be useful to keep the manager webapp installed if you need the ability to redeploy without restarting Tomcat.  If you choose to keep it please read the section on Securing the Manager WebApp.&lt;br /&gt;
* Remove '''CATALINA_HOME'''/conf/Catalina/localhost/host-manager.xml and '''CATALINA_HOME'''/conf/Catalina/localhost/manager.xml (again, if you are keeping the manager application, do not remove this).&lt;br /&gt;
* Make sure the default servlet is configured '''not''' to serve index pages when a welcome file is not present.  In '''CATALINA_HOME'''/conf/web.xml&lt;br /&gt;
  &amp;lt;servlet&amp;gt;&lt;br /&gt;
    &amp;lt;servlet-name&amp;gt;default&amp;lt;/servlet-name&amp;gt;&lt;br /&gt;
    &amp;lt;servlet-class&amp;gt;org.apache.catalina.servlets.DefaultServlet&amp;lt;/servlet-class&amp;gt;&lt;br /&gt;
    &amp;lt;init-param&amp;gt;&lt;br /&gt;
      &amp;lt;param-name&amp;gt;debug&amp;lt;/param-name&amp;gt;&lt;br /&gt;
      &amp;lt;param-value&amp;gt;0&amp;lt;/param-value&amp;gt;&lt;br /&gt;
    &amp;lt;/init-param&amp;gt;&lt;br /&gt;
    &amp;lt;init-param&amp;gt;&lt;br /&gt;
      &amp;lt;param-name&amp;gt;listings&amp;lt;/param-name&amp;gt;&lt;br /&gt;
      &amp;lt;param-value&amp;gt;'''false'''&amp;lt;/param-value&amp;gt;  &amp;amp;lt;!-- make sure this is false --&amp;amp;gt;&lt;br /&gt;
    &amp;lt;/init-param&amp;gt;&lt;br /&gt;
    &amp;lt;load-on-startup&amp;gt;1&amp;lt;/load-on-startup&amp;gt;&lt;br /&gt;
  &amp;lt;/servlet&amp;gt;&lt;br /&gt;
* Remove version string from HTTP error messages by repacking '''CATALINA_HOME'''/server/lib/catalina.jar with an updated ServerInfo.properties file.&lt;br /&gt;
  cd CATALINA_HOME/server/lib&lt;br /&gt;
  jar xf catalina.jar org/apache/catalina/util/ServerInfo.properties&lt;br /&gt;
  ... update ServerInfo.properties by changing server.info line to server.info=Apache Tomcat&lt;br /&gt;
  jar uf catalina.jar org/apache/catalina/util/ServerInfo.properties&lt;br /&gt;
  ... remove CATALINA_HOME/server/lib/org (created when extracting the ServerInfo.properties file)&lt;br /&gt;
* Replace default error page (default is stacktrace) by adding the following into '''CATALINA_HOME'''/conf/web.xml.  The default error page shows a full stacktrace which is a disclosure of sensitive information.  ''The following solution is not ideal as it produces a blank page because Tomcat cannot find the file specified, but without a better solution this, at least, achieves the desired result.  A well configured web application will override this default in CATALINA_HOME/webapps/APP_NAME/WEB-INF/web.xml so it won't cause problems.''&lt;br /&gt;
  &amp;lt;error-page&amp;gt;&lt;br /&gt;
    &amp;lt;exception-type&amp;gt;java.lang.Exception&amp;lt;/exception-type&amp;gt;&lt;br /&gt;
    &amp;lt;location&amp;gt;/error.jsp&amp;lt;/location&amp;gt;&lt;br /&gt;
  &amp;lt;/error-page&amp;gt;&lt;br /&gt;
* Consider replacing '''CATALINA_HOME'''/conf/server.xml with '''CATALINA_HOME'''/conf/server-minimal.xml - ''work out what we lose''&lt;br /&gt;
* Replace the server version string from HTTP headers in server responses, by adding the server keyword in your Connectors in '''CATALINA_HOME'''/conf/server.xml&lt;br /&gt;
  &amp;lt;Connector port=&amp;quot;8080&amp;quot; ...&lt;br /&gt;
             server=&amp;quot;Apache&amp;quot; /&amp;gt;  &amp;amp;lt;!-- server header is now Apache --&amp;amp;gt;&lt;br /&gt;
* Start Tomcat, deploy your applications into '''CATALINA_HOME'''/webapps and hope it works!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Securing Manager WebApp ==&lt;br /&gt;
&lt;br /&gt;
* By default there are no users with the manager role.  To make use of the manager webapp you need to add a new user into the '''CATALINA_HOME'''/conf/tomcat-users.xml file.&lt;br /&gt;
  &amp;lt;user username=&amp;quot;darren&amp;quot; password=&amp;quot;ReallyComplexPassword&amp;quot; roles=&amp;quot;manager&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Using a [http://tomcat.apache.org/tomcat-5.5-doc/config/valve.html valve] to filter by IP or hostname to only allow a subset of machines to connect (i.e. LAN machines).  Add one of the following within the Context tag in '''CATALINA_HOME'''/conf/Catalina/localhost/manager.xml&lt;br /&gt;
  &amp;amp;lt;!-- allow only LAN IPs to connect to the manager webapp --&amp;amp;gt;&lt;br /&gt;
  &amp;amp;lt;!-- contrary to the current Tomcat 5.5 documation the value for '''allow''' is not a regular expression --&amp;amp;gt;&lt;br /&gt;
  &amp;amp;lt;!-- future versions may have to be specificed as 192\.168\.1\.* --&amp;amp;gt;&lt;br /&gt;
  &amp;lt;Valve className=&amp;quot;org.apache.catalina.valves.RemoteAddrValve&amp;quot;&lt;br /&gt;
         allow=&amp;quot;192.168.1.*&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  &amp;amp;lt;!-- allow only LAN hosts to connect to the manager webapp --&amp;amp;gt;&lt;br /&gt;
  &amp;amp;lt;!-- contrary to the current Tomcat 5.5 documation the value for '''allow''' is not a regular expression --&amp;amp;gt;&lt;br /&gt;
  &amp;amp;lt;!-- future versions may have to be specificed as *\.localdomain\.com --&amp;amp;gt;&lt;br /&gt;
  &amp;lt;Valve className=&amp;quot;org.apache.catalina.valves.RemoteHostValve&amp;quot;&lt;br /&gt;
         allow=&amp;quot;*.localdomain.com&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* You can rename the manager webapp to something else, e.g. ''foobar''&lt;br /&gt;
** Move '''CATALINA_HOME'''/conf/Catalina/localhost/'''manager.xml''' to '''CATALINA_HOME'''/conf/Catalina/localhost/'''foobar.xml'''&lt;br /&gt;
** Update the '''docBase''' attribute within '''CATALINA_HOME'''/conf/Catalina/localhost/'''foobar.xml''' to ${catalina.home}/server/webapps/foobar&lt;br /&gt;
** Move '''CATALINA_HOME'''/server/webapps/'''manager''' to '''CATALINA_HOME'''/server/webapps/'''foobar'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Logging ==&lt;br /&gt;
&lt;br /&gt;
* TODO: Audit trails&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Encryption ==&lt;br /&gt;
&lt;br /&gt;
* SSL for password or other sensitive data exchange (''bordering on application security, not specific to tomcat'')&lt;br /&gt;
* SSL for connections (JDBC, LDAP, etc ..)&lt;br /&gt;
* The Tomcat documentation clearly explains how to [http://tomcat.apache.org/tomcat-5.5-doc/ssl-howto.html enable SSL.]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Java Security ==&lt;br /&gt;
&lt;br /&gt;
=== Running Tomcat with a Security Manager=== &lt;br /&gt;
The default Tomcat configuration provides good protection for most requirements, but does not prevent a malicious application from compromising the security of other applications running in the same instance.  To prevent this sort of attack, Tomcat can be run with a Security Manager enabled which strictly controls access to server resources.&lt;br /&gt;
Tomcat documentation has a good section on [http://tomcat.apache.org/tomcat-5.5-doc/security-manager-howto.html enabling the Security Manager.]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Miscellaneous ==&lt;br /&gt;
&lt;br /&gt;
* [http://tomcat.apache.org/faq/security.html Tomcat Security FAQ]&lt;br /&gt;
&lt;br /&gt;
=== Using Port 80 ===&lt;br /&gt;
&lt;br /&gt;
If you are on a Windows machine you will be able to change the port attribute of the connector within the ''Catalina'' service from 8080 to 80.  This allows you to use tomcat directly to serve all requests.  Depending on your requirements it may not be good enough to serve directly from Tomcat so you may like to consider;&lt;br /&gt;
* Use IIS / Apache running on port 80 and mod_jk to proxy requests to Tomcat&lt;br /&gt;
&lt;br /&gt;
On a UNIX machine only root is allowed to run services on ports below 1024 (kernel recompilation can overcome this).  It is a very bad idea to run Tomcat as root, so the options are;&lt;br /&gt;
* Use Apache running on port 80 and mod_jk (or mod_proxy_ajp) to proxy requests to Tomcat&lt;br /&gt;
* Run Tomcat as root, but in a chroot jail&lt;br /&gt;
* Use a tool like authbind to enable a non root user to bind to ports below 1024&lt;br /&gt;
* Use a port forwarder such as [http://www.netfilter.org/projects/iptables/index.html Iptables] to redirect incoming requests from 8080 to 80.  This has the disadvantage that internal redirects still need to use 8080.&lt;br /&gt;
* Run [http://www.squid-cache.org/ Squid] as a web accelerator in front of Tomcat&lt;br /&gt;
* Use JSVC/procrun&lt;br /&gt;
&lt;br /&gt;
=== Cleartext Passwords in CATALINA_HOME/conf/server.xml ===&lt;br /&gt;
&lt;br /&gt;
When configuring a resource, such as a JDBC pool, it is necessary to include clear text username and password in CATALINA_HOME/conf/server.xml  Best practices advice us never to store clear text passwords, but the following paragraphs highlight it is very difficult to avoid.&lt;br /&gt;
&lt;br /&gt;
If one way encryption was used on the password it must be possible for a database connection to be established using a username and encrypted password - so the encrypted password is just as valuable as the clear text one to an attacker.&lt;br /&gt;
&lt;br /&gt;
If two way encryption was used a keyfile is needed which must also live on the filesystem.  To make it more secure a passphase is added to the keyfile which then has to be stored in the configuration as clear text - no improvement.&lt;br /&gt;
&lt;br /&gt;
Encoding is security by obscurity and offers no form of protection (algorithms can be reverse engineered).  What encoding does do is make huge amounts of overhead work - you need to customise Tomcat and the commons digester it uses to parse the config files.  You'd also need a way to create encoded passwords.&lt;br /&gt;
&lt;br /&gt;
In the case of a JDBC pool what you can do is;&lt;br /&gt;
* make sure the database user only has access to the databases and tables they need (also limit rights as necessary).&lt;br /&gt;
* make sure the raw database files are only accessible to the user running the database services (e.g. mysql/postgresql user)&lt;br /&gt;
* make sure the Tomcat configuration files are only accessible to the tomcat user&lt;br /&gt;
&lt;br /&gt;
[[Category:OWASP Java Project]]&lt;/div&gt;</summary>
		<author><name>Dledmonds</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Securing_tomcat&amp;diff=11158</id>
		<title>Securing tomcat</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Securing_tomcat&amp;diff=11158"/>
				<updated>2006-10-27T12:32:37Z</updated>
		
		<summary type="html">&lt;p&gt;Dledmonds: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
Most weaknesses in [http://tomcat.apache.org/ Apache Tomcat] come from incorrect or inappropiate configuration.  It is nearly always possible to make Tomcat more secure than the default out of the box installation.  What follows documents best practices and recommendations on securing a production Tomcat server, whether it be hosted on a Windows or Unix based operating system.  ''Please note that the section ordering is not a representation of the section importance.''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Software Versions ==&lt;br /&gt;
&lt;br /&gt;
The first step is to make sure you are running the latest stable releases of software;&lt;br /&gt;
* Java Runtime Environment (JRE) or SDK&lt;br /&gt;
* Tomcat&lt;br /&gt;
* Third party libraries&lt;br /&gt;
This does not mean you have to upgrade all your production servers to a new (and potentially buggy) release which has just been made available to the public.  What you must do is download the latest stable bugfix release that has continual support.  For the JRE and Tomcat you should be looking at the last digits in the version number (5.5.'''X''') as it represents the bugfix information.  The bugs fixed in these releases are publicly available so if you don't upgrade you could be providing attackers with a very easy route to compromise your server.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Installation of Apache Tomcat 5.5 ==&lt;br /&gt;
&lt;br /&gt;
=== UNIX ===&lt;br /&gt;
&lt;br /&gt;
* Create a tomcat user/group&lt;br /&gt;
* Download and unpack the core distribution (referenced as '''CATALINA_HOME''' from now on)&lt;br /&gt;
* Change '''CATALINA_HOME''' ownership to tomcat user and tomcat group&lt;br /&gt;
* Change files in '''CATALINA_HOME'''/conf to be readonly&lt;br /&gt;
* Make sure tomcat user has read/write access to /tmp and write (yes, only write) access to '''CATALINA_HOME'''/log&lt;br /&gt;
&lt;br /&gt;
=== Windows ===&lt;br /&gt;
&lt;br /&gt;
* Download the core windows service installer&lt;br /&gt;
* Start the installation, click ''Next'' and ''Agree'' to the licence&lt;br /&gt;
* Untick ''native'', ''documentation'', ''examples'' and ''webapps'' then click ''Next''&lt;br /&gt;
* Choose an installation directory (referenced as '''CATALINA_HOME''' from now on), preferably on a different drive to the OS.  &lt;br /&gt;
* Choose an administrator username (NOT admin) and a secure password that complies with your organisations password policy.&lt;br /&gt;
* Complete tomcat installation, but do not start service.&lt;br /&gt;
* TODO: ''filesystem security''&lt;br /&gt;
&lt;br /&gt;
=== Common ===&lt;br /&gt;
&lt;br /&gt;
* Remove everything from '''CATALINA_HOME'''/webapps (ROOT, balancer, jsp-examples, servlet-examples, tomcat-docs, webdav)&lt;br /&gt;
* Remove everything from '''CATALINA_HOME'''/server/webapps (host-manager, manager).  Note that it can be useful to keep the manager webapp installed if you need the ability to redeploy without restarting Tomcat.  If you choose to keep it please read the section on Securing the Manager WebApp.&lt;br /&gt;
* Remove '''CATALINA_HOME'''/conf/Catalina/localhost/host-manager.xml and '''CATALINA_HOME'''/conf/Catalina/localhost/manager.xml (again, if you are keeping the manager application, do not remove this).&lt;br /&gt;
* Make sure the default servlet is configured '''not''' to serve index pages when a welcome file is not present.  In '''CATALINA_HOME'''/conf/web.xml&lt;br /&gt;
  &amp;lt;servlet&amp;gt;&lt;br /&gt;
    &amp;lt;servlet-name&amp;gt;default&amp;lt;/servlet-name&amp;gt;&lt;br /&gt;
    &amp;lt;servlet-class&amp;gt;org.apache.catalina.servlets.DefaultServlet&amp;lt;/servlet-class&amp;gt;&lt;br /&gt;
    &amp;lt;init-param&amp;gt;&lt;br /&gt;
      &amp;lt;param-name&amp;gt;debug&amp;lt;/param-name&amp;gt;&lt;br /&gt;
      &amp;lt;param-value&amp;gt;0&amp;lt;/param-value&amp;gt;&lt;br /&gt;
    &amp;lt;/init-param&amp;gt;&lt;br /&gt;
    &amp;lt;init-param&amp;gt;&lt;br /&gt;
      &amp;lt;param-name&amp;gt;listings&amp;lt;/param-name&amp;gt;&lt;br /&gt;
      &amp;lt;param-value&amp;gt;'''false'''&amp;lt;/param-value&amp;gt;  &amp;amp;lt;!-- make sure this is false --&amp;amp;gt;&lt;br /&gt;
    &amp;lt;/init-param&amp;gt;&lt;br /&gt;
    &amp;lt;load-on-startup&amp;gt;1&amp;lt;/load-on-startup&amp;gt;&lt;br /&gt;
  &amp;lt;/servlet&amp;gt;&lt;br /&gt;
* Remove version string from HTTP error messages by repacking '''CATALINA_HOME'''/server/lib/catalina.jar with an updated ServerInfo.properties file.&lt;br /&gt;
  cd CATALINA_HOME/server/lib&lt;br /&gt;
  jar xf catalina.jar org/apache/catalina/util/ServerInfo.properties&lt;br /&gt;
  ... update ServerInfo.properties by changing server.info line to server.info=Apache Tomcat&lt;br /&gt;
  jar uf catalina.jar org/apache/catalina/util/ServerInfo.properties&lt;br /&gt;
  ... remove CATALINA_HOME/server/lib/org (created when extracting the ServerInfo.properties file)&lt;br /&gt;
* Replace default error page (default is stacktrace) by adding the following into '''CATALINA_HOME'''/conf/web.xml.  The default error page shows a full stacktrace which is a disclosure of sensitive information.  ''The following solution is not ideal as it produces a blank page because Tomcat cannot find the file specified, but without a better solution this, at least, achieves the desired result.  A well configured web application will override this default in CATALINA_HOME/webapps/APP_NAME/WEB-INF/web.xml so it won't cause problems.''&lt;br /&gt;
  &amp;lt;error-page&amp;gt;&lt;br /&gt;
    &amp;lt;exception-type&amp;gt;java.lang.Exception&amp;lt;/exception-type&amp;gt;&lt;br /&gt;
    &amp;lt;location&amp;gt;/error.jsp&amp;lt;/location&amp;gt;&lt;br /&gt;
  &amp;lt;/error-page&amp;gt;&lt;br /&gt;
* Consider replacing '''CATALINA_HOME'''/conf/server.xml with '''CATALINA_HOME'''/conf/server-minimal.xml - ''work out what we lose''&lt;br /&gt;
* ''is it easy to remove the version string from the server HTTP header (Apache-Coyote/1.1) ?''&lt;br /&gt;
* Start Tomcat, deploy your applications into '''CATALINA_HOME'''/webapps and hope it works!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Securing Manager WebApp ==&lt;br /&gt;
&lt;br /&gt;
* By default there are no users with the manager role.  To make use of the manager webapp you need to add a new user into the '''CATALINA_HOME'''/conf/tomcat-users.xml file.&lt;br /&gt;
  &amp;lt;user username=&amp;quot;darren&amp;quot; password=&amp;quot;ReallyComplexPassword&amp;quot; roles=&amp;quot;manager&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Using a [http://tomcat.apache.org/tomcat-5.5-doc/config/valve.html valve] to filter by IP or hostname to only allow a subset of machines to connect (i.e. LAN machines).  Add one of the following within the Context tag in '''CATALINA_HOME'''/conf/Catalina/localhost/manager.xml&lt;br /&gt;
  &amp;amp;lt;!-- allow only LAN IPs to connect to the manager webapp --&amp;amp;gt;&lt;br /&gt;
  &amp;amp;lt;!-- contrary to the current Tomcat 5.5 documation the value for '''allow''' is not a regular expression --&amp;amp;gt;&lt;br /&gt;
  &amp;amp;lt;!-- future versions may have to be specificed as 192\.168\.1\.* --&amp;amp;gt;&lt;br /&gt;
  &amp;lt;Valve className=&amp;quot;org.apache.catalina.valves.RemoteAddrValve&amp;quot;&lt;br /&gt;
         allow=&amp;quot;192.168.1.*&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  &amp;amp;lt;!-- allow only LAN hosts to connect to the manager webapp --&amp;amp;gt;&lt;br /&gt;
  &amp;amp;lt;!-- contrary to the current Tomcat 5.5 documation the value for '''allow''' is not a regular expression --&amp;amp;gt;&lt;br /&gt;
  &amp;amp;lt;!-- future versions may have to be specificed as *\.localdomain\.com --&amp;amp;gt;&lt;br /&gt;
  &amp;lt;Valve className=&amp;quot;org.apache.catalina.valves.RemoteHostValve&amp;quot;&lt;br /&gt;
         allow=&amp;quot;*.localdomain.com&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* You can rename the manager webapp to something else, e.g. ''foobar''&lt;br /&gt;
** Move '''CATALINA_HOME'''/conf/Catalina/localhost/'''manager.xml''' to '''CATALINA_HOME'''/conf/Catalina/localhost/'''foobar.xml'''&lt;br /&gt;
** Update the '''docBase''' attribute within '''CATALINA_HOME'''/conf/Catalina/localhost/'''foobar.xml''' to ${catalina.home}/server/webapps/foobar&lt;br /&gt;
** Move '''CATALINA_HOME'''/server/webapps/'''manager''' to '''CATALINA_HOME'''/server/webapps/'''foobar'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Logging ==&lt;br /&gt;
&lt;br /&gt;
* TODO: Audit trails&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Encryption ==&lt;br /&gt;
&lt;br /&gt;
* SSL for password or other sensitive data exchange (''bordering on application security, not specific to tomcat'')&lt;br /&gt;
* SSL for connections (JDBC, LDAP, etc ..)&lt;br /&gt;
* The Tomcat documentation clearly explains how to [http://tomcat.apache.org/tomcat-5.5-doc/ssl-howto.html enable SSL.]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Java Security ==&lt;br /&gt;
&lt;br /&gt;
=== Running Tomcat with a Security Manager=== &lt;br /&gt;
The default Tomcat configuration provides good protection for most requirements, but does not prevent a malicious application from compromising the security of other applications running in the same instance.  To prevent this sort of attack, Tomcat can be run with a Security Manager enabled which strictly controls access to server resources.&lt;br /&gt;
Tomcat documentation has a good section on [http://tomcat.apache.org/tomcat-5.5-doc/security-manager-howto.html enabling the Security Manager.]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Miscellaneous ==&lt;br /&gt;
&lt;br /&gt;
* [http://tomcat.apache.org/faq/security.html Tomcat Security FAQ]&lt;br /&gt;
&lt;br /&gt;
=== Using Port 80 ===&lt;br /&gt;
&lt;br /&gt;
If you are on a Windows machine you will be able to change the port attribute of the connector within the ''Catalina'' service from 8080 to 80.  This allows you to use tomcat directly to serve all requests.  Depending on your requirements it may not be good enough to serve directly from Tomcat so you may like to consider;&lt;br /&gt;
* Use IIS / Apache running on port 80 and mod_jk to proxy requests to Tomcat&lt;br /&gt;
&lt;br /&gt;
On a UNIX machine only root is allowed to run services on ports below 1024 (kernel recompilation can overcome this).  It is a very bad idea to run Tomcat as root, so the options are;&lt;br /&gt;
* Use Apache running on port 80 and mod_jk (or mod_proxy_ajp) to proxy requests to Tomcat&lt;br /&gt;
* Run Tomcat as root, but in a chroot jail&lt;br /&gt;
* Use a tool like authbind to enable a non root user to bind to ports below 1024&lt;br /&gt;
* Use a port forwarder such as [http://www.netfilter.org/projects/iptables/index.html Iptables] to redirect incoming requests from 8080 to 80.  This has the disadvantage that internal redirects still need to use 8080.&lt;br /&gt;
* Run [http://www.squid-cache.org/ Squid] as a web accelerator in front of Tomcat&lt;br /&gt;
* Use JSVC/procrun&lt;br /&gt;
&lt;br /&gt;
=== Cleartext Passwords in CATALINA_HOME/conf/server.xml ===&lt;br /&gt;
&lt;br /&gt;
When configuring a resource, such as a JDBC pool, it is necessary to include clear text username and password in CATALINA_HOME/conf/server.xml  Best practices advice us never to store clear text passwords, but the following paragraphs highlight it is very difficult to avoid.&lt;br /&gt;
&lt;br /&gt;
If one way encryption was used on the password it must be possible for a database connection to be established using a username and encrypted password - so the encrypted password is just as valuable as the clear text one to an attacker.&lt;br /&gt;
&lt;br /&gt;
If two way encryption was used a keyfile is needed which must also live on the filesystem.  To make it more secure a passphase is added to the keyfile which then has to be stored in the configuration as clear text - no improvement.&lt;br /&gt;
&lt;br /&gt;
Encoding is security by obscurity and offers no form of protection (algorithms can be reverse engineered).  What encoding does do is make huge amounts of overhead work - you need to customise Tomcat and the commons digester it uses to parse the config files.  You'd also need a way to create encoded passwords.&lt;br /&gt;
&lt;br /&gt;
In the case of a JDBC pool what you can do is;&lt;br /&gt;
* make sure the database user only has access to the databases and tables they need (also limit rights as necessary).&lt;br /&gt;
* make sure the raw database files are only accessible to the user running the database services (e.g. mysql/postgresql user)&lt;br /&gt;
* make sure the Tomcat configuration files are only accessible to the tomcat user&lt;br /&gt;
&lt;br /&gt;
[[Category:OWASP Java Project]]&lt;/div&gt;</summary>
		<author><name>Dledmonds</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Securing_tomcat&amp;diff=11154</id>
		<title>Securing tomcat</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Securing_tomcat&amp;diff=11154"/>
				<updated>2006-10-27T11:55:34Z</updated>
		
		<summary type="html">&lt;p&gt;Dledmonds: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
Most weaknesses in [http://tomcat.apache.org/ Apache Tomcat] come from incorrect or inappropiate configuration.  It is nearly always possible to make Tomcat more secure than the default out of the box installation.  What follows documents best practices and recommendations on securing a production Tomcat server, whether it be hosted on a Windows or Unix based operating system.  ''Please note that the section ordering is not a representation of the section importance.''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Software Versions ==&lt;br /&gt;
&lt;br /&gt;
The first step is to make sure you are running the latest stable releases of software;&lt;br /&gt;
* Java Runtime Environment (JRE) or SDK&lt;br /&gt;
* Tomcat&lt;br /&gt;
* Third party libraries&lt;br /&gt;
This does not mean you have to upgrade all your production servers to a new (and potentially buggy) release which has just been made available to the public.  What you must do is download the latest stable bugfix release that has continual support.  For the JRE and Tomcat you should be looking at the last digits in the version number (5.5.'''X''') as it represents the bugfix information.  The bugs fixed in these releases are publicly available so if you don't upgrade you could be providing attackers with a very easy route to compromise your server.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Installation of Apache Tomcat 5.5 ==&lt;br /&gt;
&lt;br /&gt;
=== UNIX ===&lt;br /&gt;
&lt;br /&gt;
* Create a tomcat user/group&lt;br /&gt;
* Download and unpack the core distribution (referenced as '''CATALINA_HOME''' from now on)&lt;br /&gt;
* Change '''CATALINA_HOME''' ownership to tomcat user and tomcat group&lt;br /&gt;
* Change files in '''CATALINA_HOME'''/conf to be readonly&lt;br /&gt;
* Make sure tomcat user has read/write access to /tmp and write (yes, only write) access to '''CATALINA_HOME'''/log&lt;br /&gt;
&lt;br /&gt;
=== Windows ===&lt;br /&gt;
&lt;br /&gt;
* Download the core windows service installer&lt;br /&gt;
* Start the installation, click ''Next'' and ''Agree'' to the licence&lt;br /&gt;
* Untick ''native'', ''documentation'', ''examples'' and ''webapps'' then click ''Next''&lt;br /&gt;
* Choose an installation directory (referenced as '''CATALINA_HOME''' from now on), preferably on a different drive to the OS.  &lt;br /&gt;
* Choose an administrator username (NOT admin) and a secure password that complies with your organisations password policy.&lt;br /&gt;
* Complete tomcat installation, but do not start service.&lt;br /&gt;
* TODO: ''filesystem security''&lt;br /&gt;
&lt;br /&gt;
=== Common ===&lt;br /&gt;
&lt;br /&gt;
* Remove everything from '''CATALINA_HOME'''/webapps (ROOT, balancer, jsp-examples, servlet-examples, tomcat-docs, webdav)&lt;br /&gt;
* Remove everything from '''CATALINA_HOME'''/server/webapps (host-manager, manager).  Note that it can be useful to keep the manager webapp installed if you need the ability to redeploy without restarting Tomcat.  If you choose to keep it please read the section on Securing the Manager WebApp.&lt;br /&gt;
* Remove '''CATALINA_HOME'''/conf/Catalina/localhost/host-manager.xml and '''CATALINA_HOME'''/conf/Catalina/localhost/manager.xml (again, if you are keeping the manager application, do not remove this).&lt;br /&gt;
* Make sure the default servlet is configured '''not''' to serve index pages when a welcome file is not present.  In '''CATALINA_HOME'''/conf/web.xml&lt;br /&gt;
  &amp;lt;servlet&amp;gt;&lt;br /&gt;
    &amp;lt;servlet-name&amp;gt;default&amp;lt;/servlet-name&amp;gt;&lt;br /&gt;
    &amp;lt;servlet-class&amp;gt;org.apache.catalina.servlets.DefaultServlet&amp;lt;/servlet-class&amp;gt;&lt;br /&gt;
    &amp;lt;init-param&amp;gt;&lt;br /&gt;
      &amp;lt;param-name&amp;gt;debug&amp;lt;/param-name&amp;gt;&lt;br /&gt;
      &amp;lt;param-value&amp;gt;0&amp;lt;/param-value&amp;gt;&lt;br /&gt;
    &amp;lt;/init-param&amp;gt;&lt;br /&gt;
    &amp;lt;init-param&amp;gt;&lt;br /&gt;
      &amp;lt;param-name&amp;gt;listings&amp;lt;/param-name&amp;gt;&lt;br /&gt;
      &amp;lt;param-value&amp;gt;'''false'''&amp;lt;/param-value&amp;gt;  &amp;amp;lt;!-- make sure this is false --&amp;amp;gt;&lt;br /&gt;
    &amp;lt;/init-param&amp;gt;&lt;br /&gt;
    &amp;lt;load-on-startup&amp;gt;1&amp;lt;/load-on-startup&amp;gt;&lt;br /&gt;
  &amp;lt;/servlet&amp;gt;&lt;br /&gt;
* Replace default HTTP error pages (i.e. 404) by adding the following into '''CATALINA_HOME'''/conf/web.xml.  The default HTTP error pages show the full Tomcat version which is unnecessary information disclosure.  ''The following solution is not ideal as it produces a blank page because Tomcat cannot find the file specified, but without a better solution this, at least, achieves the desired result.  A well configured web application will override this default in CATALINA_HOME/webapps/APP_NAME/WEB-INF/web.xml so it won't cause problems.''&lt;br /&gt;
  &amp;lt;error-page&amp;gt;&lt;br /&gt;
    &amp;lt;error-code&amp;gt;404&amp;lt;/error-code&amp;gt;&lt;br /&gt;
    &amp;lt;location&amp;gt;/404.jsp&amp;lt;/location&amp;gt;&lt;br /&gt;
  &amp;lt;/error-page&amp;gt;&lt;br /&gt;
* Replace default error page (default is stacktrace) by adding the following into '''CATALINA_HOME'''/conf/web.xml.  The default error page shows a full stacktrace which is a disclosure of sensitive information.  ''The following solution is not ideal as it produces a blank page because Tomcat cannot find the file specified, but without a better solution this, at least, achieves the desired result.  A well configured web application will override this default in CATALINA_HOME/webapps/APP_NAME/WEB-INF/web.xml so it won't cause problems.''&lt;br /&gt;
  &amp;lt;error-page&amp;gt;&lt;br /&gt;
    &amp;lt;exception-type&amp;gt;java.lang.Exception&amp;lt;/exception-type&amp;gt;&lt;br /&gt;
    &amp;lt;location&amp;gt;/error.jsp&amp;lt;/location&amp;gt;&lt;br /&gt;
  &amp;lt;/error-page&amp;gt;&lt;br /&gt;
* Consider replacing '''CATALINA_HOME'''/conf/server.xml with '''CATALINA_HOME'''/conf/server-minimal.xml - ''work out what we lose''&lt;br /&gt;
* ''is it easy to remove the version string from the server HTTP header (Apache-Coyote/1.1) ?''&lt;br /&gt;
* Start Tomcat, deploy your applications into '''CATALINA_HOME'''/webapps and hope it works!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Securing Manager WebApp ==&lt;br /&gt;
&lt;br /&gt;
* By default there are no users with the manager role.  To make use of the manager webapp you need to add a new user into the '''CATALINA_HOME'''/conf/tomcat-users.xml file.&lt;br /&gt;
  &amp;lt;user username=&amp;quot;darren&amp;quot; password=&amp;quot;ReallyComplexPassword&amp;quot; roles=&amp;quot;manager&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Using a [http://tomcat.apache.org/tomcat-5.5-doc/config/valve.html valve] to filter by IP or hostname to only allow a subset of machines to connect (i.e. LAN machines).  Add one of the following within the Context tag in '''CATALINA_HOME'''/conf/Catalina/localhost/manager.xml&lt;br /&gt;
  &amp;amp;lt;!-- allow only LAN IPs to connect to the manager webapp --&amp;amp;gt;&lt;br /&gt;
  &amp;amp;lt;!-- contrary to the current Tomcat 5.5 documation the value for '''allow''' is not a regular expression --&amp;amp;gt;&lt;br /&gt;
  &amp;amp;lt;!-- future versions may have to be specificed as 192\.168\.1\.* --&amp;amp;gt;&lt;br /&gt;
  &amp;lt;Valve className=&amp;quot;org.apache.catalina.valves.RemoteAddrValve&amp;quot;&lt;br /&gt;
         allow=&amp;quot;192.168.1.*&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  &amp;amp;lt;!-- allow only LAN hosts to connect to the manager webapp --&amp;amp;gt;&lt;br /&gt;
  &amp;amp;lt;!-- contrary to the current Tomcat 5.5 documation the value for '''allow''' is not a regular expression --&amp;amp;gt;&lt;br /&gt;
  &amp;amp;lt;!-- future versions may have to be specificed as *\.localdomain\.com --&amp;amp;gt;&lt;br /&gt;
  &amp;lt;Valve className=&amp;quot;org.apache.catalina.valves.RemoteHostValve&amp;quot;&lt;br /&gt;
         allow=&amp;quot;*.localdomain.com&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* You can rename the manager webapp to something else, e.g. ''foobar''&lt;br /&gt;
** Move '''CATALINA_HOME'''/conf/Catalina/localhost/'''manager.xml''' to '''CATALINA_HOME'''/conf/Catalina/localhost/'''foobar.xml'''&lt;br /&gt;
** Update the '''docBase''' attribute within '''CATALINA_HOME'''/conf/Catalina/localhost/'''foobar.xml''' to ${catalina.home}/server/webapps/foobar&lt;br /&gt;
** Move '''CATALINA_HOME'''/server/webapps/'''manager''' to '''CATALINA_HOME'''/server/webapps/'''foobar'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Logging ==&lt;br /&gt;
&lt;br /&gt;
* TODO: Audit trails&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Encryption ==&lt;br /&gt;
&lt;br /&gt;
* SSL for password or other sensitive data exchange (''bordering on application security, not specific to tomcat'')&lt;br /&gt;
* SSL for connections (JDBC, LDAP, etc ..)&lt;br /&gt;
* The Tomcat documentation clearly explains how to [http://tomcat.apache.org/tomcat-5.5-doc/ssl-howto.html enable SSL.]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Java Security ==&lt;br /&gt;
&lt;br /&gt;
=== Running Tomcat with a Security Manager=== &lt;br /&gt;
The default Tomcat configuration provides good protection for most requirements, but does not prevent a malicious application from compromising the security of other applications running in the same instance.  To prevent this sort of attack, Tomcat can be run with a Security Manager enabled which strictly controls access to server resources.&lt;br /&gt;
Tomcat documentation has a good section on [http://tomcat.apache.org/tomcat-5.5-doc/security-manager-howto.html enabling the Security Manager.]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Miscellaneous ==&lt;br /&gt;
&lt;br /&gt;
* [http://tomcat.apache.org/faq/security.html Tomcat Security FAQ]&lt;br /&gt;
&lt;br /&gt;
=== Using Port 80 ===&lt;br /&gt;
&lt;br /&gt;
If you are on a Windows machine you will be able to change the port attribute of the connector within the ''Catalina'' service from 8080 to 80.  This allows you to use tomcat directly to serve all requests.  Depending on your requirements it may not be good enough to serve directly from Tomcat so you may like to consider;&lt;br /&gt;
* Use IIS / Apache running on port 80 and mod_jk to proxy requests to Tomcat&lt;br /&gt;
&lt;br /&gt;
On a UNIX machine only root is allowed to run services on ports below 1024 (kernel recompilation can overcome this).  It is a very bad idea to run Tomcat as root, so the options are;&lt;br /&gt;
* Use Apache running on port 80 and mod_jk (or mod_proxy_ajp) to proxy requests to Tomcat&lt;br /&gt;
* Run Tomcat as root, but in a chroot jail&lt;br /&gt;
* Use a tool like authbind to enable a non root user to bind to ports below 1024&lt;br /&gt;
* Use a port forwarder such as [http://www.netfilter.org/projects/iptables/index.html Iptables] to redirect incoming requests from 8080 to 80.  This has the disadvantage that internal redirects still need to use 8080.&lt;br /&gt;
* Run [http://www.squid-cache.org/ Squid] as a web accelerator in front of Tomcat&lt;br /&gt;
* Use JSVC/procrun&lt;br /&gt;
&lt;br /&gt;
=== Cleartext Passwords in CATALINA_HOME/conf/server.xml ===&lt;br /&gt;
&lt;br /&gt;
When configuring a resource, such as a JDBC pool, it is necessary to include clear text username and password in CATALINA_HOME/conf/server.xml  Best practices advice us never to store clear text passwords, but the following paragraphs highlight it is very difficult to avoid.&lt;br /&gt;
&lt;br /&gt;
If one way encryption was used on the password it must be possible for a database connection to be established using a username and encrypted password - so the encrypted password is just as valuable as the clear text one to an attacker.&lt;br /&gt;
&lt;br /&gt;
If two way encryption was used a keyfile is needed which must also live on the filesystem.  To make it more secure a passphase is added to the keyfile which then has to be stored in the configuration as clear text - no improvement.&lt;br /&gt;
&lt;br /&gt;
Encoding is security by obscurity and offers no form of protection (algorithms can be reverse engineered).  What encoding does do is make huge amounts of overhead work - you need to customise Tomcat and the commons digester it uses to parse the config files.  You'd also need a way to create encoded passwords.&lt;br /&gt;
&lt;br /&gt;
In the case of a JDBC pool what you can do is;&lt;br /&gt;
* make sure the database user only has access to the databases and tables they need (also limit rights as necessary).&lt;br /&gt;
* make sure the raw database files are only accessible to the user running the database services (e.g. mysql/postgresql user)&lt;br /&gt;
* make sure the Tomcat configuration files are only accessible to the tomcat user&lt;br /&gt;
&lt;br /&gt;
[[Category:OWASP Java Project]]&lt;/div&gt;</summary>
		<author><name>Dledmonds</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Securing_tomcat&amp;diff=11153</id>
		<title>Securing tomcat</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Securing_tomcat&amp;diff=11153"/>
				<updated>2006-10-27T11:53:47Z</updated>
		
		<summary type="html">&lt;p&gt;Dledmonds: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
Most weaknesses in [http://tomcat.apache.org/ Apache Tomcat] come from incorrect or inappropiate configuration.  It is nearly always possible to make Tomcat more secure than the default out of the box installation.  What follows documents best practices and recommendations on securing a production Tomcat server, whether it be hosted on a Windows or Unix based operating system.  ''Please note that the section ordering is not a representation of the section importance.''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Software Versions ==&lt;br /&gt;
&lt;br /&gt;
The first step is to make sure you are running the latest stable releases of software;&lt;br /&gt;
* Java Runtime Environment (JRE) or SDK&lt;br /&gt;
* Tomcat&lt;br /&gt;
* Third party libraries&lt;br /&gt;
This does not mean you have to upgrade all your production servers to a new (and potentially buggy) release which has just been made available to the public.  What you must do is download the latest stable bugfix release that has continual support.  For the JRE and Tomcat you should be looking at the last digits in the version number (5.5.'''X''') as it represents the bugfix information.  The bugs fixed in these releases are publicly available so if you don't upgrade you could be providing attackers with a very easy route to compromise your server.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Installation of Apache Tomcat 5.5 ==&lt;br /&gt;
&lt;br /&gt;
=== UNIX ===&lt;br /&gt;
&lt;br /&gt;
* Create a tomcat user/group&lt;br /&gt;
* Download and unpack the core distribution (referenced as '''CATALINA_HOME''' from now on)&lt;br /&gt;
* Change '''CATALINA_HOME''' ownership to tomcat user and tomcat group&lt;br /&gt;
* Change files in '''CATALINA_HOME'''/conf to be readonly&lt;br /&gt;
* Make sure tomcat user has read/write access to /tmp and write (yes, only write) access to '''CATALINA_HOME'''/log&lt;br /&gt;
&lt;br /&gt;
=== Windows ===&lt;br /&gt;
&lt;br /&gt;
* Download the core windows service installer&lt;br /&gt;
* Start the installation, click ''Next'' and ''Agree'' to the licence&lt;br /&gt;
* Untick ''native'', ''documentation'', ''examples'' and ''webapps'' then click ''Next''&lt;br /&gt;
* Choose an installation directory (referenced as '''CATALINA_HOME''' from now on), preferably on a different drive to the OS.  &lt;br /&gt;
* Choose an administrator username (NOT admin) and a secure password that complies with your organisations password policy.&lt;br /&gt;
* Complete tomcat installation, but do not start service.&lt;br /&gt;
* TODO: ''filesystem security''&lt;br /&gt;
&lt;br /&gt;
=== Common ===&lt;br /&gt;
&lt;br /&gt;
* Remove everything from '''CATALINA_HOME'''/webapps (ROOT, balancer, jsp-examples, servlet-examples, tomcat-docs, webdav)&lt;br /&gt;
* Remove everything from '''CATALINA_HOME'''/server/webapps (host-manager, manager).  Note that it can be useful to keep the manager webapp installed if you need the ability to redeploy without restarting Tomcat.  If you choose to keep it please read the section on Securing the Manager WebApp.&lt;br /&gt;
* Remove '''CATALINA_HOME'''/conf/Catalina/localhost/host-manager.xml and '''CATALINA_HOME'''/conf/Catalina/localhost/manager.xml (again, if you are keeping the manager application, do not remove this).&lt;br /&gt;
* Make sure the default servlet is configured '''not''' to serve index pages when a welcome file is not present.  In '''CATALINA_HOME'''/conf/web.xml&lt;br /&gt;
  &amp;lt;servlet&amp;gt;&lt;br /&gt;
    &amp;lt;servlet-name&amp;gt;default&amp;lt;/servlet-name&amp;gt;&lt;br /&gt;
    &amp;lt;servlet-class&amp;gt;org.apache.catalina.servlets.DefaultServlet&amp;lt;/servlet-class&amp;gt;&lt;br /&gt;
    &amp;lt;init-param&amp;gt;&lt;br /&gt;
      &amp;lt;param-name&amp;gt;debug&amp;lt;/param-name&amp;gt;&lt;br /&gt;
      &amp;lt;param-value&amp;gt;0&amp;lt;/param-value&amp;gt;&lt;br /&gt;
    &amp;lt;/init-param&amp;gt;&lt;br /&gt;
    &amp;lt;init-param&amp;gt;&lt;br /&gt;
      &amp;lt;param-name&amp;gt;listings&amp;lt;/param-name&amp;gt;&lt;br /&gt;
      &amp;lt;param-value&amp;gt;'''false'''&amp;lt;/param-value&amp;gt;&lt;br /&gt;
    &amp;lt;/init-param&amp;gt;&lt;br /&gt;
    &amp;lt;load-on-startup&amp;gt;1&amp;lt;/load-on-startup&amp;gt;&lt;br /&gt;
  &amp;lt;/servlet&amp;gt;&lt;br /&gt;
* Replace default HTTP error pages (i.e. 404) by adding the following into '''CATALINA_HOME'''/conf/web.xml.  The default HTTP error pages show the full Tomcat version which is unnecessary information disclosure.  ''The following solution is not ideal as it produces a blank page because Tomcat cannot find the file specified, but without a better solution this, at least, achieves the desired result.  A well configured web application will override this default in CATALINA_HOME/webapps/APP_NAME/WEB-INF/web.xml so it won't cause problems.''&lt;br /&gt;
  &amp;lt;error-page&amp;gt;&lt;br /&gt;
    &amp;lt;error-code&amp;gt;404&amp;lt;/error-code&amp;gt;&lt;br /&gt;
    &amp;lt;location&amp;gt;/404.jsp&amp;lt;/location&amp;gt;&lt;br /&gt;
  &amp;lt;/error-page&amp;gt;&lt;br /&gt;
* Replace default error page (default is stacktrace) by adding the following into '''CATALINA_HOME'''/conf/web.xml.  The default error page shows a full stacktrace which is a disclosure of sensitive information.  ''The following solution is not ideal as it produces a blank page because Tomcat cannot find the file specified, but without a better solution this, at least, achieves the desired result.  A well configured web application will override this default in CATALINA_HOME/webapps/APP_NAME/WEB-INF/web.xml so it won't cause problems.''&lt;br /&gt;
  &amp;lt;error-page&amp;gt;&lt;br /&gt;
    &amp;lt;exception-type&amp;gt;java.lang.Exception&amp;lt;/exception-type&amp;gt;&lt;br /&gt;
    &amp;lt;location&amp;gt;/error.jsp&amp;lt;/location&amp;gt;&lt;br /&gt;
  &amp;lt;/error-page&amp;gt;&lt;br /&gt;
* Consider replacing '''CATALINA_HOME'''/conf/server.xml with '''CATALINA_HOME'''/conf/server-minimal.xml - ''work out what we lose''&lt;br /&gt;
* ''is it easy to remove the version string from the server HTTP header (Apache-Coyote/1.1) ?''&lt;br /&gt;
* Start Tomcat, deploy your applications into '''CATALINA_HOME'''/webapps and hope it works!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Securing Manager WebApp ==&lt;br /&gt;
&lt;br /&gt;
* By default there are no users with the manager role.  To make use of the manager webapp you need to add a new user into the '''CATALINA_HOME'''/conf/tomcat-users.xml file.&lt;br /&gt;
  &amp;lt;user username=&amp;quot;darren&amp;quot; password=&amp;quot;ReallyComplexPassword&amp;quot; roles=&amp;quot;manager&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Using a [http://tomcat.apache.org/tomcat-5.5-doc/config/valve.html valve] to filter by IP or hostname to only allow a subset of machines to connect (i.e. LAN machines).  Add one of the following within the Context tag in '''CATALINA_HOME'''/conf/Catalina/localhost/manager.xml&lt;br /&gt;
  &amp;amp;lt;!-- allow only LAN IPs to connect to the manager webapp --&amp;amp;gt;&lt;br /&gt;
  &amp;amp;lt;!-- contrary to the current Tomcat 5.5 documation the value for '''allow''' is not a regular expression --&amp;amp;gt;&lt;br /&gt;
  &amp;amp;lt;!-- future versions may have to be specificed as 192\.168\.1\.* --&amp;amp;gt;&lt;br /&gt;
  &amp;lt;Valve className=&amp;quot;org.apache.catalina.valves.RemoteAddrValve&amp;quot;&lt;br /&gt;
         allow=&amp;quot;192.168.1.*&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  &amp;amp;lt;!-- allow only LAN hosts to connect to the manager webapp --&amp;amp;gt;&lt;br /&gt;
  &amp;amp;lt;!-- contrary to the current Tomcat 5.5 documation the value for '''allow''' is not a regular expression --&amp;amp;gt;&lt;br /&gt;
  &amp;amp;lt;!-- future versions may have to be specificed as *\.localdomain\.com --&amp;amp;gt;&lt;br /&gt;
  &amp;lt;Valve className=&amp;quot;org.apache.catalina.valves.RemoteHostValve&amp;quot;&lt;br /&gt;
         allow=&amp;quot;*.localdomain.com&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* You can rename the manager webapp to something else, e.g. ''foobar''&lt;br /&gt;
** Move '''CATALINA_HOME'''/conf/Catalina/localhost/'''manager.xml''' to '''CATALINA_HOME'''/conf/Catalina/localhost/'''foobar.xml'''&lt;br /&gt;
** Update the '''docBase''' attribute within '''CATALINA_HOME'''/conf/Catalina/localhost/'''foobar.xml''' to ${catalina.home}/server/webapps/foobar&lt;br /&gt;
** Move '''CATALINA_HOME'''/server/webapps/'''manager''' to '''CATALINA_HOME'''/server/webapps/'''foobar'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Logging ==&lt;br /&gt;
&lt;br /&gt;
* TODO: Audit trails&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Encryption ==&lt;br /&gt;
&lt;br /&gt;
* SSL for password or other sensitive data exchange (''bordering on application security, not specific to tomcat'')&lt;br /&gt;
* SSL for connections (JDBC, LDAP, etc ..)&lt;br /&gt;
* The Tomcat documentation clearly explains how to [http://tomcat.apache.org/tomcat-5.5-doc/ssl-howto.html enable SSL.]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Java Security ==&lt;br /&gt;
&lt;br /&gt;
=== Running Tomcat with a Security Manager=== &lt;br /&gt;
The default Tomcat configuration provides good protection for most requirements, but does not prevent a malicious application from compromising the security of other applications running in the same instance.  To prevent this sort of attack, Tomcat can be run with a Security Manager enabled which strictly controls access to server resources.&lt;br /&gt;
Tomcat documentation has a good section on [http://tomcat.apache.org/tomcat-5.5-doc/security-manager-howto.html enabling the Security Manager.]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Miscellaneous ==&lt;br /&gt;
&lt;br /&gt;
* [http://tomcat.apache.org/faq/security.html Tomcat Security FAQ]&lt;br /&gt;
&lt;br /&gt;
=== Using Port 80 ===&lt;br /&gt;
&lt;br /&gt;
If you are on a Windows machine you will be able to change the port attribute of the connector within the ''Catalina'' service from 8080 to 80.  This allows you to use tomcat directly to serve all requests.  Depending on your requirements it may not be good enough to serve directly from Tomcat so you may like to consider;&lt;br /&gt;
* Use IIS / Apache running on port 80 and mod_jk to proxy requests to Tomcat&lt;br /&gt;
&lt;br /&gt;
On a UNIX machine only root is allowed to run services on ports below 1024 (kernel recompilation can overcome this).  It is a very bad idea to run Tomcat as root, so the options are;&lt;br /&gt;
* Use Apache running on port 80 and mod_jk (or mod_proxy_ajp) to proxy requests to Tomcat&lt;br /&gt;
* Run Tomcat as root, but in a chroot jail&lt;br /&gt;
* Use a tool like authbind to enable a non root user to bind to ports below 1024&lt;br /&gt;
* Use a port forwarder such as [http://www.netfilter.org/projects/iptables/index.html Iptables] to redirect incoming requests from 8080 to 80.  This has the disadvantage that internal redirects still need to use 8080.&lt;br /&gt;
* Run [http://www.squid-cache.org/ Squid] as a web accelerator in front of Tomcat&lt;br /&gt;
* Use JSVC/procrun&lt;br /&gt;
&lt;br /&gt;
=== Cleartext Passwords in CATALINA_HOME/conf/server.xml ===&lt;br /&gt;
&lt;br /&gt;
When configuring a resource, such as a JDBC pool, it is necessary to include clear text username and password in CATALINA_HOME/conf/server.xml  Best practices advice us never to store clear text passwords, but the following paragraphs highlight it is very difficult to avoid.&lt;br /&gt;
&lt;br /&gt;
If one way encryption was used on the password it must be possible for a database connection to be established using a username and encrypted password - so the encrypted password is just as valuable as the clear text one to an attacker.&lt;br /&gt;
&lt;br /&gt;
If two way encryption was used a keyfile is needed which must also live on the filesystem.  To make it more secure a passphase is added to the keyfile which then has to be stored in the configuration as clear text - no improvement.&lt;br /&gt;
&lt;br /&gt;
Encoding is security by obscurity and offers no form of protection (algorithms can be reverse engineered).  What encoding does do is make huge amounts of overhead work - you need to customise Tomcat and the commons digester it uses to parse the config files.  You'd also need a way to create encoded passwords.&lt;br /&gt;
&lt;br /&gt;
In the case of a JDBC pool what you can do is;&lt;br /&gt;
* make sure the database user only has access to the databases and tables they need (also limit rights as necessary).&lt;br /&gt;
* make sure the raw database files are only accessible to the user running the database services (e.g. mysql/postgresql user)&lt;br /&gt;
* make sure the Tomcat configuration files are only accessible to the tomcat user&lt;br /&gt;
&lt;br /&gt;
[[Category:OWASP Java Project]]&lt;/div&gt;</summary>
		<author><name>Dledmonds</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Talk:Securing_tomcat&amp;diff=10978</id>
		<title>Talk:Securing tomcat</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Talk:Securing_tomcat&amp;diff=10978"/>
				<updated>2006-10-24T13:40:37Z</updated>
		
		<summary type="html">&lt;p&gt;Dledmonds: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Network Security ==&lt;br /&gt;
&lt;br /&gt;
Generic advice common to all server security (link).&lt;br /&gt;
&lt;br /&gt;
:Not sure what information should go here? [[User:Stephendv|Stephendv]] 04:21, 16 October 2006 (EDT)&lt;br /&gt;
::I was thinking of a firewall discussion in relation to protecting the server.  Perhaps this should be changed to only mention the shutdown port needs protecting in tomcat [[User:dledmonds|dledmonds]]&lt;br /&gt;
:::Ah, gotcha!  Yeah that would definitely be something worthwhile adding. [[User:Stephendv|Stephendv]] 06:53, 23 October 2006 (EDT)&lt;/div&gt;</summary>
		<author><name>Dledmonds</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Securing_tomcat&amp;diff=10977</id>
		<title>Securing tomcat</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Securing_tomcat&amp;diff=10977"/>
				<updated>2006-10-24T13:38:54Z</updated>
		
		<summary type="html">&lt;p&gt;Dledmonds: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
Most weaknesses in [http://tomcat.apache.org/ Apache Tomcat] come from incorrect or inappropiate configuration.  It is nearly always possible to make Tomcat more secure than the default out of the box installation.  What follows documents best practices and recommendations on securing a production Tomcat server, whether it be hosted on a Windows or Unix based operating system.  ''Please note that the section ordering is not a representation of the section importance.''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Software Versions ==&lt;br /&gt;
&lt;br /&gt;
The first step is to make sure you are running the latest stable releases of software;&lt;br /&gt;
* Java Runtime Environment (JRE) or SDK&lt;br /&gt;
* Tomcat&lt;br /&gt;
* Third party libraries&lt;br /&gt;
This does not mean you have to upgrade all your production servers to a new (and potentially buggy) release which has just been made available to the public.  What you must do is download the latest stable bugfix release that has continual support.  For the JRE and Tomcat you should be looking at the last digits in the version number (5.5.'''X''') as it represents the bugfix information.  The bugs fixed in these releases are publicly available so if you don't upgrade you could be providing attackers with a very easy route to compromise your server.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Installation of Apache Tomcat 5.5 ==&lt;br /&gt;
&lt;br /&gt;
=== UNIX ===&lt;br /&gt;
&lt;br /&gt;
* Create a tomcat user/group&lt;br /&gt;
* Download and unpack the core distribution (referenced as '''CATALINA_HOME''' from now on)&lt;br /&gt;
* Change '''CATALINA_HOME''' ownership to tomcat user and tomcat group&lt;br /&gt;
* Change files in '''CATALINA_HOME'''/conf to be readonly&lt;br /&gt;
* Make sure tomcat user has read/write access to /tmp and write (yes, only write) access to '''CATALINA_HOME'''/log&lt;br /&gt;
&lt;br /&gt;
=== Windows ===&lt;br /&gt;
&lt;br /&gt;
* Download the core windows service installer&lt;br /&gt;
* Start the installation, click ''Next'' and ''Agree'' to the licence&lt;br /&gt;
* Untick ''native'', ''documentation'', ''examples'' and ''webapps'' then click ''Next''&lt;br /&gt;
* Choose an installation directory (referenced as '''CATALINA_HOME''' from now on), preferably on a different drive to the OS.  &lt;br /&gt;
* Choose an administrator username (NOT admin) and a secure password that complies with your organisations password policy.&lt;br /&gt;
* Complete tomcat installation, but do not start service.&lt;br /&gt;
* TODO: ''filesystem security''&lt;br /&gt;
&lt;br /&gt;
=== Common ===&lt;br /&gt;
&lt;br /&gt;
* Remove everything from '''CATALINA_HOME'''/webapps (ROOT, balancer, jsp-examples, servlet-examples, tomcat-docs, webdav)&lt;br /&gt;
* Remove everything from '''CATALINA_HOME'''/server/webapps (host-manager, manager).  Note that it can be useful to keep the manager webapp installed if you need the ability to redeploy without restarting Tomcat.  If you choose to keep it please read the section on Securing the Manager WebApp.&lt;br /&gt;
* Make sure the default servlet is configured '''not''' to serve index pages when a welcome file is not present.  In '''CATALINA_HOME'''/conf/web.xml&lt;br /&gt;
  &amp;lt;servlet&amp;gt;&lt;br /&gt;
    &amp;lt;servlet-name&amp;gt;default&amp;lt;/servlet-name&amp;gt;&lt;br /&gt;
    &amp;lt;servlet-class&amp;gt;org.apache.catalina.servlets.DefaultServlet&amp;lt;/servlet-class&amp;gt;&lt;br /&gt;
    &amp;lt;init-param&amp;gt;&lt;br /&gt;
      &amp;lt;param-name&amp;gt;debug&amp;lt;/param-name&amp;gt;&lt;br /&gt;
      &amp;lt;param-value&amp;gt;0&amp;lt;/param-value&amp;gt;&lt;br /&gt;
    &amp;lt;/init-param&amp;gt;&lt;br /&gt;
    &amp;lt;init-param&amp;gt;&lt;br /&gt;
      &amp;lt;param-name&amp;gt;listings&amp;lt;/param-name&amp;gt;&lt;br /&gt;
      &amp;lt;param-value&amp;gt;'''false'''&amp;lt;/param-value&amp;gt;&lt;br /&gt;
    &amp;lt;/init-param&amp;gt;&lt;br /&gt;
    &amp;lt;load-on-startup&amp;gt;1&amp;lt;/load-on-startup&amp;gt;&lt;br /&gt;
  &amp;lt;/servlet&amp;gt;&lt;br /&gt;
* Replace default HTTP error pages (i.e. 404) by adding the following into '''CATALINA_HOME'''/conf/web.xml.  The default HTTP error pages show the full Tomcat version which is unnecessary information disclosure.  ''The following solution is not ideal as it produces a blank page because Tomcat cannot find the file specified, but without a better solution this, at least, achieves the desired result.  A well configured web application will override this default in CATALINA_HOME/webapps/APP_NAME/WEB-INF/web.xml so it won't cause problems.''&lt;br /&gt;
  &amp;lt;error-page&amp;gt;&lt;br /&gt;
    &amp;lt;error-code&amp;gt;404&amp;lt;/error-code&amp;gt;&lt;br /&gt;
    &amp;lt;location&amp;gt;/404.jsp&amp;lt;/location&amp;gt;&lt;br /&gt;
  &amp;lt;/error-page&amp;gt;&lt;br /&gt;
* Replace default error page (default is stacktrace) by adding the following into '''CATALINA_HOME'''/conf/web.xml.  The default error page shows a full stacktrace which is a disclosure of sensitive information.  ''The following solution is not ideal as it produces a blank page because Tomcat cannot find the file specified, but without a better solution this, at least, achieves the desired result.  A well configured web application will override this default in CATALINA_HOME/webapps/APP_NAME/WEB-INF/web.xml so it won't cause problems.''&lt;br /&gt;
  &amp;lt;error-page&amp;gt;&lt;br /&gt;
    &amp;lt;exception-type&amp;gt;java.lang.Exception&amp;lt;/exception-type&amp;gt;&lt;br /&gt;
    &amp;lt;location&amp;gt;/error.jsp&amp;lt;/location&amp;gt;&lt;br /&gt;
  &amp;lt;/error-page&amp;gt;&lt;br /&gt;
* Consider replacing '''CATALINA_HOME'''/conf/server.xml with '''CATALINA_HOME'''/conf/server-minimal.xml - ''work out what we lose''&lt;br /&gt;
* ''is it easy to remove the version string from the server HTTP header (Apache-Coyote/1.1) ?''&lt;br /&gt;
* Start Tomcat, deploy your applications into '''CATALINA_HOME'''/webapps and hope it works!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Securing Manager WebApp ==&lt;br /&gt;
&lt;br /&gt;
* By default there are no users with the manager role.  To make use of the manager webapp you need to add a new user into the '''CATALINA_HOME'''/conf/tomcat-users.xml file.&lt;br /&gt;
  &amp;lt;user username=&amp;quot;darren&amp;quot; password=&amp;quot;ReallyComplexPassword&amp;quot; roles=&amp;quot;manager&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Using a [http://tomcat.apache.org/tomcat-5.5-doc/config/valve.html valve] to filter by IP or hostname to only allow a subset of machines to connect (i.e. LAN machines).  Add one of the following within the Context tag in '''CATALINA_HOME'''/conf/Catalina/localhost/manager.xml&lt;br /&gt;
  &amp;amp;lt;!-- allow only LAN IPs to connect to the manager webapp --&amp;amp;gt;&lt;br /&gt;
  &amp;amp;lt;!-- contrary to the current Tomcat 5.5 documation the value for '''allow''' is not a regular expression --&amp;amp;gt;&lt;br /&gt;
  &amp;amp;lt;!-- future versions may have to be specificed as 192\.168\.1\.* --&amp;amp;gt;&lt;br /&gt;
  &amp;lt;Valve className=&amp;quot;org.apache.catalina.valves.RemoteAddrValve&amp;quot;&lt;br /&gt;
         allow=&amp;quot;192.168.1.*&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  &amp;amp;lt;!-- allow only LAN hosts to connect to the manager webapp --&amp;amp;gt;&lt;br /&gt;
  &amp;amp;lt;!-- contrary to the current Tomcat 5.5 documation the value for '''allow''' is not a regular expression --&amp;amp;gt;&lt;br /&gt;
  &amp;amp;lt;!-- future versions may have to be specificed as *\.localdomain\.com --&amp;amp;gt;&lt;br /&gt;
  &amp;lt;Valve className=&amp;quot;org.apache.catalina.valves.RemoteHostValve&amp;quot;&lt;br /&gt;
         allow=&amp;quot;*.localdomain.com&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* You can rename the manager webapp to something else, e.g. ''foobar''&lt;br /&gt;
** Move '''CATALINA_HOME'''/conf/Catalina/localhost/'''manager.xml''' to '''CATALINA_HOME'''/conf/Catalina/localhost/'''foobar.xml'''&lt;br /&gt;
** Update the '''docBase''' attribute within '''CATALINA_HOME'''/conf/Catalina/localhost/'''foobar.xml''' to ${catalina.home}/server/webapps/foobar&lt;br /&gt;
** Move '''CATALINA_HOME'''/server/webapps/'''manager''' to '''CATALINA_HOME'''/server/webapps/'''foobar'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Logging ==&lt;br /&gt;
&lt;br /&gt;
* TODO: Audit trails&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Encryption ==&lt;br /&gt;
&lt;br /&gt;
* SSL for password or other sensitive data exchange (''bordering on application security, not specific to tomcat'')&lt;br /&gt;
* SSL for connections (JDBC, LDAP, etc ..)&lt;br /&gt;
* The Tomcat documentation clearly explains how to [http://tomcat.apache.org/tomcat-5.5-doc/ssl-howto.html enable SSL.]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Java Security ==&lt;br /&gt;
&lt;br /&gt;
=== Running Tomcat with a Security Manager=== &lt;br /&gt;
The default Tomcat configuration provides good protection for most requirements, but does not prevent a malicious application from compromising the security of other applications running in the same instance.  To prevent this sort of attack, Tomcat can be run with a Security Manager enabled which strictly controls access to server resources.&lt;br /&gt;
Tomcat documentation has a good section on [http://tomcat.apache.org/tomcat-5.5-doc/security-manager-howto.html enabling the Security Manager.]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Miscellaneous ==&lt;br /&gt;
&lt;br /&gt;
* [http://tomcat.apache.org/faq/security.html Tomcat Security FAQ]&lt;br /&gt;
&lt;br /&gt;
=== Using Port 80 ===&lt;br /&gt;
&lt;br /&gt;
If you are on a Windows machine you will be able to change the port attribute of the connector within the ''Catalina'' service from 8080 to 80.  This allows you to use tomcat directly to serve all requests.  Depending on your requirements it may not be good enough to serve directly from Tomcat so you may like to consider;&lt;br /&gt;
* Use IIS / Apache running on port 80 and mod_jk to proxy requests to Tomcat&lt;br /&gt;
&lt;br /&gt;
On a UNIX machine only root is allowed to run services on ports below 1024 (kernel recompilation can overcome this).  It is a very bad idea to run Tomcat as root, so the options are;&lt;br /&gt;
* Use Apache running on port 80 and mod_jk (or mod_proxy_ajp) to proxy requests to Tomcat&lt;br /&gt;
* Run Tomcat as root, but in a chroot jail&lt;br /&gt;
* Use a tool like authbind to enable a non root user to bind to ports below 1024&lt;br /&gt;
* Use a port forwarder such as [http://www.netfilter.org/projects/iptables/index.html Iptables] to redirect incoming requests from 8080 to 80.  This has the disadvantage that internal redirects still need to use 8080.&lt;br /&gt;
* Run [http://www.squid-cache.org/ Squid] as a web accelerator in front of Tomcat&lt;br /&gt;
* Use JSVC/procrun&lt;br /&gt;
&lt;br /&gt;
=== Cleartext Passwords in CATALINA_HOME/conf/server.xml ===&lt;br /&gt;
&lt;br /&gt;
When configuring a resource, such as a JDBC pool, it is necessary to include clear text username and password in CATALINA_HOME/conf/server.xml  Best practices advice us never to store clear text passwords, but the following paragraphs highlight it is very difficult to avoid.&lt;br /&gt;
&lt;br /&gt;
If one way encryption was used on the password it must be possible for a database connection to be established using a username and encrypted password - so the encrypted password is just as valuable as the clear text one to an attacker.&lt;br /&gt;
&lt;br /&gt;
If two way encryption was used a keyfile is needed which must also live on the filesystem.  To make it more secure a passphase is added to the keyfile which then has to be stored in the configuration as clear text - no improvement.&lt;br /&gt;
&lt;br /&gt;
Encoding is security by obscurity and offers no form of protection (algorithms can be reverse engineered).  What encoding does do is make huge amounts of overhead work - you need to customise Tomcat and the commons digester it uses to parse the config files.  You'd also need a way to create encoded passwords.&lt;br /&gt;
&lt;br /&gt;
In the case of a JDBC pool what you can do is;&lt;br /&gt;
* make sure the database user only has access to the databases and tables they need (also limit rights as necessary).&lt;br /&gt;
* make sure the raw database files are only accessible to the user running the database services (e.g. mysql/postgresql user)&lt;br /&gt;
* make sure the Tomcat configuration files are only accessible to the tomcat user&lt;br /&gt;
&lt;br /&gt;
[[Category:OWASP Java Project]]&lt;/div&gt;</summary>
		<author><name>Dledmonds</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Talk:Securing_tomcat&amp;diff=10878</id>
		<title>Talk:Securing tomcat</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Talk:Securing_tomcat&amp;diff=10878"/>
				<updated>2006-10-20T15:36:38Z</updated>
		
		<summary type="html">&lt;p&gt;Dledmonds: /* Securing Manager WebApp */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Installation ==&lt;br /&gt;
* Choose an installation directory (referenced as '''TOMCAT_DIR''' from now on), preferably on a different drive to the OS. &lt;br /&gt;
 &lt;br /&gt;
:do we get many advantages separating application and webapps? - Darren Edmonds&lt;br /&gt;
::it could prevent path traversal under windows, but not unix.  Separating apps from OS is common good practice anyway.  [[User:Stephendv|Stephendv]] 02:32, 9 October 2006 (EDT)&lt;br /&gt;
&lt;br /&gt;
== Network Security ==&lt;br /&gt;
&lt;br /&gt;
Generic advice common to all server security (link).&lt;br /&gt;
&lt;br /&gt;
:Not sure what information should go here? [[User:Stephendv|Stephendv]] 04:21, 16 October 2006 (EDT)&lt;br /&gt;
:I was thinking of a firewall discussion in relation to protecting the server.  Perhaps this should be changed to only mention the shutdown port needs protecting in tomcat [[User:dledmonds|dledmonds]]&lt;br /&gt;
&lt;br /&gt;
== User Input ==&lt;br /&gt;
&lt;br /&gt;
User data, whether it be HTTP headers or parameters, should '&amp;quot;never&amp;quot;' be trusted.  It is usually the responsibility of the application to validate data, but it is important that one poorly written application doesn't compromise Tomcat as a whole.&lt;br /&gt;
&lt;br /&gt;
* global filters&lt;br /&gt;
* global error pages (see above)&lt;br /&gt;
* permission lockdown (see below)&lt;br /&gt;
&lt;br /&gt;
:I think this section would be more appropriate for apps themselves, rather than applying to the server as a whole. [[User:Stephendv|Stephendv]] 04:24, 16 October 2006 (EDT)&lt;br /&gt;
:Agree the section doesn't seem relevant to Tomcat as it is, but I wanted to focus on preventing one webapp ruining it for everyone.   Perhaps a full rundown on java security is out of scope, but how could we prevent a poorly written download webapp from using path traversal exploits to download files of other webapps? [[User:dledmonds|dledmonds]]&lt;br /&gt;
&lt;br /&gt;
== Securing Manager WebApp ==&lt;br /&gt;
&lt;br /&gt;
* By default there are no users with the manager role.  To make use of the manager webapp you need to add a new user into the '''CATALINA_HOME'''/conf/tomcat-users.xml file.&lt;br /&gt;
  &amp;lt;user username=&amp;quot;darren&amp;quot; password=&amp;quot;ReallyComplexPassword&amp;quot; roles=&amp;quot;manager&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Using a [http://tomcat.apache.org/tomcat-5.5-doc/config/valve.html valve] to filter by IP or hostname to only allow a subset of machines to connect (i.e. LAN machines).  Add one of the following within the Context tag in '''CATALINA_HOME'''/conf/Catalina/localhost/manager.xml&lt;br /&gt;
  &amp;amp;lt;!-- allow only LAN IPs to connect to the manager webapp --&amp;amp;gt;&lt;br /&gt;
  &amp;amp;lt;!-- contrary to the current Tomcat 5.5 documation the value for '''allow''' is not a regular expression --&amp;amp;gt;&lt;br /&gt;
  &amp;amp;lt;!-- future versions may have to be specificed as 192\.168\.1\.* --&amp;amp;gt;&lt;br /&gt;
  &amp;lt;Valve className=&amp;quot;org.apache.catalina.valves.RemoteAddrValve&amp;quot;&lt;br /&gt;
         allow=&amp;quot;192.168.1.*&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  &amp;amp;lt;!-- allow only LAN hosts to connect to the manager webapp --&amp;amp;gt;&lt;br /&gt;
  &amp;amp;lt;!-- contrary to the current Tomcat 5.5 documation the value for '''allow''' is not a regular expression --&amp;amp;gt;&lt;br /&gt;
  &amp;amp;lt;!-- future versions may have to be specificed as *\.localdomain\.com --&amp;amp;gt;&lt;br /&gt;
  &amp;lt;Valve className=&amp;quot;org.apache.catalina.valves.RemoteHostValve&amp;quot;&lt;br /&gt;
         allow=&amp;quot;*.localdomain.com&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* You can rename the manager webapp to something else, e.g. ''foobar''  (''confirm nothing breaks in this move'')&lt;br /&gt;
** Move '''CATALINA_HOME'''/conf/Catalina/localhost/'''manager.xml''' to '''CATALINA_HOME'''/conf/Catalina/localhost/'''foobar.xml'''&lt;br /&gt;
** Update the '''docBase''' attribute within '''CATALINA_HOME'''/conf/Catalina/localhost/'''foobar.xml''' to ${catalina.home}/server/webapps/foobar&lt;br /&gt;
** Move '''CATALINA_HOME'''/server/webapps/'''manager''' to '''CATALINA_HOME'''/server/webapps/'''foobar'''&lt;br /&gt;
&lt;br /&gt;
== Miscellaneous ==&lt;br /&gt;
&lt;br /&gt;
* [http://tomcat.apache.org/faq/security.html Tomcat Security FAQ]&lt;br /&gt;
&lt;br /&gt;
=== Using Port 80 ===&lt;br /&gt;
&lt;br /&gt;
If you are on a Windows machine you will be able to change the port attribute of the connector within the ''Catalina'' service from 8080 to 80.  This allows you to use tomcat directly to serve all requests.  Depending on your requirements it may not be good enough to serve directly from Tomcat so you may like to consider;&lt;br /&gt;
* Use IIS / Apache running on port 80 and mod_jk to proxy requests to Tomcat&lt;br /&gt;
&lt;br /&gt;
On a UNIX machine only root is allowed to run services on ports below 1024 (kernel recompilation can overcome this).  It is a very bad idea to run Tomcat as root, so the options are;&lt;br /&gt;
* Use Apache running on port 80 and mod_jk to proxy requests to Tomcat  (''is mod_jk the correct version?'')&lt;br /&gt;
* Run Tomcat as root, but in a chroot jail&lt;br /&gt;
* Use a tool like authbind to enable a non root user to bind to ports below 1024&lt;br /&gt;
* Use a port forwarder such as [http://www.netfilter.org/projects/iptables/index.html Iptables] to redirect incoming requests from 8080 to 80.  This has the disadvantage that internal redirects still need to use 8080.&lt;br /&gt;
* Run [http://www.squid-cache.org/ Squid] as a web accelerator in front of Tomcat&lt;br /&gt;
* Use JSVC/procrun&lt;br /&gt;
&lt;br /&gt;
=== Cleartext Passwords in CATALINA_HOME/conf/server.xml ===&lt;br /&gt;
&lt;br /&gt;
When configuring a resource, such as a JDBC pool, it is necessary to include clear text username and password in CATALINA_HOME/conf/server.xml  Best practices advice us never to store clear text passwords, but the following paragraphs highlight it is very difficult to avoid.&lt;br /&gt;
&lt;br /&gt;
If one way encryption was used on the password it must be possible for a database connection to be established using a username and encrypted password - so the encrypted password is just as valuable as the clear text one to an attacker.&lt;br /&gt;
&lt;br /&gt;
If two way encryption was used a keyfile is needed which must also live on the filesystem.  To make it more secure a passphase is added to the keyfile which then has to be stored in the configuration as clear text - no improvement.&lt;br /&gt;
&lt;br /&gt;
Encoding is security by obscurity and offers no form of protection (algorithms can be reverse engineered).  What encoding does do is make huge amounts of overhead work - you need to customise Tomcat and the commons digester it uses to parse the config files.  You'd also need a way to create encoded passwords.&lt;br /&gt;
&lt;br /&gt;
In the case of a JDBC pool what you can do is;&lt;br /&gt;
* make sure the database user only has access to the databases and tables they need (also limit rights as necessary).&lt;br /&gt;
* make sure the raw database files are only accessible to the user running the database services (e.g. mysql/postgresql user)&lt;br /&gt;
* make sure the Tomcat configuration files are only accessible to the tomcat user&lt;/div&gt;</summary>
		<author><name>Dledmonds</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Talk:Securing_tomcat&amp;diff=10877</id>
		<title>Talk:Securing tomcat</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Talk:Securing_tomcat&amp;diff=10877"/>
				<updated>2006-10-20T14:28:44Z</updated>
		
		<summary type="html">&lt;p&gt;Dledmonds: /* Securing Manager WebApp */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Installation ==&lt;br /&gt;
* Choose an installation directory (referenced as '''TOMCAT_DIR''' from now on), preferably on a different drive to the OS. &lt;br /&gt;
 &lt;br /&gt;
:do we get many advantages separating application and webapps? - Darren Edmonds&lt;br /&gt;
::it could prevent path traversal under windows, but not unix.  Separating apps from OS is common good practice anyway.  [[User:Stephendv|Stephendv]] 02:32, 9 October 2006 (EDT)&lt;br /&gt;
&lt;br /&gt;
== Network Security ==&lt;br /&gt;
&lt;br /&gt;
Generic advice common to all server security (link).&lt;br /&gt;
&lt;br /&gt;
:Not sure what information should go here? [[User:Stephendv|Stephendv]] 04:21, 16 October 2006 (EDT)&lt;br /&gt;
:I was thinking of a firewall discussion in relation to protecting the server.  Perhaps this should be changed to only mention the shutdown port needs protecting in tomcat [[User:dledmonds|dledmonds]]&lt;br /&gt;
&lt;br /&gt;
== User Input ==&lt;br /&gt;
&lt;br /&gt;
User data, whether it be HTTP headers or parameters, should '&amp;quot;never&amp;quot;' be trusted.  It is usually the responsibility of the application to validate data, but it is important that one poorly written application doesn't compromise Tomcat as a whole.&lt;br /&gt;
&lt;br /&gt;
* global filters&lt;br /&gt;
* global error pages (see above)&lt;br /&gt;
* permission lockdown (see below)&lt;br /&gt;
&lt;br /&gt;
:I think this section would be more appropriate for apps themselves, rather than applying to the server as a whole. [[User:Stephendv|Stephendv]] 04:24, 16 October 2006 (EDT)&lt;br /&gt;
:Agree the section doesn't seem relevant to Tomcat as it is, but I wanted to focus on preventing one webapp ruining it for everyone.   Perhaps a full rundown on java security is out of scope, but how could we prevent a poorly written download webapp from using path traversal exploits to download files of other webapps? [[User:dledmonds|dledmonds]]&lt;br /&gt;
&lt;br /&gt;
== Securing Manager WebApp ==&lt;br /&gt;
&lt;br /&gt;
* Brief description of how to create a valid manager capable user&lt;br /&gt;
&lt;br /&gt;
* Using a [http://tomcat.apache.org/tomcat-5.5-doc/config/valve.html valve] to filtering by IP or hostname to only allow a subset of machine to connect (i.e. LAN machines).  Add one of the following within the Context tag in '''CATALINA_HOME'''/conf/Catalina/localhost/manager.xml&lt;br /&gt;
  &amp;amp;lt;!-- allow only LAN IPs to connect to the manager webapp --&amp;amp;gt;&lt;br /&gt;
  &amp;amp;lt;!-- contrary to the current Tomcat 5.5 documation the value for '''allow''' is not a regular expression --&amp;amp;gt;&lt;br /&gt;
  &amp;amp;lt;!-- future versions may have to be specificed as 192\.168\.1\.* --&amp;amp;gt;&lt;br /&gt;
  &amp;lt;Valve className=&amp;quot;org.apache.catalina.valves.RemoteAddrValve&amp;quot;&lt;br /&gt;
         allow=&amp;quot;192.168.1.*&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  &amp;amp;lt;!-- allow only LAN hosts to connect to the manager webapp --&amp;amp;gt;&lt;br /&gt;
  &amp;amp;lt;!-- contrary to the current Tomcat 5.5 documation the value for '''allow''' is not a regular expression --&amp;amp;gt;&lt;br /&gt;
  &amp;amp;lt;!-- future versions may have to be specificed as *\.localdomain\.com --&amp;amp;gt;&lt;br /&gt;
  &amp;lt;Valve className=&amp;quot;org.apache.catalina.valves.RemoteHostValve&amp;quot;&lt;br /&gt;
         allow=&amp;quot;*.localdomain.com&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Renaming the manager webapp&lt;br /&gt;
&lt;br /&gt;
== Miscellaneous ==&lt;br /&gt;
&lt;br /&gt;
* [http://tomcat.apache.org/faq/security.html Tomcat Security FAQ]&lt;br /&gt;
&lt;br /&gt;
=== Using Port 80 ===&lt;br /&gt;
&lt;br /&gt;
If you are on a Windows machine you will be able to change the port attribute of the connector within the ''Catalina'' service from 8080 to 80.  This allows you to use tomcat directly to serve all requests.  Depending on your requirements it may not be good enough to serve directly from Tomcat so you may like to consider;&lt;br /&gt;
* Use IIS / Apache running on port 80 and mod_jk to proxy requests to Tomcat&lt;br /&gt;
&lt;br /&gt;
On a UNIX machine only root is allowed to run services on ports below 1024 (kernel recompilation can overcome this).  It is a very bad idea to run Tomcat as root, so the options are;&lt;br /&gt;
* Use Apache running on port 80 and mod_jk to proxy requests to Tomcat  (''is mod_jk the correct version?'')&lt;br /&gt;
* Run Tomcat as root, but in a chroot jail&lt;br /&gt;
* Use a tool like authbind to enable a non root user to bind to ports below 1024&lt;br /&gt;
* Use a port forwarder such as [http://www.netfilter.org/projects/iptables/index.html Iptables] to redirect incoming requests from 8080 to 80.  This has the disadvantage that internal redirects still need to use 8080.&lt;br /&gt;
* Run [http://www.squid-cache.org/ Squid] as a web accelerator in front of Tomcat&lt;br /&gt;
* Use JSVC/procrun&lt;br /&gt;
&lt;br /&gt;
=== Cleartext Passwords in CATALINA_HOME/conf/server.xml ===&lt;br /&gt;
&lt;br /&gt;
When configuring a resource, such as a JDBC pool, it is necessary to include clear text username and password in CATALINA_HOME/conf/server.xml  Best practices advice us never to store clear text passwords, but the following paragraphs highlight it is very difficult to avoid.&lt;br /&gt;
&lt;br /&gt;
If one way encryption was used on the password it must be possible for a database connection to be established using a username and encrypted password - so the encrypted password is just as valuable as the clear text one to an attacker.&lt;br /&gt;
&lt;br /&gt;
If two way encryption was used a keyfile is needed which must also live on the filesystem.  To make it more secure a passphase is added to the keyfile which then has to be stored in the configuration as clear text - no improvement.&lt;br /&gt;
&lt;br /&gt;
Encoding is security by obscurity and offers no form of protection (algorithms can be reverse engineered).  What encoding does do is make huge amounts of overhead work - you need to customise Tomcat and the commons digester it uses to parse the config files.  You'd also need a way to create encoded passwords.&lt;br /&gt;
&lt;br /&gt;
In the case of a JDBC pool what you can do is;&lt;br /&gt;
* make sure the database user only has access to the databases and tables they need (also limit rights as necessary).&lt;br /&gt;
* make sure the raw database files are only accessible to the user running the database services (e.g. mysql/postgresql user)&lt;br /&gt;
* make sure the Tomcat configuration files are only accessible to the tomcat user&lt;/div&gt;</summary>
		<author><name>Dledmonds</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Talk:Securing_tomcat&amp;diff=10873</id>
		<title>Talk:Securing tomcat</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Talk:Securing_tomcat&amp;diff=10873"/>
				<updated>2006-10-20T12:14:21Z</updated>
		
		<summary type="html">&lt;p&gt;Dledmonds: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Installation ==&lt;br /&gt;
* Choose an installation directory (referenced as '''TOMCAT_DIR''' from now on), preferably on a different drive to the OS. &lt;br /&gt;
 &lt;br /&gt;
:do we get many advantages separating application and webapps? - Darren Edmonds&lt;br /&gt;
::it could prevent path traversal under windows, but not unix.  Separating apps from OS is common good practice anyway.  [[User:Stephendv|Stephendv]] 02:32, 9 October 2006 (EDT)&lt;br /&gt;
&lt;br /&gt;
== Network Security ==&lt;br /&gt;
&lt;br /&gt;
Generic advice common to all server security (link).&lt;br /&gt;
&lt;br /&gt;
:Not sure what information should go here? [[User:Stephendv|Stephendv]] 04:21, 16 October 2006 (EDT)&lt;br /&gt;
:I was thinking of a firewall discussion in relation to protecting the server.  Perhaps this should be changed to only mention the shutdown port needs protecting in tomcat [[User:dledmonds|dledmonds]]&lt;br /&gt;
&lt;br /&gt;
== User Input ==&lt;br /&gt;
&lt;br /&gt;
User data, whether it be HTTP headers or parameters, should '&amp;quot;never&amp;quot;' be trusted.  It is usually the responsibility of the application to validate data, but it is important that one poorly written application doesn't compromise Tomcat as a whole.&lt;br /&gt;
&lt;br /&gt;
* global filters&lt;br /&gt;
* global error pages (see above)&lt;br /&gt;
* permission lockdown (see below)&lt;br /&gt;
&lt;br /&gt;
:I think this section would be more appropriate for apps themselves, rather than applying to the server as a whole. [[User:Stephendv|Stephendv]] 04:24, 16 October 2006 (EDT)&lt;br /&gt;
:Agree the section doesn't seem relevant to Tomcat as it is, but I wanted to focus on preventing one webapp ruining it for everyone.   Perhaps a full rundown on java security is out of scope, but how could we prevent a poorly written download webapp from using path traversal exploits to download files of other webapps? [[User:dledmonds|dledmonds]]&lt;br /&gt;
&lt;br /&gt;
== Securing Manager WebApp ==&lt;br /&gt;
&lt;br /&gt;
* Brief description of how to create a valid manager capable user&lt;br /&gt;
* IP filtering&lt;br /&gt;
* Renaming the manager webapp&lt;br /&gt;
&lt;br /&gt;
== Miscellaneous ==&lt;br /&gt;
&lt;br /&gt;
* [http://tomcat.apache.org/faq/security.html Tomcat Security FAQ]&lt;br /&gt;
&lt;br /&gt;
=== Using Port 80 ===&lt;br /&gt;
&lt;br /&gt;
If you are on a Windows machine you will be able to change the port attribute of the connector within the ''Catalina'' service from 8080 to 80.  This allows you to use tomcat directly to serve all requests.  Depending on your requirements it may not be good enough to serve directly from Tomcat so you may like to consider;&lt;br /&gt;
* Use IIS / Apache running on port 80 and mod_jk to proxy requests to Tomcat&lt;br /&gt;
&lt;br /&gt;
On a UNIX machine only root is allowed to run services on ports below 1024 (kernel recompilation can overcome this).  It is a very bad idea to run Tomcat as root, so the options are;&lt;br /&gt;
* Use Apache running on port 80 and mod_jk to proxy requests to Tomcat  (''is mod_jk the correct version?'')&lt;br /&gt;
* Run Tomcat as root, but in a chroot jail&lt;br /&gt;
* Use a tool like authbind to enable a non root user to bind to ports below 1024&lt;br /&gt;
* Use a port forwarder such as [http://www.netfilter.org/projects/iptables/index.html Iptables] to redirect incoming requests from 8080 to 80.  This has the disadvantage that internal redirects still need to use 8080.&lt;br /&gt;
* Run [http://www.squid-cache.org/ Squid] as a web accelerator in front of Tomcat&lt;br /&gt;
* Use JSVC/procrun&lt;br /&gt;
&lt;br /&gt;
=== Cleartext Passwords in CATALINA_HOME/conf/server.xml ===&lt;br /&gt;
&lt;br /&gt;
When configuring a resource, such as a JDBC pool, it is necessary to include clear text username and password in CATALINA_HOME/conf/server.xml  Best practices advice us never to store clear text passwords, but the following paragraphs highlight it is very difficult to avoid.&lt;br /&gt;
&lt;br /&gt;
If one way encryption was used on the password it must be possible for a database connection to be established using a username and encrypted password - so the encrypted password is just as valuable as the clear text one to an attacker.&lt;br /&gt;
&lt;br /&gt;
If two way encryption was used a keyfile is needed which must also live on the filesystem.  To make it more secure a passphase is added to the keyfile which then has to be stored in the configuration as clear text - no improvement.&lt;br /&gt;
&lt;br /&gt;
Encoding is security by obscurity and offers no form of protection (algorithms can be reverse engineered).  What encoding does do is make huge amounts of overhead work - you need to customise Tomcat and the commons digester it uses to parse the config files.  You'd also need a way to create encoded passwords.&lt;br /&gt;
&lt;br /&gt;
In the case of a JDBC pool what you can do is;&lt;br /&gt;
* make sure the database user only has access to the databases and tables they need (also limit rights as necessary).&lt;br /&gt;
* make sure the raw database files are only accessible to the user running the database services (e.g. mysql/postgresql user)&lt;br /&gt;
* make sure the Tomcat configuration files are only accessible to the tomcat user&lt;/div&gt;</summary>
		<author><name>Dledmonds</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Securing_tomcat&amp;diff=10872</id>
		<title>Securing tomcat</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Securing_tomcat&amp;diff=10872"/>
				<updated>2006-10-20T11:39:48Z</updated>
		
		<summary type="html">&lt;p&gt;Dledmonds: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
Most weaknesses in [http://tomcat.apache.org/ Apache Tomcat] come from incorrect or inappropiate configuration.  It is nearly always possible to make Tomcat more secure than the default out of the box installation.  What follows documents best practices and recommendations on securing a production Tomcat server, whether it be hosted on a Windows or Unix based operating system.  ''Please note that the section ordering is not a representation of the section importance.''&lt;br /&gt;
&lt;br /&gt;
== Software Versions ==&lt;br /&gt;
&lt;br /&gt;
The first step is to make sure you are running the latest stable releases of software;&lt;br /&gt;
* Java Runtime Environment (JRE) or SDK&lt;br /&gt;
* Tomcat&lt;br /&gt;
* Third party libraries&lt;br /&gt;
This does not mean you have to upgrade all your production servers to a new (and potentially buggy) release which has just been made available to the public.  What you must do is download the latest stable bugfix release that has continual support.  For the JRE and Tomcat you should be looking at the last digits in the version number (5.5.'''X''') as it represents the bugfix information.  The bugs fixed in these releases are publicly available so if you don't upgrade you could be providing attackers with a very easy route to compromise your server.&lt;br /&gt;
&lt;br /&gt;
== Installation of Apache Tomcat 5.5 ==&lt;br /&gt;
&lt;br /&gt;
=== UNIX ===&lt;br /&gt;
&lt;br /&gt;
* Create a tomcat user/group&lt;br /&gt;
* Download and unpack the core distribution (referenced as '''CATALINA_HOME''' from now on)&lt;br /&gt;
* Change '''CATALINA_HOME''' ownership to tomcat user and tomcat group&lt;br /&gt;
* Change files in '''CATALINA_HOME'''/conf to be readonly&lt;br /&gt;
* Make sure tomcat user has read/write access to /tmp and write (yes, only write) access to '''CATALINA_HOME'''/log&lt;br /&gt;
&lt;br /&gt;
=== Windows ===&lt;br /&gt;
&lt;br /&gt;
* Download the core windows service installer&lt;br /&gt;
* Start the installation, click ''Next'' and ''Agree'' to the licence&lt;br /&gt;
* Untick ''native'', ''documentation'', ''examples'' and ''webapps'' then click ''Next''&lt;br /&gt;
* Choose an installation directory (referenced as '''CATALINA_HOME''' from now on), preferably on a different drive to the OS.  &lt;br /&gt;
* Choose an administrator username (NOT admin) and a secure password that complies with your organisations password policy.&lt;br /&gt;
* Complete tomcat installation, but do not start service.&lt;br /&gt;
* TODO: ''filesystem security''&lt;br /&gt;
&lt;br /&gt;
=== Common ===&lt;br /&gt;
&lt;br /&gt;
* Remove everything from '''CATALINA_HOME'''/webapps (ROOT, balancer, jsp-examples, servlet-examples, tomcat-docs, webdav)&lt;br /&gt;
* Remove everything from '''CATALINA_HOME'''/server/webapps (host-manager, manager).  Note that it can be useful to keep the manager webapp installed if you need the ability to redeploy without restarting Tomcat.  If you choose to keep it please read the section on Securing the Manager WebApp.&lt;br /&gt;
* Make sure the default servlet is configured '''not''' to serve index pages when a welcome file is not present.  In '''CATALINA_HOME'''/conf/web.xml&lt;br /&gt;
  &amp;lt;servlet&amp;gt;&lt;br /&gt;
    &amp;lt;servlet-name&amp;gt;default&amp;lt;/servlet-name&amp;gt;&lt;br /&gt;
    &amp;lt;servlet-class&amp;gt;org.apache.catalina.servlets.DefaultServlet&amp;lt;/servlet-class&amp;gt;&lt;br /&gt;
    &amp;lt;init-param&amp;gt;&lt;br /&gt;
      &amp;lt;param-name&amp;gt;debug&amp;lt;/param-name&amp;gt;&lt;br /&gt;
      &amp;lt;param-value&amp;gt;0&amp;lt;/param-value&amp;gt;&lt;br /&gt;
    &amp;lt;/init-param&amp;gt;&lt;br /&gt;
    &amp;lt;init-param&amp;gt;&lt;br /&gt;
      &amp;lt;param-name&amp;gt;listings&amp;lt;/param-name&amp;gt;&lt;br /&gt;
      &amp;lt;param-value&amp;gt;'''false'''&amp;lt;/param-value&amp;gt;&lt;br /&gt;
    &amp;lt;/init-param&amp;gt;&lt;br /&gt;
    &amp;lt;load-on-startup&amp;gt;1&amp;lt;/load-on-startup&amp;gt;&lt;br /&gt;
  &amp;lt;/servlet&amp;gt;&lt;br /&gt;
* Replace default HTTP error pages (i.e. 404) by adding the following into '''CATALINA_HOME'''/conf/web.xml.  The default HTTP error pages show the full Tomcat version which is unnecessary information disclosure.  ''The following solution is not ideal as it produces a blank page because Tomcat cannot find the file specified, but without a better solution this, at least, achieves the desired result.  A well configured web application will override this default in CATALINA_HOME/webapps/APP_NAME/WEB-INF/web.xml so it won't cause problems.''&lt;br /&gt;
  &amp;lt;error-page&amp;gt;&lt;br /&gt;
    &amp;lt;error-code&amp;gt;404&amp;lt;/error-code&amp;gt;&lt;br /&gt;
    &amp;lt;location&amp;gt;/404.jsp&amp;lt;/location&amp;gt;&lt;br /&gt;
  &amp;lt;/error-page&amp;gt;&lt;br /&gt;
* Replace default error page (default is stacktrace) by adding the following into '''CATALINA_HOME'''/conf/web.xml.  The default error page shows a full stacktrace which is a disclosure of sensitive information.  ''The following solution is not ideal as it produces a blank page because Tomcat cannot find the file specified, but without a better solution this, at least, achieves the desired result.  A well configured web application will override this default in CATALINA_HOME/webapps/APP_NAME/WEB-INF/web.xml so it won't cause problems.''&lt;br /&gt;
  &amp;lt;error-page&amp;gt;&lt;br /&gt;
    &amp;lt;exception-type&amp;gt;java.lang.Exception&amp;lt;/exception-type&amp;gt;&lt;br /&gt;
    &amp;lt;location&amp;gt;/error.jsp&amp;lt;/location&amp;gt;&lt;br /&gt;
  &amp;lt;/error-page&amp;gt;&lt;br /&gt;
* Consider replacing '''CATALINA_HOME'''/conf/server.xml with '''CATALINA_HOME'''/conf/server-minimal.xml - ''work out what we lose''&lt;br /&gt;
* ''is it easy to remove the version string from the server HTTP header (Apache-Coyote/1.1) ?''&lt;br /&gt;
* Start Tomcat, deploy your applications into '''CATALINA_HOME'''/webapps and hope it works!&lt;br /&gt;
&lt;br /&gt;
== Securing Manager WebApp ==&lt;br /&gt;
&lt;br /&gt;
''currently being discussed/reviewed in the talk pages''&lt;br /&gt;
&lt;br /&gt;
== Logging ==&lt;br /&gt;
&lt;br /&gt;
* TODO: Audit trails&lt;br /&gt;
&lt;br /&gt;
== User Input ==&lt;br /&gt;
&lt;br /&gt;
User data, whether it be HTTP headers or parameters, should '&amp;quot;never&amp;quot;' be trusted.  It is usually the responsibility of the application to validate data, but it is important that one poorly written application doesn't compromise Tomcat as a whole.&lt;br /&gt;
&lt;br /&gt;
* global filters&lt;br /&gt;
* global error pages (see above)&lt;br /&gt;
* permission lockdown (see below)&lt;br /&gt;
&lt;br /&gt;
== Encryption ==&lt;br /&gt;
&lt;br /&gt;
* SSL for password or other sensitive data exchange (''bordering on application security, not specific to tomcat'')&lt;br /&gt;
* SSL for connections (JDBC, LDAP, etc ..)&lt;br /&gt;
* The Tomcat documentation clearly explains how to [http://tomcat.apache.org/tomcat-5.5-doc/ssl-howto.html enable SSL.]&lt;br /&gt;
&lt;br /&gt;
== Java Security ==&lt;br /&gt;
&lt;br /&gt;
=== Running Tomcat with a Security Manager=== &lt;br /&gt;
The default Tomcat configuration provides good protection for most requirements, but does not prevent a malicious application from compromising the security of other applications running in the same instance.  To prevent this sort of attack, Tomcat can be run with a Security Manager enabled which strictly controls access to server resources.&lt;br /&gt;
Tomcat documentation has a good section on [http://tomcat.apache.org/tomcat-5.5-doc/security-manager-howto.html enabling the Security Manager.]&lt;br /&gt;
&lt;br /&gt;
== Miscellaneous ==&lt;br /&gt;
&lt;br /&gt;
* TODO: Storing cleartext passwords in configuration files (article to add)&lt;br /&gt;
&lt;br /&gt;
[[Category:OWASP Java Project]]&lt;/div&gt;</summary>
		<author><name>Dledmonds</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Talk:Securing_tomcat&amp;diff=10871</id>
		<title>Talk:Securing tomcat</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Talk:Securing_tomcat&amp;diff=10871"/>
				<updated>2006-10-20T11:38:48Z</updated>
		
		<summary type="html">&lt;p&gt;Dledmonds: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Installation ==&lt;br /&gt;
* Choose an installation directory (referenced as '''TOMCAT_DIR''' from now on), preferably on a different drive to the OS. &lt;br /&gt;
 &lt;br /&gt;
:do we get many advantages separating application and webapps? - Darren Edmonds&lt;br /&gt;
::it could prevent path traversal under windows, but not unix.  Separating apps from OS is common good practice anyway.  [[User:Stephendv|Stephendv]] 02:32, 9 October 2006 (EDT)&lt;br /&gt;
&lt;br /&gt;
== Network Security ==&lt;br /&gt;
&lt;br /&gt;
Generic advice common to all server security (link).&lt;br /&gt;
&lt;br /&gt;
:Not sure what information should go here? [[User:Stephendv|Stephendv]] 04:21, 16 October 2006 (EDT)&lt;br /&gt;
:I was thinking of a firewall discussion in relation to protecting the server.  Perhaps this should be changed to only mention the shutdown port needs protecting in tomcat [[User:dledmonds|dledmonds]]&lt;br /&gt;
&lt;br /&gt;
== User Input ==&lt;br /&gt;
&lt;br /&gt;
User data, whether it be HTTP headers or parameters, should '&amp;quot;never&amp;quot;' be trusted.  It is usually the responsibility of the application to validate data, but it is important that one poorly written application doesn't compromise Tomcat as a whole.&lt;br /&gt;
&lt;br /&gt;
* global filters&lt;br /&gt;
* global error pages (see above)&lt;br /&gt;
* permission lockdown (see below)&lt;br /&gt;
&lt;br /&gt;
:I think this section would be more appropriate for apps themselves, rather than applying to the server as a whole. [[User:Stephendv|Stephendv]] 04:24, 16 October 2006 (EDT)&lt;br /&gt;
:Agree the section doesn't seem relevant to Tomcat as it is, but I wanted to focus on preventing one webapp ruining it for everyone.   Perhaps a full rundown on java security is out of scope, but how could we prevent a poorly written download webapp from using path traversal exploits to download files of other webapps? [[User:dledmonds|dledmonds]]&lt;br /&gt;
&lt;br /&gt;
== Securing Manager WebApp ==&lt;br /&gt;
&lt;br /&gt;
* Brief description of how to create a valid manager capable user&lt;br /&gt;
* IP filtering&lt;br /&gt;
* Renaming the manager webapp&lt;/div&gt;</summary>
		<author><name>Dledmonds</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Securing_tomcat&amp;diff=10870</id>
		<title>Securing tomcat</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Securing_tomcat&amp;diff=10870"/>
				<updated>2006-10-20T11:03:13Z</updated>
		
		<summary type="html">&lt;p&gt;Dledmonds: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
Most weaknesses in [http://tomcat.apache.org/ Apache Tomcat] come from incorrect or inappropiate configuration.  It is nearly always possible to make Tomcat more secure than the default out of the box installation.  What follows documents best practices and recommendations on securing a production Tomcat server, whether it be hosted on a Windows or Unix based operating system.  ''Please note that the section ordering is not a representation of the section importance.''&lt;br /&gt;
&lt;br /&gt;
== Software Versions ==&lt;br /&gt;
&lt;br /&gt;
The first step is to make sure you are running the latest stable releases of software;&lt;br /&gt;
* Java Runtime Environment (JRE) or SDK&lt;br /&gt;
* Tomcat&lt;br /&gt;
* Third party libraries&lt;br /&gt;
This does not mean you have to upgrade all your production servers to a new (and potentially buggy) release which has just been made available to the public.  What you must do is download the latest stable bugfix release that has continual support.  For the JRE and Tomcat you should be looking at the last digits in the version number (5.5.'''X''') as it represents the bugfix information.  The bugs fixed in these releases are publicly available so if you don't upgrade you could be providing attackers with a very easy route to compromise your server.&lt;br /&gt;
&lt;br /&gt;
== Installation of Apache Tomcat 5.5 ==&lt;br /&gt;
&lt;br /&gt;
=== UNIX ===&lt;br /&gt;
&lt;br /&gt;
* Create a tomcat user/group&lt;br /&gt;
* Download and unpack the core distribution (referenced as '''CATALINA_HOME''' from now on)&lt;br /&gt;
* Change '''CATALINA_HOME''' ownership to tomcat user and tomcat group&lt;br /&gt;
* Change files in '''CATALINA_HOME'''/conf to be readonly&lt;br /&gt;
* Make sure tomcat user has read/write access to /tmp and write (yes, only write) access to '''CATALINA_HOME'''/log&lt;br /&gt;
* Change the default HTTP port to something other than 8080, by editing the Connector port attribute within the Catalina Service ('''CATALINA_HOME'''/conf/server.xml).  This ensures less scripted attacks on your server, but in no way helps protect you from vulnerabilities.&lt;br /&gt;
&lt;br /&gt;
=== Windows ===&lt;br /&gt;
&lt;br /&gt;
* Download the core windows service installer&lt;br /&gt;
* Start the installation, click ''Next'' and ''Agree'' to the licence&lt;br /&gt;
* Untick ''native'', ''documentation'', ''examples'' and ''webapps'' then click ''Next''&lt;br /&gt;
* Choose an installation directory (referenced as '''CATALINA_HOME''' from now on), preferably on a different drive to the OS.  &lt;br /&gt;
* Change the default HTTP port to something other than 8080.  This ensures less scripted attacks on your server, but in no way helps protect you from vulnerabilities. &lt;br /&gt;
* Choose an administrator username (NOT admin) and a secure password that complies with your organisations password policy.&lt;br /&gt;
* Complete tomcat installation, but do not start service.&lt;br /&gt;
* TODO: ''filesystem security''&lt;br /&gt;
&lt;br /&gt;
=== Common ===&lt;br /&gt;
&lt;br /&gt;
* Remove everything from '''CATALINA_HOME'''/webapps (ROOT, balancer, jsp-examples, servlet-examples, tomcat-docs, webdav)&lt;br /&gt;
* Remove everything from '''CATALINA_HOME'''/server/webapps (host-manager, manager).  Note that it can be useful to keep the manager webapp installed if you need the ability to redeploy without restarting Tomcat.  If you choose to keep it please read the section on Securing the Manager WebApp.&lt;br /&gt;
* Make sure the default servlet is configured '''not''' to serve index pages when a welcome file is not present.  In '''CATALINA_HOME'''/conf/web.xml&lt;br /&gt;
  &amp;lt;servlet&amp;gt;&lt;br /&gt;
    &amp;lt;servlet-name&amp;gt;default&amp;lt;/servlet-name&amp;gt;&lt;br /&gt;
    &amp;lt;servlet-class&amp;gt;org.apache.catalina.servlets.DefaultServlet&amp;lt;/servlet-class&amp;gt;&lt;br /&gt;
    &amp;lt;init-param&amp;gt;&lt;br /&gt;
      &amp;lt;param-name&amp;gt;debug&amp;lt;/param-name&amp;gt;&lt;br /&gt;
      &amp;lt;param-value&amp;gt;0&amp;lt;/param-value&amp;gt;&lt;br /&gt;
    &amp;lt;/init-param&amp;gt;&lt;br /&gt;
    &amp;lt;init-param&amp;gt;&lt;br /&gt;
      &amp;lt;param-name&amp;gt;listings&amp;lt;/param-name&amp;gt;&lt;br /&gt;
      &amp;lt;param-value&amp;gt;'''false'''&amp;lt;/param-value&amp;gt;&lt;br /&gt;
    &amp;lt;/init-param&amp;gt;&lt;br /&gt;
    &amp;lt;load-on-startup&amp;gt;1&amp;lt;/load-on-startup&amp;gt;&lt;br /&gt;
  &amp;lt;/servlet&amp;gt;&lt;br /&gt;
* Replace default HTTP error pages (i.e. 404) by adding the following into '''CATALINA_HOME'''/conf/web.xml.  The default HTTP error pages show the full Tomcat version which is unnecessary information disclosure.  ''The following solution is not ideal as it produces a blank page because Tomcat cannot find the file specified, but without a better solution this, at least, achieves the desired result.  A well configured web application will override this default in CATALINA_HOME/webapps/APP_NAME/WEB-INF/web.xml so it won't cause problems.''&lt;br /&gt;
  &amp;lt;error-page&amp;gt;&lt;br /&gt;
    &amp;lt;error-code&amp;gt;404&amp;lt;/error-code&amp;gt;&lt;br /&gt;
    &amp;lt;location&amp;gt;/404.jsp&amp;lt;/location&amp;gt;&lt;br /&gt;
  &amp;lt;/error-page&amp;gt;&lt;br /&gt;
* Replace default error page (default is stacktrace) by adding the following into '''CATALINA_HOME'''/conf/web.xml.  The default error page shows a full stacktrace which is a disclosure of sensitive information.  ''The following solution is not ideal as it produces a blank page because Tomcat cannot find the file specified, but without a better solution this, at least, achieves the desired result.  A well configured web application will override this default in CATALINA_HOME/webapps/APP_NAME/WEB-INF/web.xml so it won't cause problems.''&lt;br /&gt;
  &amp;lt;error-page&amp;gt;&lt;br /&gt;
    &amp;lt;exception-type&amp;gt;java.lang.Exception&amp;lt;/exception-type&amp;gt;&lt;br /&gt;
    &amp;lt;location&amp;gt;/error.jsp&amp;lt;/location&amp;gt;&lt;br /&gt;
  &amp;lt;/error-page&amp;gt;&lt;br /&gt;
* Consider replacing '''CATALINA_HOME'''/conf/server.xml with '''CATALINA_HOME'''/conf/server-minimal.xml - ''work out what we lose''&lt;br /&gt;
* ''is it easy to remove the version string from the server HTTP header (Apache-Coyote/1.1) ?''&lt;br /&gt;
* Start Tomcat, deploy your applications into '''CATALINA_HOME'''/webapps and hope it works!&lt;br /&gt;
&lt;br /&gt;
== Securing Manager WebApp ==&lt;br /&gt;
&lt;br /&gt;
''currently being discussed/reviewed in the talk pages''&lt;br /&gt;
&lt;br /&gt;
== Logging ==&lt;br /&gt;
&lt;br /&gt;
* TODO: Audit trails&lt;br /&gt;
&lt;br /&gt;
== User Input ==&lt;br /&gt;
&lt;br /&gt;
User data, whether it be HTTP headers or parameters, should '&amp;quot;never&amp;quot;' be trusted.  It is usually the responsibility of the application to validate data, but it is important that one poorly written application doesn't compromise Tomcat as a whole.&lt;br /&gt;
&lt;br /&gt;
* global filters&lt;br /&gt;
* global error pages (see above)&lt;br /&gt;
* permission lockdown (see below)&lt;br /&gt;
&lt;br /&gt;
== Encryption ==&lt;br /&gt;
&lt;br /&gt;
* SSL for password or other sensitive data exchange (''bordering on application security, not specific to tomcat'')&lt;br /&gt;
* SSL for connections (JDBC, LDAP, etc ..)&lt;br /&gt;
* The Tomcat documentation clearly explains how to [http://tomcat.apache.org/tomcat-5.5-doc/ssl-howto.html enable SSL.]&lt;br /&gt;
&lt;br /&gt;
== Java Security ==&lt;br /&gt;
&lt;br /&gt;
=== Running Tomcat with a Security Manager=== &lt;br /&gt;
The default Tomcat configuration provides good protection for most requirements, but does not prevent a malicious application from compromising the security of other applications running in the same instance.  To prevent this sort of attack, Tomcat can be run with a Security Manager enabled which strictly controls access to server resources.&lt;br /&gt;
Tomcat documentation has a good section on [http://tomcat.apache.org/tomcat-5.5-doc/security-manager-howto.html enabling the Security Manager.]&lt;br /&gt;
&lt;br /&gt;
== Miscellaneous ==&lt;br /&gt;
&lt;br /&gt;
* TODO: Storing cleartext passwords in configuration files (article to add)&lt;br /&gt;
&lt;br /&gt;
[[Category:OWASP Java Project]]&lt;/div&gt;</summary>
		<author><name>Dledmonds</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Securing_tomcat&amp;diff=10869</id>
		<title>Securing tomcat</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Securing_tomcat&amp;diff=10869"/>
				<updated>2006-10-20T10:37:09Z</updated>
		
		<summary type="html">&lt;p&gt;Dledmonds: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
Most weaknesses in [http://tomcat.apache.org/ Apache Tomcat] come from incorrect or inappropiate configuration.  It is nearly always possible to make Tomcat more secure than the default out of the box installation.  What follows documents best practices and recommendations on securing a production Tomcat server, whether it be hosted on a Windows or Unix based operating system.  ''Please note that the section ordering is not a representation of the section importance.''&lt;br /&gt;
&lt;br /&gt;
== Software Versions ==&lt;br /&gt;
&lt;br /&gt;
The first step is to make sure you are running the latest stable releases of software;&lt;br /&gt;
* Java Runtime Environment (JRE) or SDK&lt;br /&gt;
* Tomcat&lt;br /&gt;
* Third party libraries&lt;br /&gt;
This does not mean you have to upgrade all your production servers to a new (and potentially buggy) release which has just been made available to the public.  What you must do is download the latest stable bugfix release that has continual support.  For the JRE and Tomcat you should be looking at the last digits in the version number (5.5.'''X''') as it represents the bugfix information.  The bugs fixed in these releases are publicly available so if you don't upgrade you could be providing attackers with a very easy route to compromise your server.&lt;br /&gt;
&lt;br /&gt;
== Installation of Apache Tomcat 5.5 ==&lt;br /&gt;
&lt;br /&gt;
=== UNIX ===&lt;br /&gt;
&lt;br /&gt;
* Create a tomcat user/group&lt;br /&gt;
* Download and unpack the core distribution (referenced as '''CATALINA_HOME''' from now on)&lt;br /&gt;
* Change '''CATALINA_HOME''' ownership to tomcat user and tomcat group&lt;br /&gt;
* Change files in '''CATALINA_HOME'''/conf to be readonly&lt;br /&gt;
* Make sure tomcat user has read/write access to /tmp and write (yes, only write) access to '''CATALINA_HOME'''/log&lt;br /&gt;
* Change the default HTTP port to something other than 8080, by editing the Connector port attribute within the Catalina Service ('''CATALINA_HOME'''/conf/server.xml).  This ensures less scripted attacks on your server, but in no way helps protect you from vulnerabilities.&lt;br /&gt;
&lt;br /&gt;
=== Windows ===&lt;br /&gt;
&lt;br /&gt;
* Download the core windows service installer&lt;br /&gt;
* Start the installation, click ''Next'' and ''Agree'' to the licence&lt;br /&gt;
* Untick ''native'', ''documentation'', ''examples'' and ''webapps'' then click ''Next''&lt;br /&gt;
* Choose an installation directory (referenced as '''CATALINA_HOME''' from now on), preferably on a different drive to the OS.  &lt;br /&gt;
* Change the default HTTP port to something other than 8080.  This ensures less scripted attacks on your server, but in no way helps protect you from vulnerabilities. &lt;br /&gt;
* Choose an administrator username (NOT admin) and a secure password that complies with your organisations password policy.&lt;br /&gt;
* Complete tomcat installation, but do not start service.&lt;br /&gt;
* TODO: ''filesystem security''&lt;br /&gt;
&lt;br /&gt;
=== Common ===&lt;br /&gt;
&lt;br /&gt;
* Remove everything from '''CATALINA_HOME'''/webapps (ROOT, balancer, jsp-examples, servlet-examples, tomcat-docs, webdav)&lt;br /&gt;
* Remove everything from '''CATALINA_HOME'''/server/webapps (host-manager, manager)&lt;br /&gt;
* Make sure the default servlet is configured '''not''' to serve index pages when a welcome file is not present.  In '''CATALINA_HOME'''/conf/web.xml&lt;br /&gt;
  &amp;lt;servlet&amp;gt;&lt;br /&gt;
    &amp;lt;servlet-name&amp;gt;default&amp;lt;/servlet-name&amp;gt;&lt;br /&gt;
    &amp;lt;servlet-class&amp;gt;org.apache.catalina.servlets.DefaultServlet&amp;lt;/servlet-class&amp;gt;&lt;br /&gt;
    &amp;lt;init-param&amp;gt;&lt;br /&gt;
      &amp;lt;param-name&amp;gt;debug&amp;lt;/param-name&amp;gt;&lt;br /&gt;
      &amp;lt;param-value&amp;gt;0&amp;lt;/param-value&amp;gt;&lt;br /&gt;
    &amp;lt;/init-param&amp;gt;&lt;br /&gt;
    &amp;lt;init-param&amp;gt;&lt;br /&gt;
      &amp;lt;param-name&amp;gt;listings&amp;lt;/param-name&amp;gt;&lt;br /&gt;
      &amp;lt;param-value&amp;gt;'''false'''&amp;lt;/param-value&amp;gt;&lt;br /&gt;
    &amp;lt;/init-param&amp;gt;&lt;br /&gt;
    &amp;lt;load-on-startup&amp;gt;1&amp;lt;/load-on-startup&amp;gt;&lt;br /&gt;
  &amp;lt;/servlet&amp;gt;&lt;br /&gt;
* Replace default HTTP error pages (i.e. 404) by adding the following into '''CATALINA_HOME'''/conf/web.xml.  The default HTTP error pages show the full Tomcat version which is unnecessary information disclosure.  ''The following solution is not ideal as it produces a blank page because Tomcat cannot find the file specified, but without a better solution this, at least, achieves the desired result.  A well configured web application will override this default in CATALINA_HOME/webapps/APP_NAME/WEB-INF/web.xml so it won't cause problems.''&lt;br /&gt;
  &amp;lt;error-page&amp;gt;&lt;br /&gt;
    &amp;lt;error-code&amp;gt;404&amp;lt;/error-code&amp;gt;&lt;br /&gt;
    &amp;lt;location&amp;gt;/404.jsp&amp;lt;/location&amp;gt;&lt;br /&gt;
  &amp;lt;/error-page&amp;gt;&lt;br /&gt;
* Replace default error page (default is stacktrace) by adding the following into '''CATALINA_HOME'''/conf/web.xml.  The default error page shows a full stacktrace which is a disclosure of sensitive information.  ''The following solution is not ideal as it produces a blank page because Tomcat cannot find the file specified, but without a better solution this, at least, achieves the desired result.  A well configured web application will override this default in CATALINA_HOME/webapps/APP_NAME/WEB-INF/web.xml so it won't cause problems.''&lt;br /&gt;
  &amp;lt;error-page&amp;gt;&lt;br /&gt;
    &amp;lt;exception-type&amp;gt;java.lang.Exception&amp;lt;/exception-type&amp;gt;&lt;br /&gt;
    &amp;lt;location&amp;gt;/error.jsp&amp;lt;/location&amp;gt;&lt;br /&gt;
  &amp;lt;/error-page&amp;gt;&lt;br /&gt;
* Consider replacing '''CATALINA_HOME'''/conf/server.xml with '''CATALINA_HOME'''/conf/server-minimal.xml - ''work out what we lose''&lt;br /&gt;
* ''is it easy to remove the version string from the server HTTP header (Apache-Coyote/1.1) ?''&lt;br /&gt;
* Start Tomcat, deploy your applications into '''CATALINA_HOME'''/webapps and hope it works!&lt;br /&gt;
&lt;br /&gt;
== Logging ==&lt;br /&gt;
&lt;br /&gt;
* TODO: Audit trails&lt;br /&gt;
&lt;br /&gt;
== User Input ==&lt;br /&gt;
&lt;br /&gt;
User data, whether it be HTTP headers or parameters, should '&amp;quot;never&amp;quot;' be trusted.  It is usually the responsibility of the application to validate data, but it is important that one poorly written application doesn't compromise Tomcat as a whole.&lt;br /&gt;
&lt;br /&gt;
* global filters&lt;br /&gt;
* global error pages (see above)&lt;br /&gt;
* permission lockdown (see below)&lt;br /&gt;
&lt;br /&gt;
== Encryption ==&lt;br /&gt;
&lt;br /&gt;
* SSL for password or other sensitive data exchange (''bordering on application security, not specific to tomcat'')&lt;br /&gt;
* SSL for connections (JDBC, LDAP, etc ..)&lt;br /&gt;
* The Tomcat documentation clearly explains how to [http://tomcat.apache.org/tomcat-5.5-doc/ssl-howto.html enable SSL.]&lt;br /&gt;
&lt;br /&gt;
== Java Security ==&lt;br /&gt;
&lt;br /&gt;
=== Running Tomcat with a Security Manager=== &lt;br /&gt;
The default Tomcat configuration provides good protection for most requirements, but does not prevent a malicious application from compromising the security of other applications running in the same instance.  To prevent this sort of attack, Tomcat can be run with a Security Manager enabled which strictly controls access to server resources.&lt;br /&gt;
Tomcat documentation has a good section on [http://tomcat.apache.org/tomcat-5.5-doc/security-manager-howto.html enabling the Security Manager.]&lt;br /&gt;
&lt;br /&gt;
== Miscellaneous ==&lt;br /&gt;
&lt;br /&gt;
* TODO: Storing cleartext passwords in configuration files (article to add)&lt;br /&gt;
&lt;br /&gt;
[[Category:OWASP Java Project]]&lt;/div&gt;</summary>
		<author><name>Dledmonds</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Talk:Securing_tomcat&amp;diff=10223</id>
		<title>Talk:Securing tomcat</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Talk:Securing_tomcat&amp;diff=10223"/>
				<updated>2006-10-06T17:18:49Z</updated>
		
		<summary type="html">&lt;p&gt;Dledmonds: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
Most weaknesses in [http://tomcat.apache.org/ Apache Tomcat] come from incorrect or inappropiate configuration.  It is nearly always possible to make Tomcat more secure than the default out of the box installation.  What follows documents best practices and recommendations on securing a production Tomcat server, whether it be hosted on a Windows or Unix based operating system.  ''Please note that the section ordering is not a representation of the section importance.''&lt;br /&gt;
&lt;br /&gt;
== Software Versions ==&lt;br /&gt;
&lt;br /&gt;
The first step is to make sure you are running the latest stable releases of software;&lt;br /&gt;
* Java Runtime Environment (JRE) or SDK&lt;br /&gt;
* Tomcat&lt;br /&gt;
* Third party libraries&lt;br /&gt;
This does not mean you have to upgrade all your production servers to a new (and potentially buggy) release which has just been made available to the public.  What you must do is download the latest stable bugfix release that has continual support.  For the JRE and Tomcat you should be looking at the last digits in the version number (5.5.'''X''') as it represents the bugfix information.  The bugs fixed in these releases are publicly available so if you don't upgrade you could be providing attackers with a very easy route to compromise your server.&lt;br /&gt;
&lt;br /&gt;
== Installation of Apache Tomcat 5.5 ==&lt;br /&gt;
&lt;br /&gt;
=== UNIX ===&lt;br /&gt;
&lt;br /&gt;
* Create a tomcat user/group&lt;br /&gt;
* Download and unpack the core distribution (referenced as '''TOMCAT_DIR''' from now on)&lt;br /&gt;
* Change '''TOMCAT_DIR''' ownership to tomcat user and tomcat group&lt;br /&gt;
* Change files in '''TOMCAT_DIR'''/conf to be readonly&lt;br /&gt;
* Make sure tomcat user has read/write access to /tmp and write (yes, only write) access to '''TOMCAT_DIR'''/log&lt;br /&gt;
* Change the default HTTP port to something other than 8080, by editing the Connector port attribute within the Catalina Service ('''TOMCAT_DIR'''/conf/server.xml).  This ensures less scripted attacks on your server, but in no way helps protect you from vulnerabilities.&lt;br /&gt;
&lt;br /&gt;
=== Windows ===&lt;br /&gt;
&lt;br /&gt;
* Download the core windows service installer&lt;br /&gt;
* Start the installation, click ''Next'' and ''Agree'' to the licence&lt;br /&gt;
* Untick ''native'', ''documentation'', ''examples'' and ''webapps'' then click ''Next''&lt;br /&gt;
* Choose an installation directory (referenced as '''TOMCAT_DIR''' from now on), preferably on a different drive to the OS.  ''do we get many advantages separating application and webapps?''&lt;br /&gt;
* Change the default HTTP port to something other than 8080.  This ensures less scripted attacks on your server, but in no way helps protect you from vulnerabilities.&lt;br /&gt;
* Choose an administrator username (NOT admin) and a secure password.&lt;br /&gt;
* Complete tomcat installation, but do not start service.&lt;br /&gt;
* ''filesystem security need documenting''&lt;br /&gt;
&lt;br /&gt;
=== Common ===&lt;br /&gt;
&lt;br /&gt;
* Remove everything from '''TOMCAT_DIR'''/webapps (ROOT, balancer, jsp-examples, servlet-examples, tomcat-docs, webdav)&lt;br /&gt;
* Remove everything from '''TOMCAT_DIR'''/server/webapps (host-manager, manager)&lt;br /&gt;
* Replace default HTTP error pages (i.e. 404) ''can we specify a container wide location?''&lt;br /&gt;
  &amp;lt;error-page&amp;gt;&lt;br /&gt;
    &amp;lt;error-code&amp;gt;404&amp;lt;/error-code&amp;gt;&lt;br /&gt;
    &amp;lt;location&amp;gt;/404.jsp&amp;lt;/location&amp;gt;&lt;br /&gt;
  &amp;lt;/error-page&amp;gt;&lt;br /&gt;
* Replace default error page (default is stacktrace) ''can we specify a container wide location?''&lt;br /&gt;
  &amp;lt;error-page&amp;gt;&lt;br /&gt;
    &amp;lt;exception-type&amp;gt;java.lang.Exception&amp;lt;/exception-type&amp;gt;&lt;br /&gt;
    &amp;lt;location&amp;gt;/error.jsp&amp;lt;/location&amp;gt;&lt;br /&gt;
  &amp;lt;/error-page&amp;gt;&lt;br /&gt;
* Consider replacing '''TOMCAT_DIR'''/conf/server.xml with '''TOMCAT_DIR'''/conf/server-minimal.xml - ''work out what we lose''&lt;br /&gt;
* ''is it easy to remove the version string from the server HTTP header (Apache-Coyote/1.1) ?''&lt;br /&gt;
* Start Tomcat, deploy your applications into '''TOMCAT_DIR'''/webapps and hope it works!&lt;br /&gt;
&lt;br /&gt;
== Network Security ==&lt;br /&gt;
&lt;br /&gt;
Generic advice common to all server security (link).&lt;br /&gt;
&lt;br /&gt;
== Logging ==&lt;br /&gt;
&lt;br /&gt;
* Audit trails&lt;br /&gt;
&lt;br /&gt;
== User Input ==&lt;br /&gt;
&lt;br /&gt;
User data, whether it be HTTP headers or parameters, should '&amp;quot;never&amp;quot;' be trusted.  It is usually the responsibility of the application to validate data, but it is important that one poorly written application doesn't compromise Tomcat as a whole.&lt;br /&gt;
&lt;br /&gt;
* global filters&lt;br /&gt;
* global error pages (see above)&lt;br /&gt;
* permission lockdown (see below)&lt;br /&gt;
&lt;br /&gt;
== Encryption ==&lt;br /&gt;
&lt;br /&gt;
* SSL for password or other sensitive data exchange (''bordering on application security, not specific to tomcat'')&lt;br /&gt;
* SSL for connections (JDBC, LDAP, etc ..)&lt;br /&gt;
&lt;br /&gt;
== Java Security ==&lt;br /&gt;
&lt;br /&gt;
* Running default tomcat with a security manager&lt;br /&gt;
* Locking down web application permissions&lt;br /&gt;
&lt;br /&gt;
== Miscellaneous ==&lt;br /&gt;
&lt;br /&gt;
* Storing cleartext passwords in configuration files (article to add)&lt;/div&gt;</summary>
		<author><name>Dledmonds</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=OWASP_Java_Project_Roadmap&amp;diff=10222</id>
		<title>OWASP Java Project Roadmap</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=OWASP_Java_Project_Roadmap&amp;diff=10222"/>
				<updated>2006-10-06T17:17:12Z</updated>
		
		<summary type="html">&lt;p&gt;Dledmonds: /* Securing Popular J2EE Servers */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Goals==&lt;br /&gt;
&lt;br /&gt;
The OWASP Java Project's overall goal is to...&lt;br /&gt;
&lt;br /&gt;
 Produce materials that show J2EE architects, developers, and&lt;br /&gt;
 deployers how to deal with most common application security&lt;br /&gt;
 problems throughout the lifecycle.&lt;br /&gt;
&lt;br /&gt;
In the near term, we are focused on the following tactical goals:&lt;br /&gt;
&lt;br /&gt;
# Provide examples of how to prevent Cross Site Scripting attacks in popular web frameworks&lt;br /&gt;
# Provide examples of how to prevent SQL Injection in popular data access frameworks&lt;br /&gt;
# Provide examples of how to prevent LDAP injection in Java&lt;br /&gt;
# A practical guide to implementing a security policy for a Java web application&lt;br /&gt;
# Secure configuration guides for popular application servers&lt;br /&gt;
&lt;br /&gt;
==Current Tasks==&lt;br /&gt;
* Call for volunteers - Join the [http://lists.owasp.org/mailman/listinfo/java-project mailing list], read the [[Tutorial]] and get started!&lt;br /&gt;
* Refine this roadmap in the [http://www.owasp.org/index.php/Talk:OWASP_Java_Project_Roadmap discussion]. &lt;br /&gt;
&lt;br /&gt;
==Ideas==&lt;br /&gt;
&lt;br /&gt;
Please submit your ideas for the OWASP Java Project here (you can sign your ideas by adding four tilde characters like this &amp;lt;nowiki&amp;gt;~~~~&amp;lt;/nowiki&amp;gt;)&lt;br /&gt;
* It would be useful to have a library of J2EE security resources on the web.  In addition to URLs, I think these should have short summaries that explain what the resource is about.  I've clicked on far too many &amp;quot;J2EE Security&amp;quot; links only to find that the article is about implementing access control in Tomcat.&lt;br /&gt;
* A tool that automatically generates a security policy for a given application could be useful.  The tool is first run in learning mode where it maps all the accesses that the application attempts and then generates a policy based on those access attempts. Status: tool sent to Stephen.&lt;br /&gt;
&lt;br /&gt;
==[[J2EE Security for Architects]]==&lt;br /&gt;
&lt;br /&gt;
===Design considerations===&lt;br /&gt;
&amp;lt;table border=1 cellpadding=5&amp;gt;&lt;br /&gt;
  &amp;lt;tr&amp;gt;&amp;lt;td valign=&amp;quot;top&amp;quot;&amp;gt;&amp;lt;b&amp;gt;Objective:&amp;lt;/b&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Discuss the security implications of common J2EE architectures.  This could be discussed in terms of: Authentication, Authorisation, Data Validation, Cross Site Scripting protection.  Other architecture concerns such as scalability, performance and maintainability can also be mentioned, but the focus on security should not be lost.&lt;br /&gt;
  &lt;br /&gt;
  Any other security concerns that should be addressed during the design phase should also be mentioned here.&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
  &amp;lt;tr&amp;gt;&amp;lt;td valign=&amp;quot;top&amp;quot;&amp;gt;&amp;lt;b&amp;gt;Status:&amp;lt;/b&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Call for volunteers&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
  &amp;lt;tr&amp;gt;&amp;lt;td valign=&amp;quot;top&amp;quot;&amp;gt;&amp;lt;b&amp;gt;Contributors:&amp;lt;/b&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
  &amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;&amp;lt;b&amp;gt;Reviewers:&amp;lt;/b&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
* Architectural considerations&lt;br /&gt;
** EJB Middle tier&lt;br /&gt;
** Web Services Middle tier&lt;br /&gt;
** Spring Middle tier&lt;br /&gt;
&lt;br /&gt;
===Noteworthy Frameworks===&lt;br /&gt;
&amp;lt;table border=1 cellpadding=5&amp;gt;&lt;br /&gt;
  &amp;lt;tr&amp;gt;&amp;lt;td valign=&amp;quot;top&amp;quot;&amp;gt;&amp;lt;b&amp;gt;Objective:&amp;lt;/b&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Discuss important and relevant Java security frameworks that would be useful to architects.  The information should be at a suitably high level, for example, by discussing the advantages and features as well as the associated costs (direct and indirect) of using the frameworks.&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td valign=&amp;quot;top&amp;quot;&amp;gt;&amp;lt;b&amp;gt;Status:&amp;lt;/b&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Comparison of Frameworks in progress&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
  &amp;lt;tr&amp;gt;&amp;lt;td valign=&amp;quot;top&amp;quot;&amp;gt;&amp;lt;b&amp;gt;Contributors: &amp;lt;/b&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Claire McDonough, Ranjita Shankar Iyer&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
  &amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;&amp;lt;b&amp;gt;Reviewers: &amp;lt;/b&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Rohyt Belani, Stephen De Vries&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt; &lt;br /&gt;
1.	Struts &lt;br /&gt;
2.	Turbine&lt;br /&gt;
3.	JFS (MyFaces)&lt;br /&gt;
4.	Tapestry&lt;br /&gt;
5.	Webwork&lt;br /&gt;
6.	Cocoon&lt;br /&gt;
7.	Tiles&lt;br /&gt;
8.	SiteMesh&lt;br /&gt;
9.	Spring&lt;br /&gt;
&lt;br /&gt;
==[[J2EE Security for Developers]]==&lt;br /&gt;
&lt;br /&gt;
===Java Security Basics===&lt;br /&gt;
&amp;lt;table border=1 cellpadding=5&amp;gt;&lt;br /&gt;
  &amp;lt;tr&amp;gt;&amp;lt;td valign=&amp;quot;top&amp;quot;&amp;gt;&amp;lt;b&amp;gt;Objective:&amp;lt;/b&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Provide an introduction into the basic security services provided by the Java language and environment.  Remember to keep this relevant for web developers for the initial release - there may be a potential to expand this to thick clients in subsequent releases.&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
  &amp;lt;tr&amp;gt;&amp;lt;td valign=&amp;quot;top&amp;quot;&amp;gt;&amp;lt;b&amp;gt;Status:&amp;lt;/b&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Outline development&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td valign=&amp;quot;top&amp;quot;&amp;gt;&amp;lt;b&amp;gt;Contributors:&amp;lt;/b&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Shyaam Sundhar&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
  &amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;&amp;lt;b&amp;gt;Reviewers:&amp;lt;/b&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Rohyt Belani, Stephen De Vries&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
* Class Loading&lt;br /&gt;
* Bytecode verifier&lt;br /&gt;
* The Security Manager and security.policy file&lt;br /&gt;
&lt;br /&gt;
===Input Validation===&lt;br /&gt;
* Overview&lt;br /&gt;
* Dangerous calls (BufferedReader.readLine(), ServletRequest.getParameter(), etc...)&lt;br /&gt;
&lt;br /&gt;
==== SQL Injection====&lt;br /&gt;
&amp;lt;table border=1 cellpadding=5&amp;gt;&lt;br /&gt;
  &amp;lt;tr&amp;gt;&amp;lt;td valign=&amp;quot;top&amp;quot;&amp;gt;&amp;lt;b&amp;gt;Objective:&amp;lt;/b&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Provide cursory background information on SQL injection and refer to the Guide for more indepth coverage (no need to duplicate info in the Guide).  This section should provide practical advise and real-world code examples for developers. If you feel that a popular persistence framework is not covered, please add it!&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
  &amp;lt;tr&amp;gt;&amp;lt;td valign=&amp;quot;top&amp;quot;&amp;gt;&amp;lt;b&amp;gt;Status:&amp;lt;/b&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Work is underway&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
  &amp;lt;tr&amp;gt;&amp;lt;td valign=&amp;quot;top&amp;quot;&amp;gt;&amp;lt;b&amp;gt;Contributors:&amp;lt;/b&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;[[User:Stephendv|Stephendv]], Joe Kumar&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
  &amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;&amp;lt;b&amp;gt;Reviewers:&amp;lt;/b&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
* Overview&lt;br /&gt;
* Prevention&lt;br /&gt;
** White Listing&lt;br /&gt;
** Prepared Statements&lt;br /&gt;
** Stored Procedures &lt;br /&gt;
** Hibernate &lt;br /&gt;
** Ibatis &lt;br /&gt;
** Spring JDBC &lt;br /&gt;
** EJB 3.0&lt;br /&gt;
** JDO&lt;br /&gt;
&lt;br /&gt;
====Cross Site Scripting (XSS)====&lt;br /&gt;
&amp;lt;table border=1 cellpadding=5&amp;gt;&lt;br /&gt;
  &amp;lt;tr&amp;gt;&amp;lt;td valign=&amp;quot;top&amp;quot;&amp;gt;&amp;lt;b&amp;gt;Objective:&amp;lt;/b&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Provide cursory background information on XSS and refer to the Guide for more indepth coverage.  This section should provide practical advise and real-world code examples for developers.  If you would like to see coverage of a web framework that's not listed, please add it!&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td valign=&amp;quot;top&amp;quot;&amp;gt;&amp;lt;b&amp;gt;Status:&amp;lt;/b&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Call for volunteers&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;  &lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td valign=&amp;quot;top&amp;quot;&amp;gt;&amp;lt;b&amp;gt;Contributors:&amp;lt;/b&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
  &amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;&amp;lt;b&amp;gt;Reviewers:&amp;lt;/b&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
* Overview&lt;br /&gt;
* Prevention&lt;br /&gt;
** White Listing &lt;br /&gt;
** Manual HTML Encoding&lt;br /&gt;
** Preventing XSS in popular Web Frameworks&lt;br /&gt;
*** JSP/JSTL&lt;br /&gt;
*** Struts&lt;br /&gt;
*** Spring MVC&lt;br /&gt;
*** Java Server Faces&lt;br /&gt;
*** WebWork&lt;br /&gt;
*** Wicket&lt;br /&gt;
*** Tapestry &lt;br /&gt;
* CSRF attack&lt;br /&gt;
&lt;br /&gt;
==== LDAP Injection ====&lt;br /&gt;
&amp;lt;table border=1 cellpadding=5&amp;gt;&lt;br /&gt;
  &amp;lt;tr&amp;gt;&amp;lt;td valign=&amp;quot;top&amp;quot;&amp;gt;&amp;lt;b&amp;gt;Objective:&amp;lt;/b&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;As with the other Injection sections, only provide cursory information on the general case. Should contain practical real-world advise and code examples for preventing LDAP injection.&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td valign=&amp;quot;top&amp;quot;&amp;gt;&amp;lt;b&amp;gt;Status:&amp;lt;/b&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Call for volunteers&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;  &lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td valign=&amp;quot;top&amp;quot;&amp;gt;&amp;lt;b&amp;gt;Contributors:&amp;lt;/b&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;[[User:Stephendv|Stephendv]]&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
  &amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;&amp;lt;b&amp;gt;Reviewers:&amp;lt;/b&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
* Overview&lt;br /&gt;
* Prevention&lt;br /&gt;
&lt;br /&gt;
==== XPATH Injection ====&lt;br /&gt;
&amp;lt;table border=1 cellpadding=5&amp;gt;&lt;br /&gt;
  &amp;lt;tr&amp;gt;&amp;lt;td valign=&amp;quot;top&amp;quot;&amp;gt;&amp;lt;b&amp;gt;Objective:&amp;lt;/b&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;As with the other Injection sections, only provide cursory information on the general case. Should contain practical real-world advise and code examples for preventing XPATH injection.&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td valign=&amp;quot;top&amp;quot;&amp;gt;&amp;lt;b&amp;gt;Status:&amp;lt;/b&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Call for volunteers&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
  &amp;lt;tr&amp;gt;&amp;lt;td valign=&amp;quot;top&amp;quot;&amp;gt;&amp;lt;b&amp;gt;Contributors:&amp;lt;/b&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
  &amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;&amp;lt;b&amp;gt;Reviewers:&amp;lt;/b&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
* Overview&lt;br /&gt;
* Prevention&lt;br /&gt;
&lt;br /&gt;
==== Miscellaneous Injection Attacks ====&lt;br /&gt;
&amp;lt;table border=1 cellpadding=5&amp;gt;&lt;br /&gt;
  &amp;lt;tr&amp;gt;&amp;lt;td valign=&amp;quot;top&amp;quot;&amp;gt;&amp;lt;b&amp;gt;Objective:&amp;lt;/b&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Should contain practical real-world advise and code examples.&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td valign=&amp;quot;top&amp;quot;&amp;gt;&amp;lt;b&amp;gt;Status:&amp;lt;/b&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Call for volunteers&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
  &amp;lt;tr&amp;gt;&amp;lt;td valign=&amp;quot;top&amp;quot;&amp;gt;&amp;lt;b&amp;gt;Contributors:&amp;lt;/b&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
  &amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;&amp;lt;b&amp;gt;Reviewers:&amp;lt;/b&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
* HTTP Response splitting&lt;br /&gt;
* Command injection - Runtime.getRuntime().exec()&lt;br /&gt;
&lt;br /&gt;
=== Authentication===&lt;br /&gt;
&amp;lt;table border=1 cellpadding=5&amp;gt;&lt;br /&gt;
  &amp;lt;tr&amp;gt;&amp;lt;td valign=&amp;quot;top&amp;quot;&amp;gt;&amp;lt;b&amp;gt;Objective:&amp;lt;/b&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Discuss authentication for Java and J2EE apps under the suggested headings below.  Examples for container managed authentication of specific application servers are also welcome.&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td valign=&amp;quot;top&amp;quot;&amp;gt;&amp;lt;b&amp;gt;Status:&amp;lt;/b&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Call for volunteers&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
  &amp;lt;tr&amp;gt;&amp;lt;td valign=&amp;quot;top&amp;quot;&amp;gt;&amp;lt;b&amp;gt;Contributors:&amp;lt;/b&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Dave Ferguson, Michel Prunet, Adrian San Juan, Philippe Curmin&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
  &amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;&amp;lt;b&amp;gt;Reviewers:&amp;lt;/b&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
* Storing credentials - Adrian San Juan&lt;br /&gt;
* [[Hashing Java|Hashing]] - Michel Prunet&lt;br /&gt;
* SSL Best Practices - Philippe Curmin is working on it. This topic shall include the following points:&lt;br /&gt;
**What is SSL&lt;br /&gt;
**How SSL is implemented in J2EE&lt;br /&gt;
**HTTPS best practices in general&lt;br /&gt;
**HTTPS best practices in J2EE&lt;br /&gt;
**Examples with Tomcat&lt;br /&gt;
**Examples with JBoss.&lt;br /&gt;
* [[Using JCaptcha]]  &lt;br /&gt;
* Container-managed authentication with Realms&lt;br /&gt;
** [[Declarative Access Control in Java]]&lt;br /&gt;
* JAAS Authentication&lt;br /&gt;
* Password length &amp;amp; complexity - Adrian San Juan&lt;br /&gt;
&lt;br /&gt;
===Session Management===&lt;br /&gt;
&amp;lt;table border=1 cellpadding=5&amp;gt;&lt;br /&gt;
  &amp;lt;tr&amp;gt;&amp;lt;td valign=&amp;quot;top&amp;quot;&amp;gt;&amp;lt;b&amp;gt;Objective:&amp;lt;/b&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;The generic problems and solutions for session management are covered in the Guide.  This section should focus on Java specific examples.  &amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
  &amp;lt;tr&amp;gt;&amp;lt;td valign=&amp;quot;top&amp;quot;&amp;gt;&amp;lt;b&amp;gt;Status:&amp;lt;/b&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Call for volunteers&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td valign=&amp;quot;top&amp;quot;&amp;gt;&amp;lt;b&amp;gt;Contributors:&amp;lt;/b&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
  &amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;&amp;lt;b&amp;gt;Reviewers:&amp;lt;/b&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
* Logout&lt;br /&gt;
* Session Timeout&lt;br /&gt;
* Absolute Timeout&lt;br /&gt;
* Session Fixation&lt;br /&gt;
* Terminating sessions&lt;br /&gt;
** Terminating sessions when the browser window is closed&lt;br /&gt;
&lt;br /&gt;
===Authorization===&lt;br /&gt;
&amp;lt;table border=1 cellpadding=5&amp;gt;&lt;br /&gt;
  &amp;lt;tr&amp;gt;&amp;lt;td valign=&amp;quot;top&amp;quot;&amp;gt;&amp;lt;b&amp;gt;Objective:&amp;lt;/b&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Java and J2EE specific discussion and examples.&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
  &amp;lt;tr&amp;gt;&amp;lt;td valign=&amp;quot;top&amp;quot;&amp;gt;&amp;lt;b&amp;gt;Status:&amp;lt;/b&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Call for volunteers&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td valign=&amp;quot;top&amp;quot;&amp;gt;&amp;lt;b&amp;gt;Contributors:&amp;lt;/b&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
  &amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;&amp;lt;b&amp;gt;Reviewers:&amp;lt;/b&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
* In presentation layer&lt;br /&gt;
* In business logic&lt;br /&gt;
* In data layer&lt;br /&gt;
* Declarative v/s Programmatic&lt;br /&gt;
* web.xml configuration - [[Declarative Access Control in Java]]&lt;br /&gt;
* [[Forced browsing]]&lt;br /&gt;
* JAAS&lt;br /&gt;
* EJB Authorization&lt;br /&gt;
* Acegi&lt;br /&gt;
* JACC&lt;br /&gt;
* Check horizontal privilege&lt;br /&gt;
&lt;br /&gt;
=== Encryption===&lt;br /&gt;
&amp;lt;table border=1 cellpadding=5&amp;gt;&lt;br /&gt;
  &amp;lt;tr&amp;gt;&amp;lt;td valign=&amp;quot;top&amp;quot;&amp;gt;&amp;lt;b&amp;gt;Objective:&amp;lt;/b&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Java and J2EE specific discussion and examples.&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
  &amp;lt;tr&amp;gt;&amp;lt;td valign=&amp;quot;top&amp;quot;&amp;gt;&amp;lt;b&amp;gt;Status:&amp;lt;/b&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Call for volunteers&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td valign=&amp;quot;top&amp;quot;&amp;gt;&amp;lt;b&amp;gt;Contributors:&amp;lt;/b&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
  &amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;&amp;lt;b&amp;gt;Reviewers:&amp;lt;/b&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
* JCE&lt;br /&gt;
* Storing db secrets&lt;br /&gt;
* Encrypting JDBC connections&lt;br /&gt;
* JSSE&lt;br /&gt;
* Random number generation&lt;br /&gt;
&lt;br /&gt;
=== Error Handling &amp;amp; Logging===&lt;br /&gt;
&amp;lt;table border=1 cellpadding=5&amp;gt;&lt;br /&gt;
  &amp;lt;tr&amp;gt;&amp;lt;td valign=&amp;quot;top&amp;quot;&amp;gt;&amp;lt;b&amp;gt;Objective:&amp;lt;/b&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Java and J2EE specific discussion and examples.&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
  &amp;lt;tr&amp;gt;&amp;lt;td valign=&amp;quot;top&amp;quot;&amp;gt;&amp;lt;b&amp;gt;Status:&amp;lt;/b&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Call for volunteers&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td valign=&amp;quot;top&amp;quot;&amp;gt;&amp;lt;b&amp;gt;Contributors:&amp;lt;/b&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
  &amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;&amp;lt;b&amp;gt;Reviewers:&amp;lt;/b&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
* Output Validation&lt;br /&gt;
* Custom Errors&lt;br /&gt;
* Logging - why log? what to log? log4j, etc.&lt;br /&gt;
* Exception handling techniques&lt;br /&gt;
** fail-open/fail-closed&lt;br /&gt;
** resource cleanup&lt;br /&gt;
** finally block&lt;br /&gt;
** swallowing exceptions&lt;br /&gt;
* Exception handling frameworks&lt;br /&gt;
** Servlet spec - web.xml&lt;br /&gt;
** JSP errorPage&lt;br /&gt;
* Web application forensics&lt;br /&gt;
&lt;br /&gt;
=== Web Services Security ===&lt;br /&gt;
&amp;lt;table border=1 cellpadding=5&amp;gt;&lt;br /&gt;
  &amp;lt;tr&amp;gt;&amp;lt;td valign=&amp;quot;top&amp;quot;&amp;gt;&amp;lt;b&amp;gt;Objective:&amp;lt;/b&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Discuss securely implementing Web Services using Java technologies.  Examples using specific frameworks are welcome.  The topic list is a bit light at the moment, please add more topics if they're relevant.&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
  &amp;lt;tr&amp;gt;&amp;lt;td valign=&amp;quot;top&amp;quot;&amp;gt;&amp;lt;b&amp;gt;Status:&amp;lt;/b&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Call for volunteers&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td valign=&amp;quot;top&amp;quot;&amp;gt;&amp;lt;b&amp;gt;Contributors:&amp;lt;/b&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
  &amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;&amp;lt;b&amp;gt;Reviewers:&amp;lt;/b&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
* SAML&lt;br /&gt;
* (X)WS-Security&lt;br /&gt;
* SunJWSDP&lt;br /&gt;
* XML Signature (JSR 105)&lt;br /&gt;
* XML Encryption (JSR 106)&lt;br /&gt;
&lt;br /&gt;
=== Code Analysis Tools ===&lt;br /&gt;
&amp;lt;table border=1 cellpadding=5&amp;gt;&lt;br /&gt;
  &amp;lt;tr&amp;gt;&amp;lt;td valign=&amp;quot;top&amp;quot;&amp;gt;&amp;lt;b&amp;gt;Objective:&amp;lt;/b&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;The introduction should cover the advantages and short comings of code analysis tools.  An overview of the current state of the art and the available tools would go well here.  As a start, only open source tools are listed, but if vendors of commercial tools adhere to the [[Tutorial]] guidelines, these submissions will be gladly received.&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
  &amp;lt;tr&amp;gt;&amp;lt;td valign=&amp;quot;top&amp;quot;&amp;gt;&amp;lt;b&amp;gt;Status:&amp;lt;/b&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Call for volunteers&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td valign=&amp;quot;top&amp;quot;&amp;gt;&amp;lt;b&amp;gt;Contributors:&amp;lt;/b&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
  &amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;&amp;lt;b&amp;gt;Reviewers:&amp;lt;/b&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
* Introduction&lt;br /&gt;
* FindBugs&lt;br /&gt;
** Creating custom rules&lt;br /&gt;
* PMD&lt;br /&gt;
** Creating custom rules&lt;br /&gt;
* JLint&lt;br /&gt;
* Jmetrics&lt;br /&gt;
&lt;br /&gt;
== [[J2EE Security For Deployers]] ==&lt;br /&gt;
&lt;br /&gt;
=== Securing Popular J2EE Servers ===&lt;br /&gt;
&amp;lt;table border=1 cellpadding=5&amp;gt;&lt;br /&gt;
  &amp;lt;tr&amp;gt;&amp;lt;td valign=&amp;quot;top&amp;quot;&amp;gt;&amp;lt;b&amp;gt;Objective:&amp;lt;/b&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Practical step-by-step guides to securing various J2EE servers.  Examples of secure configurations can also be provided for download.  If configurations are provided, they should be properly commented so that the rationale for configuration settings is clearly explained.  Users of the configurations should be provided with enough information to make their own risk decisions.&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
  &amp;lt;tr&amp;gt;&amp;lt;td valign=&amp;quot;top&amp;quot;&amp;gt;&amp;lt;b&amp;gt;Status:&amp;lt;/b&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Call for volunteers&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td valign=&amp;quot;top&amp;quot;&amp;gt;&amp;lt;b&amp;gt;Contributors:&amp;lt;/b&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Darren Edmonds&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
  &amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;&amp;lt;b&amp;gt;Reviewers:&amp;lt;/b&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
* [https://www.owasp.org/index.php/securing_tomcat Securing Tomcat] - Darren Edmonds&lt;br /&gt;
* Securing JBoss&lt;br /&gt;
* Securing WebLogic&lt;br /&gt;
* Securing WebSphere&lt;br /&gt;
* Others...&lt;br /&gt;
&lt;br /&gt;
=== Defining a Java Security Policy ===&lt;br /&gt;
&amp;lt;table border=1 cellpadding=5&amp;gt;&lt;br /&gt;
  &amp;lt;tr&amp;gt;&amp;lt;td valign=&amp;quot;top&amp;quot;&amp;gt;&amp;lt;b&amp;gt;Objective:&amp;lt;/b&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Practical information on creating a Java security policies for J2EE servers.&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
  &amp;lt;tr&amp;gt;&amp;lt;td valign=&amp;quot;top&amp;quot;&amp;gt;&amp;lt;b&amp;gt;Status:&amp;lt;/b&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Call for volunteers&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td valign=&amp;quot;top&amp;quot;&amp;gt;&amp;lt;b&amp;gt;Contributors:&amp;lt;/b&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
  &amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;&amp;lt;b&amp;gt;Reviewers:&amp;lt;/b&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
* PolicyTool&lt;br /&gt;
* jChains (www.jchains.org)&lt;br /&gt;
&lt;br /&gt;
=== Protecting Binaries ===&lt;br /&gt;
&amp;lt;table border=1 cellpadding=5&amp;gt;&lt;br /&gt;
  &amp;lt;tr&amp;gt;&amp;lt;td valign=&amp;quot;top&amp;quot;&amp;gt;&amp;lt;b&amp;gt;Objective:&amp;lt;/b&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;This should be focussed on web applications, so examples should include applets and web start apps.&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
  &amp;lt;tr&amp;gt;&amp;lt;td valign=&amp;quot;top&amp;quot;&amp;gt;&amp;lt;b&amp;gt;Status:&amp;lt;/b&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Outline development&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td valign=&amp;quot;top&amp;quot;&amp;gt;&amp;lt;b&amp;gt;Contributors:&amp;lt;/b&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Richard Seiersen&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
  &amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;&amp;lt;b&amp;gt;Reviewers:&amp;lt;/b&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Rohyt Belani&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
* Bytecode manipulation tools and techniques&lt;br /&gt;
* Bytecode obfuscation (proguard)&lt;br /&gt;
* Convert bytecode to native machine code&lt;br /&gt;
* Signing jar files with jarsigner&lt;br /&gt;
&lt;br /&gt;
==[[J2EE Security for Security Analysts and Testers]]==&lt;br /&gt;
&lt;br /&gt;
This is a proposed section that seems to be a good place to put articles that don't fit into some of the other categories. [[User:Jeff Williams|Jeff Williams]] 17:41, 30 June 2006 (EDT)&lt;br /&gt;
&lt;br /&gt;
* Using Eclipse to verify Java applications&lt;br /&gt;
* Using Findbugs, PMD, Metrics, NCSS, jLint to find flaws and bugs&lt;br /&gt;
* Using [[:Category:OWASP WebScarab Project|WebScarab]] to find vulnerabilities in J2EE applications - is there anything that would be specific to J2EE apps here?  Wouldn't using webscarab apply to all web apps? [[User:Stephendv|Stephendv]] 07:14, 17 July 2006 (EDT)&lt;br /&gt;
* Decompiling Java bytecode&lt;br /&gt;
&lt;br /&gt;
== [[Java Resources]] ==&lt;br /&gt;
&amp;lt;table border=1 cellpadding=5&amp;gt;&lt;br /&gt;
  &amp;lt;tr&amp;gt;&amp;lt;td valign=&amp;quot;top&amp;quot;&amp;gt;&amp;lt;b&amp;gt;Objective:&amp;lt;/b&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Define other Java security resources, links, papers and books that would be useful to the community.&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:OWASP Java Project]]&lt;/div&gt;</summary>
		<author><name>Dledmonds</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Talk:Hashing_Java&amp;diff=10093</id>
		<title>Talk:Hashing Java</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Talk:Hashing_Java&amp;diff=10093"/>
				<updated>2006-10-02T11:47:28Z</updated>
		
		<summary type="html">&lt;p&gt;Dledmonds: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;I use a very similar scheme in my applications, but 2 points that came to mind whilst reading.&lt;br /&gt;
#Iterations of at least 1000 times seemed a bit excessive, but it is in the standard and I'm in no way qualified to critise.&lt;br /&gt;
#Instead of storing salt in it's own field I usually include it amongst the password (i.e characters 2, 4, 7, 13, 17, 19) to make it that bit harder to even find the salt value.  I generally hex encode the hashes as well to make them a bit easier to work with.  Assuming decompiled code is available (as an attacker has gained access to the password hashes) this extra salt hiding may not serve any useless purpose.&lt;/div&gt;</summary>
		<author><name>Dledmonds</name></author>	</entry>

	</feed>