Toward the Solution

Solving a problem as complex as computer security needs a systematic and comprehensive approach. Before we get to that, let's talk about technologies that solve parts of the problem.

Enabling Technologies

A number of technologies, resources and processes have been developed to counter the threat of online security. Some of the prominent ones are discussed below:

Cryptography

The practice of keeping content secure from prying eyes is known as cryptography. A cryptographic algorithm or cipher is used to convert plain-text content to cipher-text through a process known as encryption and back to plaintext through the reverse process known as decryption. A key may be used during the encryption and decryption process. Algorithms using the same key for both encryption and decryption are known as symmetric-key algorithms. Another class of algorithms uses a key pair, one key for encryption and another for decryption. Either of the keys in a key pair can be used for encryption and the other one for decryption. These algorithms are called asymmetric-key algorithms, as the encryption key, also known as the public-key, can be made public for anyone to do the encryption but only the owner of the decryption key, also known as the private key, can decrypt and read the message or vice versa.

Given a key pair, it is computationally, or otherwise, difficult to derive one key from the other, the difficulty depending on the size of the key. This ensures that, in practice, the private key cannot be deduced from the public key.

Applicability of public key cryptography for sending confidential messages is quite obvious. A stranger can use the public key of the intended recipient to encrypt the message. Although any one can intercept and “see” the encrypted content, only the intended recipient, having the private key, can decrypt and retrieve the original message.

The reverse process, whereby someone encrypts the message with the private key and others decrypt the message using the public key, is used as the digital equivalent of signatures. The fact that the private key is successfully used to decrypt the message proves that the message was encrypted by the corresponding private key and hence must have originated from the private key owner.

Another cryptographic operation, called secure hash or one-way hash, takes a message and reduces it to a fixed sized sequence of bits, also known as message digest, in such a way that the probability of two different messages yielding the same message digest is extremely low. This can be used to ensure integrity of messages. Any change in the original message will be detected, as the message digest of the new message will not match the original digest. Symmetric-key cryptography can be used to ensure that both the message and the message digest are not changed.

Secure hash is also useful for storing password information. A clear-text password is a huge security risk. To avoid this, you can generate a secure hash and store this value. To validate a password, compute the secure hash and compare it to the stored value.

Cryptography and public-key algorithms have emerged as the underlying basis for a number of computer security technologies. These ideas, along with Java API to perform cryptographic operations, are further discussed in Chapter 3, Cryptography with Java. In fact, we keep encountering cryptographic concepts at many places in rest of the book.

Public Key Infrastructure

Cryptography can be applied in different situations to facilitate secure communication but it requires additional abstractions and infrastructure components to be in place. For example, there must be a convenient but secure way to create, store, exchange, and occasionally invalidate the information comprising the public key, the identity of the corresponding private key holder and any other relevant information. Owners of the private key cannot be relied on to package the public key and the identity information because it would make it quite easy to forge identity and so, there is a need for entities that can verify the claimed identity and certify the identity claim.

Toward this, a set of abstractions, standards, protocols and organizational roles have been developed to facilitate the use of cryptography for electronic security. The combination of all these technologies, services and the software is called Public Key Infrastructure or PKI.

The following is a brief description of certain key components of PKI.

A digital certificate holds the identity information of the private key owner, the corresponding public key, validity period, and other related information (such as intended use of the certificate) and is signed by a CA (Certificate Authority). Each CA maintains a PKI repository of issued certificates to be used by senders of encrypted messages and recipients of digitally signed messages, either individuals or businesses, for verification. Another list maintained and distributed by CAs is CRL (Certificate Revocation List), a list of unexpired but revoked certificates. CAs also maintain archive of all the issued certificates for settling disputes pertaining to digitally signed “old” documents, even if the certificate has expired.

PKI users obtain certificates by creating a key pair, packaging the identification information and public key within a CSR (Certificate Signing Request) and sending that to a CA. The CA verifies the identity claim, creates a signed certificate and sends it back to the requester. A PKI-user may have multiple certificates, each with identity and purpose relevant for a particular use. This is similar to a person holding a drivers license, employer issued photo identification card and one or more credit cards.

