Skip to main content

Security Hardening of WebSphere Application Server Installations:


It is a known fact that an out of the box WAS installation with security enabled is not entirely secure. There is a number of steps that has to be taken in order to "harden" the installation. Most of the steps are documented in the WebSphere hardening guide, which should be closely studied and followed by any WAS administrator or developer. The hardening guide, however, is a little light on the specifics regarding how to secure WAS at the OS level. For example, hardening should normally include changing file and directory permissions to restrict access to sensitive configuration files.

Why bother hardening the installation at the OS level? This helps defend against external threats, i.e., a server hosting the installation is compromised and against internal threats, i.e., an unauthorized access from inside. Here are some of the things you can do to secure your installation on a Unix/Linux platform:

1) If you installed WAS as a non-root account, make sure that this account is not part of the "users" group. Create a separate group for all administrators, say "wasadmins". If you're doing this the post-install, make sure that you changed the ownership of all WAS files and profiles. To do that, bring all WAS processes down and run chgrp -R wasadmins $WAS_INSTALL_ROOT.

2) Refrain from running WAS using root. There is no reason to do it on Unix/Linux, unless you absolutely have to use low ports. Yes, you can use sudo to tighten down access to root, but it is safer just to stay away from it. You can actually install WAS using root so it can be properly registered with the OS, but you can later change the installation to be owned by a non-root account.

3) Following the principle of least privilege, remove read access from "others". Why do you need to do it? There are many sensitive files that are part of WAS install, including files containing encoded passwords (see below). It's better to err on a side of caution and disallow general read access altogether. We should revoke execute access as well. On the other hand, we may want to grant write/execute to all members of wasadmins groups, assuming the membership in this group is going to be tightly controlled: chmod -R 770 $WAS_INSTALL_ROOT.

4) You may want to allow access to logs to "others" so that developers can view logs. Since we just revoked read permissions from the root WAS install directory and from all profile directories, you can't just "chmod" the "logs" directory. You need to redirect logs to some other directory which is not under "$WAS_INSTLALL_ROOT" or profile roots. In order to do it, change LOG_ROOT WAS variable. You can do it from the console (Environment/WebSphere variables). By default, "LOG_ROOT" is defined at a node level. If the location is going to be the same on all nodes (which it should), just create LOG_ROOT at the cell level. You'll need to restart WAS servers after this. You can redirect logs to, say, /var/log/was. Make sure that "wasadmin" system account has write permissions to this directory.

5) Do not allow login to the system account used to run WAS. You can read this guide explaining how to do it for various login mechanisms. You also need to disable "sudo su wasadmin" and only allow sudo for the specific commands/scripts that are needed to run WAS. You will need to add something like this to the sudoers file:

%wasadmins ALL= (wasadmin) WAS_INSTLALL_ROOT/bin/, PROFILE_ROOT/bin/ 

this configuration allows all member of "wasadmins" group to run commands from "bin" using

"sudo -u", e.g., sudo -u wasadmin ./startServer.sh server1.

You may relax this a little bit by allowing sudo access without having to enter password every time:

%wasadmins ALL= (wasadmin) NOPASSWD: WAS_INSTLALL_ROOT/bin/, PROFILE_ROOT/bin/

It's a bit of a pain having to run all commands via sudo (although, of course, it can be scripted), but it gives you complete audit trail of who did what in the environment. By the way, by default sudo logs via syslog, but you can redirect sudo's log into its own file by adding this directive in sudoers:
Defaults logfile=PATH_TO_LOG_FILE

