|=--------------------------------------------------------------------------------------------------=|
|=---------------------------=[ Hardening & messing with win32 Apache Tomcat ]=---------------------=|
|=------------------------------------=[ 15 July 2009 ]=--------------------------------------------=|
|=--------------------------------=[ By shad0w_crash ]=-------------------------------------------=|
|=--------------------------------------------------------------------------------------------------=|
---------------------------------------------------------------------------------------------------------
Index
1) Introduction
2) hash default userDatabase passwords
3) Disable manager
4) Change service account
5) SSL
6) Change shutdown
7) Information hiding
8) Signing jar files
9) Policies
10) Creating backdoors for tomcat
11) Weakening tomcat
12) Contact
---------------------------------------------------------------------------------------------------------
1. Introduction
This is my first tutorial on something so feel free to send me feedback.
The aim of this tutorial is putting a lot of information about securing
win32 apache tomcat in one whitepaper. The examples are tested on
version 6.0.20. Not all security measures are usefull but i wanted to
mention them because every small thing is also a thing.
---------------------------------------------------------------------------------------------------------
2. hash default userDatabase passwords
Default tomcat uses plaintext passwords in the configuration files
(tomcat/conf/user-conf.xml). When you share a server someone could gain
higher privileges by reading te file. Or if you are updating it by
shoulder surfing. To provide this you should hash the passwords. This
can be done in 2 ease steps.
1) append to the rule about the userdatabase digest="sha". The line will now look like this:
2) Change the password in user-conf.xml to sha(password).
Don't forget to reboot tomcat ;)
---------------------------------------------------------------------------------------------------------
3. Disable manager
Unless you use the tomcat manager(for deployment), the best thing to do
is removing the tomcat manger from server.xml. If it's neceseary to
exists (for remote administration) you should create an ip-filter. The
easyst way to do this is appending the following line to
tomcat/conf/server.xml:
Of course you could also use this setting to secure other webapplications on ip.
---------------------------------------------------------------------------------------------------------
4. Change service account
By a default instalations apache tomcat is installed under the local
system administrator account. You should prevent this.
First add a user and a group.
Grant the right to run services to this group (local security policy).
Grand the rights to use java, tomcat and webapp directory
If all this is been done go to services.msc and find the apache tomcat
service. Get the properties and go to log on. Here you should click this
account (and choise your account).
---------------------------------------------------------------------------------------------------------
5. SSL
Enabeling ssl, importing the right and strong signed certificateds is
not enough to make ssl work. Many website's redirect the website to
https and of course this'll work. But you're not forced to use https. If
you check out the request and repost it, most time it'll be processed.
This is a security risk because a man in the middle attack could be
realised.
In the web.xml of a context you could specify the transport-guarantee
and the allowed methods. By only allowing post and ssl you'll be more
secure. This is an example:
something
/payingservlet/*
POST
description
CONFIDENTIAL
---------------------------------------------------------------------------------------------------------
6. Change shutdown
You could shutdown apache tomcat by connecting to TCP 8005 and type
shutdown. This connection is only allowed from localhost, but why take a
change? Change the rule ' the
server wi'll only show Apache as name. You can view this change by using
LiveHTTPHeader (firefox plugin).
An other place to hide information is as follows.
Extract lib/catalina.jar and open the extracted org/apache/cataline/util/ServerInfo.properties.
Change the
server.info=Apache
server.number=x.x
server.built=x
You could degrate the data to apache and version 1.0. Also you could a
little bit of distraction by naming it to IIS (ore somelike).
---------------------------------------------------------------------------------------------------------
8. Signing jar files
Why should you sign a jar? First of you can claim your code with it.
Also it's faster to traceback if someone messed with it. If an
authorised certificate is used the chance of having a virus free jar is
much bigger :).
How to sign a jar file. First of all you need to create a keystore.
Second you need to use the jarsigner to (self)sign the jar.
keytool -genkey -alias shad0w_crash -keypass -keystore /home/shad0w/keystore
jarsigner -keystore /home/jeroen/keystore -storepass -keypass -signedjar