A number of standard formats and protocols have been developed to store and exchange these information items so that software from different vendors can process these. We look at these and other PKI-related details in Chapter 4, PKI with Java.

Secure Protocols

Cryptography and PKI alone are not sufficient for secure exchange of data. Further rules are needed for communicating parties to agree upon a specific way of using these technologies for a particular communication. This need is fulfilled by secure protocols and a number of such protocols have been developed over time. Here, by secure exchange, we mean that both communicating parties may authenticate each other and the content exchanged is assured integrity and confidentiality.

Let's look at some of the popular secure protocols.

SSL/TLS— Originally developed by Netscape Communications to allow the secure flow of sensitive information between a browser and a Web server, it can be used to secure any communication over a TCP/IP connection. URLs starting with https:// use HTTP over SSL, also known as HTTPS, for accepting the request and sending the response. HTTPS incorporates mandatory authentication of the machine running the server, meaning the server name specified in the URL must match the identification string stored in the certificate presented by the server, but the client authentication is left at the discretion of the server. This is how you are able to access most of the SSL-enabled sites without a personal digital certificate.

SSL and the Java API to write SSL-aware programs are covered in Chapter 6, Securing the Wire.

SSH— SSH refers to both the protocol and the utility software implementing the protocol and was developed as a secure replacement for utilities like rsh, rcp, rlogin, telnet, ftp, and so on. It is quite popular among the developer community for accessing a remote host over an insecure network as a secure terminal emulation program. Any program that uses a TCP/IP connection can be tunneled over an SSH connection established between the SSH daemon and the SSH client. This doesn't even require changing the existing programs. This capability is often used by developers to access CVS (Concurrent Version System), a source code control system) archives securely over the Internet.

S/MIME— this is used to digitally sign and/or encrypt MIME formatted content and was developed for secure exchange of e-mails. The main difference between S/MIME and SSL or SSH is the fact that the former secures the message whereas the later secures the transmission channel between two end points. Note that SSL or SSH cannot be used to securely transmit a message if the message may be stored at a non-trusted intermediate host, as is the case with e-mail distribution through SMTP.

XML Signature, XML Encryption and WS Security— XML Signature defines the XML syntax and processing to represent, create and verify digital signature. Similarly, XML Encryption defines the XML syntax and processing to represent encrypted data and perform encryption and decryption. Like S/MIME, XML Signature and XML Encryption are used for protecting messages. However, these are too low-level to protect SOAP (Simple Object Access Protocol) messages used in Web services. Toward this end, a new standard, WS Security, is being developed. It defines the rules to use XML Signature and XML Encryption, among others, to secure SOAP messages.

The relationship among various cryptographic operations, PKI and security protocols is shown in Figure 1-2. Note that both transport-oriented and message-oriented security protocols depend on PKI.

Figure 1-2. Cryptography, PKI and Secure Protocols.


Anti-Virus Software

Viruses are malicious programs that spread through infected files, e-mail attachments, or application programs. Besides consuming computing resources, destroying valuable data and possibly stealing confidential information, a virus could open a backdoor to the infected machine for access at a later time.

Anti-virus software detects viruses by matching the loaded data against footprints of known viruses.

Firewalls and Proxies

Firewalls are systems that control the flow of network traffic between networks with differing security policy such as a corporate intranet and open Internet. In its simplest form, a firewall is an intelligent router that can block or allow IP packets based on origin and/or target addresses and ports. By maintaining a table of active TCP connections, some of these firewalls are able to allow initiation of TCP connections from only one side with an exchange of data packets in both directions on the established connections. More sophisticated firewall systems consisting of multiple routers and hosts are also possible and are usually deployed by organizations with large and complex networks.

Firewalls are deployed to restrict unwanted connectivity and flow of information between the internal network and the Internet. However, this restriction sometimes hampers genuine connectivity needs. For example, e-mail exchange and Web browsing from internal machines are legitimate activities and should be allowed. This is achieved by deploying protocol and application specific proxies that offer significant control and monitoring over information being exchanged.