6) Secure "sensitive" files. As any WAS administrator knows, passwords stored in WAS are not really encrypted, they are just encoded, so they can be decoded pretty easily (there is a way to plug in custom encryption, but that's a different story). Therefore, it is imperative to properly protect files containing encoded passwords. To do that, we're going to revoke any access to these files from "wasadmins" group. That way, only the "wasadmin" system account (which we can't even login into) or root can read these files. Encoded passwords are stored in "security.xml" and "wim/wimconfig.xml" (if you have LDAP configured).
All these files reside under "$PROFILE_ROOT/config/cells/$CELL_NAME". "fileRegistry.xml" also contains passwords, although these passwords are properly encrypted. You may also want to protect keystores (key.p12). Note that in addition to the cell key store, each node has its own keystore. You don't need to worry as much about trust stores (trust.p12), in fact it might be convenient to keep group-level access to trust stores so that administrators can modify them outside of WAS (e.g., by adding a signer cert using ikeyman). While you're on it, make sure that you don't use the default password (WebAS) for any of the keystores/truststores.
To revoke group access to any of the files mentioned above, just run "chmod 600" on them, e.g. chmod 600 security.xml. Note that you'll have to repeat it for each profile, including deployment manager and application server profiles (unless you have a standalone install).
Node synchronization built into WAS fully supports changing permissions on config files. The changes will not disappear after node sync (provided you updated the DM profile).

7) If your environment has a DMZ utilizing IHS, make sure that you don't have WAS installation on the DMZ boxes. It is convenient to have node agents running on the IHS servers, so you can manage HIS from admin console, but, unfortunately, it is a security risk. Deployment manager pushes all configuration files, including "security.xml" to all nodes, and we certainly don't want this file sitting in the DMZ (even with "600" permissions).

8) Repeat all changes on every server containing WAS installation. You may want to script them or, better yet, use a tool like Puppet to automate OS-level configuration changes across multiple machines. For example, see this guide on how to centralize management of the sudoers file.









Comments

Popular posts from this blog

SSL certificate installation on IHS (IBM HTTP Server):

Hi, folks... Today I am going to explain how to install an SSL certificate on IHS (IBM HTTP Server). Let's go through the below steps: *Notes: 1) Create a .sh script for creating the db, for importing certificates and for receiving the signed key.  2) gsk7cmd command supports -Xms1024m -Xmx2048m options for adding extra heap memory to java. This is very usefull because some times you end up with OutOfMemory errors. 3) After creating the request you can see the request by list request certificates in the keystore, after receiving the signed certificate the certificate request is removed. Don't worry, this is normal. 4) SL0208E: SSL Handshake Failed, Certificate validation error.  This error is related to the Root Class-3 certificate. Don't forget to import it to the keystore. Step 1 : Configure your environment variables (Using command line): export JAVA_HOME=/java/jre export PATH=/java/jre/bin:$PATH Step 2 : Create a new key store database: ...

WebSphere Application Server Performance Tuning...

Here are some tips for WebSphere Application Server Performance Tuning: 1. Turn verbose garbage collection on, either by using WAS console (Servers => Application servers => server_name => Process definition => Java Virtual Machine) or by modifying command line parameters. Then, restart JVM.  2. Run your test harness and peruse the log file native_stderr.log. This will give you an idea whether your JVM has got optimal heap size allocated: you'll want to find that garbage collection does not occur more often than every 10-15 seconds and it does not take longer than 1 to 2 seconds to complete.  3. If the above is not true, change the JVM heap size, restart JVM and repeat step 2.  4. Use WAS console to check the size of Web Container's thread pool. the maximum size of 60-80 is usually a good default value.  5. Use WAS console to make sure the JDBC Connection Pool has its Maximum Connections set up to a value lower than Web Container's...

Typical flow of a J2EE Application

The typical application flow is as follows: 1. A Web client requests a URL in the browser (input page). 2. The request is routed to the Web server over the Internet. 3. The Web server immediately passes the request to the Web server plug-in.  All requests go to the Web server plug-in first. 4. The Web server plug-in examines the URL, verifies the list of host name aliases from which it will accept traffic based on the virtual host information, and chooses a server to handle the request. 5. A stream is created. A stream is a connection to the Web container. It is possible to maintain a connection (stream) over a number of requests. The Web container receives the request and, based on the URL, dispatches it to the proper servlet. 6. If the servlet class is not loaded, the dynamic class loader loads the servlet (servlet init() , then doGet() or doPost() ). 7. JNDI is used for lookup of either datasources or EJBs required by the servlet. 8. Depending upon whether a ...