Servers are depended upon to deliver data in a secure, reliable fashion. There must be assurance that data integrity, confidentiality, and availability is maintained. This technical paper includes suggestions for combating external threats to your server in addition to practical, hands-on configuration recommendations.
The hardening guidelines broadly cover the following components:
This paper is specific to application server aspects of hardening. You may need to refer documentation of other products for a complete hardening exercise. The following aspects are dealt in this paper:
Enterprises depend on application servers to deliver data when they need it and how they need it, in a secure and reliable way. Data integrity, confidentiality, and availability are of paramount importance. One of the first steps to achieving this is to install and maintain the application server such that unauthorized access, unauthorized use, and disruptions in service is prevented.
Organizations usually have a server hardening policy as part of their security audit. The policy applies to all individuals who are responsible for the installation and running of server, the application that is deployed on the server, the data resources that will be accessed by the server, and the complete hardware ecosystem (network and servers).
It is fair to assume that the default username and password for your Pramati Server is well known and, using it, anyone can access the Server Management Console with the administrator privileges. This gives malicious user administrative privileges to the Server. Moreover, IP-based restriction is not enabled for Server Management Console. This opens the default configuration server to attacks on the intranet.
A DoS is characterized by an explicit attempt by attackers to prevent legitimate users of a service from using that service. Examples include flooding a network preventing legitimate network traffic, disrupting connections between two machines preventing access to a service, preventing a particular individual from accessing a service and disrupting service to a specific system or person.
Illegitimate use of resources may also result in Denial of Service. For example, an intruder may use your anonymous file transfer protocol (FTP) area as a place to store illegal copies of commercial software, consuming disk space and generating network traffic.
You can set up DoS attack prevention at five levels on Pramati Server:
While DoS can be prevented at the system or firewall level, Pramati Server provides DoS prevention features that can be configured in the web-config.xml using these tags:
The Web container discards the connection if any of these rules are violated.
DoS prevention rules can be configured using the Management Console GUI too. To do so, select Configure > Web Server > Denial of Service. This displays the following window:
Worker threads enable concurrent processing by the server. Worker threads can be kept alive (that is, waiting on a connection for the next request) to improve performance. Keeping all threads alive maximizes performance but makes your server vulnerable. Rogue users can block all such threads by making them indefinitely wait for the next "elusive request" over the connection. As a result legitimate users get delays.
Reducing the number of worker threads that can be kept alive may affect performance but make your server more available to a wider number of users. This tag in web-config.xml specifies the number of keep alive worker threads:
In this case, at least 50 worker threads are always available to valid users. These are default values on Pramati Server.
Response sniffers available with common browsers can be used to show this information:
Here you may want to mask the identity the Web server ("Pramati Server"). Publishing the type of Web server makes it vulnerable to hacking. Server identity also appears on default error pages.
To mask the identity of the server, modify this tag in web-config.xml.
Directory listing is specified in default-web.xml, using servlet mapping for PramatiDefaultDirectoryListingServlet. This servlet mapping is commented by default. So directory listing is OFF by default. No additional effort is required for securing access to the server directories. In any event, Server directory listing does not give a user access to directories outside of the doc-root specified for the application. Hence it is recommended to keep application files outside the server installation directory.
A custom directory listing servlet can be written by modifying the servlet-class tag under the PramatiDefaultDirectoryListingServlet in default-web.xml. The servlet class should be saved in: /public_html/web-inf/classes or inside a jar placed in /public_html/web-inf/lib directory.
Note: A JSP can be specified as the directory listing servlet by removing the servlet-class tag and adding a jsp-file tag in default-web.xml.
The StatusCode servlet is used as the default error page by the Server when no custom error page has been defined in the application web.xml. A custom servlet can override this servlet by modyfying the servlet-class tag under PramatiDefaultStatusCodeServlet in default-web.xml. The servlet class should be present inside /public_html/web-inf/classes directory or inside a jar placed in /public_html/web-inf/lib directory.
Note: The user can also specify a JSP as the error page servlet by removing the servlet-class tag and adding a jsp-file tag in default-web.xml.
Production sites often like to configure bare, runtime servers with shell controls and stripped of any Web-based administration functions that may contain security holes. On Pramati Server, the administration applications are enabled by default. The following system property disables the Management Console as well as the Console Online Help application:
Place this property in the startup file, runserver.bat after the java command, like this:
Note: Instead of disabling Web-based administration, you may want to place IP-based access restrictions so that only certain workstations on the network are enabled to manage the server.
This Pramati Server feature restricts access to certain URLs based on client IP address. For example, this can be used to restrict access to the administration application to workstations on the LAN.
|
Set value as True or False as per the access permission requirement. |
|
|
IP address for which all above access constraint values are applicable. Can be specified in CIDR. |
You may want to read more on CIDR patterns here.
URL restrictions can be configured from the Management Console too.
Administrators prefer to run the application server as OS user with least privileges (non-root user). This poses a problem in Linux environments where only a root user can open the port 80 required by the Web server.
Note: On Linux, root user privileges are required to open ports less than 1024. Windows does not have this restriction.
If the Web server does not need to open a port less than 1024, this is not a problem, provided the server has permissions to access to the files specified by its root context. On the other hand, starting the server with the root user privileges can compromise the entire machine, including the application server.
A solution is to create a dedicated user role for running the application server: the "Nobody" role. This role has privileges only on the app server installation directory, and no access to other systems in the box. A way of safely giving privileges to "Nobody" is by using IPTables.
This solution allows Pramati to run as an independent Web server, using a non-privileged user, and still respond to port 80 on the server. It requires Linux with a kernel v2.4.x and IPTables installed.
IPTables also allow you to do nifty things like redirecting all incoming packets on, say, port 80 (the default www port) to another port such as port 8181 (Pramati Server default port). To do this redirection, two things are needed:
The first step is needed only if you have configured your firewall to protect your machine. Use your firewall-configuration software to accept incoming packets of type TCP and destination-port 8181. Essentially, you need a copy of the standard rule for port 80, using port 8181.
The second step is to instruct IPTables to redirect all packets that arrive on port 80 to port 8181. This is done using the following command (as root):
The above command tells IPTables to redirect all TCP packets with a destination port 80, coming in on network interface eth0, to the port 8181 (on the same machine). You may want to add this rule to files used by your firewall configuration so that it is added automatically on booting.
Note: This will not redirect local requests, since these bypass pre-routing chain. Thus, any browsers or other client software running on the Server itself will either have to connect directly to port 8181, or something else must be used to redirect these local requests. While some servers might not require local requests to be redirected, note that this could affect local search engine software and such.
Pages that ask for your password, account number, credit card number or any other sensitive information, need to be secured through SSL (HTTPS). Users are authenticated and authorized before they can enter the site. To enable this, the Web server is configured in two steps:
Note: By default, Pramati Server is not enabled for SSL.
Modify the web-config.xml tag protocol to enable HTTPS. Set the ssl-enabled tag under protocol to true to enable HTTPS.
Specify the HTTPS port in the <https-port> tag under server-config.xml. The default port is 443.
Create a resource collection of pages that will be accessed over HTTPS. Make the following changes in web.xml:
On hitting a HTTP error like 404, a default page is returned by the server. This page uses a standard template that may give away the server identity (even if you have masked the identity of the server as discussed earlier). Instead, you can write a custom page and return that to the browser in case of an error. Such a page could be a sitemap or the homepage of the Web application. This is good programming practice. The application developer must modify the web.xml in the /web-inf directory of the application. You can throw a custom error page for two types of exceptions:
Dynamically generated HTML pages can introduce security risks if inputs are not validated either on the way in or on the way out. Malicious script can be embedded within input that is submitted to Web pages and appear to browsers as originating from a trusted source. This problem is referred to as a cross-site security scripting issue. This is avoided through good programming practices. Application developers must avoid using query parameters directly to generate HTML text or SQL queries.
For more information, click here.
Network Address Translation (NAT) or IP masquerading implies that the IP of Server host is mapped to a global IP outside the firewall, so that any request arriving at the global IP is transparently directed to the local IP.
For Pramati Server to receive calls from the global IP across the firewall, point java.rmi.server.hostname to the global IP while starting Server.
For example, if the user's global IP is 192.12.1.143, start the Server using:
What is the OS level access required for the user-id used by the clients accessing the site, say a separate guest account with minimum privileges could be created?
Clients accessing the site need no OS-level access to the server at all. The application itself manages the authentication and authorization of users based in information available in the application database.
What web-server user-id is required for Internet users?
The user-id `root' in Pramati Server is not the same as the OS root in Unix systems. This is the default admin user in Pramati Security domain. The password of this user can be changed or another user can be added.
For the application, if the standard J2EE security model is used, then the users (internet, internal or admin) can be configured in the app server and assigned to various groups. Access privileges are set on the groups. Pramati Server uses JAAS framework and enables plugging in various security repositories.
How can the default access privileges required for the XML file, which includes the Server user-id and password, be modified?
Access privileges to this file can be restricted to the administrator who will be starting Pramati Server.
What logs are available through Pramati Server and how can the logs required be enabled? What access settings are recommended for the log file?
There are two types of logging that can be configured on Pramati Server- web activity logging and Server internal logging.
What is the process behind auditing security?
Based on the domain specific solution, security audit may involve one of these processes.
There are various tools available in the market for performing one or few of these tasks. Most of the tools have a friendly interface for detecting and managing vulnerabilities. But very few application servers provide built-in tools for scanning vulnerabilities as the exercise is out of scope for the server.
What are the key benefits of Security Audit?
How often do I need to perform security audit?
With the amount of traffic and impregnability of business, it can vary from monthly to every two days.
How does Pramati Server aid in the auditing process?
Pramati Server logs in information about authentication and authorization including results and failures in a dedicated audit log file. This information can be used by third party tools or the network administrator to assess the security breaches and estimate the damages if any.
Can I install the Web server in the same partition as the OS?
Yes, you can. But if the Web server vulnerabilities are exploited, files in the same partition can be easily accessed. Critical system files like cmd.exe (command interpreter for Windows 2000 / Windows NT) can be used to carry out unauthorized activities on the Web server like gaining access to the database, source codes of the server side includes etc. Hence ensure that Web server is installed on a different partition than the operating system. Also, the content files should be installed on a separate partition.
Why do I need to set up access control for Web server folders?
Users having full default permissions will be able to read the source code contained in script files (like JSP files) and may be able to execute these scripts in unauthorized method. Source code could contain sensitive information like database location, table structure, username / password etc. Hence Web server folder access should be restricted to a separate user who starts the Web server and has permissions only on the specific folder.
Is installing Pramati Administration Service absolutely necessary?
No. Pramati Administration Service is used only for accessing the clusters. If the server is installed in a standalone mode, the Service may not be required.
Why is Web access logging important for a server?
Unless the Web access is logged, it will not be possible to detect security breaches or DoS attacks. And also if rotation of log files is not implemented in the server, new logs will overwrite the old log entries once file size reaches the specified limit.
Every URL access is logged on the Web server. Depending on the configuration set, this log file can contain information like client IP address, the requested Web object, and date/time, which can be used for analyzing an attack on the Web server.
Archival policy should be formulated and implemented in the server. Access to write such log file must be restricted to the user who has started the Web server. Access to read log files should be restricted to different user, who will be reviewing the logs.
Why is reviewing logs important for analyzing breaches?
Any undesirable activity on the server will remain unnoticed as the logging information increases. Hence the security logs should be checked periodically by the administrator or automated with the use of auditing tools.
Why should I audit Web server specific files?
If malicious changes are made to the Web server specific files, it will remain undetected. Appropriate audit logs should be enabled to track changes made to these files. Logs should be monitored to ensure that unauthorized changes are detected immediately.