Figure 1-3 shows an enterprise network and multiple home users connected to the Internet. The enterprise network has an elaborate system of internal and external DMZs (De-Militarized Zones), created with firewalls, to protect the internal network. Home users have no such network security. In some cases, such as cable connection to the Internet, many different home users might share the same network. Use of a router with the capability to prevent certain incoming connections to shield the hosts in such networks can provide some degree of network security. It shows a host running e-mail server software with a host based IDS (Intrusion Detection System). We talk about IDSs shortly.

Figure 1-3. Enterprise Network, Home Users and the Internet


The presence of firewalls makes development and deployment of Internet based applications more difficult. A common solution is to let the program running inside the firewall to tunnel data over HTTP through HTTP-proxy or otherwise. As outgoing HTTP connections are usually allowed, this approach works most of the time. Another solution is to develop application specific proxy and convince the IT department to install the proxy.

Firewalls are effective in restricting basic connectivity of a secured network with the open Internet but offer no protection against viruses transmitted through e-mails or installed when an internal user visits external websites. Also, once an internal machine gets compromised through a virus, it can initiate connection to any external machine.

Authentication Server

As the name implies, an authentication server is responsible for managing user identities, also known as login names, and verifying their identity claim or authenticating them to a system or network of systems. The process of authentication itself could be simple password-based, physical security token-based, biometrics-based, or a combination of these.

Maintaining the integrity of the authentication server is very important as most systems grant access to resources based on the authenticated identity of the user. A compromised authentication server could easily compromise the whole system.

Intrusion Detection Systems

Intrusion Detection Systems or IDSs, as the name implies, improve security by monitoring events in applications, computers and networks and analyzing them for signs of intrusions and reporting those or actually initiating the corrective action. An intrusion is defined as any attempt to circumvent the security or compromise the confidentiality, integrity or availability of the system. Intrusions occur when attackers access the system from the Internet, authorized users gain additional privileges or users misuse their privileges. The information source used by IDSs provides a good way to classify them.

Network-based IDSs— These systems detect attacks by capturing and analyzing network packets.

Host-based IDSs— These systems operate on information collected from within the host and can even examine the system after a successful or attempted attack.

Application-based IDSs— These systems are a subset of host-based IDSs that are aware of the application characteristics and analyze the events occurring within a software application.

Each class of IDSs has its advantages and disadvantages. For example, network-based IDSs are easy to deploy and are less intrusive than host-based IDSs. One problem with all of these is that they report a significant number of false alerts.

Biometrics

In recent days, biometrics, or the use of unique physical characteristics such as retinal scan, fingerprints, voice patterns and so on, has emerged as a credible form of authentication in many situations. Actual deployment is still limited to physical locations with high security requirements but as the technology improves and the costs come down, expect this authentication technology to be used more and more.

The Internet

It should come as no surprise that the Internet itself, though a major source of security problems, is also an enabling technology. The quick communication afforded by the Internet makes it possible to keep track of new vulnerabilities as they are found and to get security patches installed as they become available. A number of online resources are available to system administrators and IT security departments in their fight against computer security problems. These include the Bugtraq mailing list, an e-mail discussion list maintained by the security company SecurityFocus and an important source of the latest vulnerabilities, CERT advisories issued by the federally funded CERT Coordination Center, and the RISKS Digest forum covering all sorts of security, safety, and reliability risks.

Configuration Management

A large percentage of security breaches exploit known vulnerabilities in systems. These can be avoided by simply keeping the systems up-to-date with the latest security patches. This could be a significant task in itself, especially when the number of systems involved is quite large. What is needed is a good configuration management system to keep track of existing software versions, security patches available from the vendor, version dependencies and the procedure to apply the patches.

Vulnerability Analysis

Vulnerability analysis is the process of investigating network elements and hosts, most often with the help of automated tools, for known vulnerabilities. Such analysis looks for misconfigured applications such as Web servers, and network components such as switches and routers, that are vulnerable to known problems. It also looks for out-of-date software with known problems and searches for applications that are enabled by default, but perhaps should not be. Such an analysis is quite effective in identifying problem areas and dealing with them.

Security Management

It is apparent that computer and network security is a complex problem with many facets, including societal issues such as social engineering and online privacy, operational interdependencies, imperfect software, and no silver bullet solution. There are security products like firewalls and intrusion detection systems and there are technologies such as cryptography, PKI and biometrics, but they all have their limitations and none of them offers a complete solution. Our knowledge of building secure systems is getting better but so is the sophistication of attackers. So what is the solution, if there is one?

The NIST (National Institute of Standards and Technology) security handbook, available online at http://csrc.nist.gov/publications/nistpubs/800-12/handbook.pdf, proposes a holistic, multi-pronged and integrated security management approach for large organizations. Such a security management program should consist of a number of elements as outlined below.

  • Prevention, Detection and Response— Take the necessary steps for prevention, be ready for detection and have a proper response if a breach does take place. To make this possible, have a high-level security program policy, issue and system specific policies and build the operational infrastructure to carry out these policies.

  • Integration with Computer System Lifecycle— Integrate the security considerations into the computer system lifecycle itself: identify and evaluate security requirements during system development/acquisition, check during implementation and validate during normal operation.

  • Risk Management Approach— Adopt a risk management approach to contain the cost of security management in the most cost-effective manner. Identify high-risk areas and allocate your security budget accordingly. Acquire security technology after careful evaluation and only those that are consistent with your overall security program.

  • Awareness, Training and Education— Have proper awareness, training and education programs in place to counter the risk posed by social engineering attacks and to ensure that security management programs are carried out by every part of the organization as per the plan.

  • Assurance Control Points— Design and implement proper control points to provide the assurance that the programs and policies are being carried out.

Though these are not directly related to the design and development of secure applications, it is important to keep in mind that eventually the application will be deployed and operated in an environment created by such principles.

Application Security

Where does this leave a J2EE application developer? One thing is obvious from the preceding discussion—you can't just “code” security in your application, test it and declare the application secure, or just throw up your hands and say that security is not your specialty and it is up to other security products and processes to secure the application. The boundary of your responsibilities lies somewhere in between.

A J2EE application, be it a Servlet/JSP-based Web application or EJB-based enterprise application or XML Web Service, runs within one or more J2EE container instances and interacts with non-J2EE components, applications, protocols, enterprise information systems, and other resources through well-defined APIs. J2EE containers themselves run on one or more machines under the same or different operating systems, all communicating to each other via IP based protocols. An application must execute within this environment of operating systems, networks, J2EE containers, non-J2EE applications, enterprise information systems, and other resources including security products such as authentication servers, PKI components, IDSs, and so on. Some of these have their own security characteristics and the application must work with them in certain ways to optimize the overall system security.

J2EE architecture lends itself quite well to dealing with such diverse environment by specifying only the API and allowing implementations to work with the existing or desired environment. A rich set of declarative constructs also helps in avoiding hard-coded security decisions within code. We explore these ideas later in the book.

As we have seen, cryptography, PKI and SSL have emerged as the cornerstone of computer and network security. Again, the Java platform has rich support for these including abstraction and APIs for user authentication, and authorization, security context management and propagation, SSL-based authentication and declarative security assertions. These capabilities allow J2EE applications to leverage security products such as cryptographic libraries, authentication servers, PKI components and so on in a standard way. We will go into significant depth understanding this support and how to incorporate these in applications.

Another factor worth noting is that a number of vulnerabilities result due to implementation flaws such as buffer overflow problems. Fortunately, the Java environment offers excellent support for secure programming in this regard. In the absence of pointers and explicit memory management, it is extremely rare to have programming defects that open up buffer overflow or stack smashing attacks. The Java security architecture also provides a number of safeguards to restrict the access rights of the code downloaded from the network.

However, the mere presence of these features doesn't make the application secure. The development team must design for security—developing a security model for the application and deciding which security features to code programmatically and which ones to be left for deployment time declarative assertions.

We explore these aspects of application development throughout the book.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.226.150.219