Chapter 18: Implementing TCPIP Security


This chapter is from the Microsoft Windows Security Resource Kit by Ben Smith and Brian Komar with the Microsoft Security Team (Microsoft Press, 2003).

TCP/IP is an industry-standard suite of protocols designed to facilitate communication between computers on large networks. TCP/IP was developed in 1969 by the U.S. Department of Defense Advanced Research Projects Agency (DARPA), as the result of a resource-sharing experiment called ARPANET (Advanced Research Projects Agency Network). Since 1969, ARPANET has grown into a worldwide community of networks known as the Internet, and TCP/IP has become the primary protocol used on all networks. Unfortunately, TCP/IP was not designed with security in mind and thus has very few security components by default. Consequently, it is often a source of network vulnerabilities. On your Microsoft Windows 2000 and Windows XP computers, you can secure the TCP/IP protocol in several ways, which include securing the TCP/IP stack itself and using IP Security (IPSec). We will examine both techniques in this chapter.

Securing TCP/IP

You cannot successfully secure computer networks without knowing how TCP/IP works. Nearly all computers today use TCP/IP as their primary network communication protocol. Thus, without physical access to a computer, an attacker must use TCP/IP to attack it. Consequently, TCP/IP security is often your first line of defense against attackers attempting to compromise your organization s network and therefore should be part of any defense-in-depth strategy for securing networks. You can secure the TCP/IP protocol in Windows 2000 and Windows XP to protect a computer against common attacks, such as denial-of-service attacks, and to help prevent attacks on applications that use the TCP/IP protocol.

Understanding Internet Layer Protocols

TCP/IP primarily operates at two levels in the OSI model: the Internet layer and the transport layer. The Internet layer is responsible for addressing, packaging, and routing functions. The core protocols of the Internet layer include the Internet Protocol (IP), Address Resolution Protocol (ARP), and Internet Control Message Protocol (ICMP):

  • IP A routable protocol responsible for logical addressing, routing, and the fragmentation and reassembly of packets

  • ARP Resolves IP addresses to Media Access Control (MAC) addresses and vice versa

  • ICMP Provides diagnostic functions and reporting errors for unsuccessful delivery of IP packets

The TCP/IP protocol suite includes a series of interconnected protocols called the core protocols. All other applications and protocols in the TCP/IP protocol suite rely on the basic services provided by several protocols, including IP, ARP, and ICMP.

IP

IP is a connectionless, unreliable datagram protocol primarily responsible for addressing and routing packets between hosts. Connectionless means that a session is not established to manage the exchange data. Unreliable means that delivery is not guaranteed. IP always makes a best-effort attempt to deliver a packet. An IP packet might be lost, delivered out of sequence, duplicated, or delayed. IP does not attempt to recover from these types of errors. The acknowledgment of packets delivered and the recovery of lost packets is the responsibility of a higher-layer protocol, such as TCP. IP is defined in RFC 791.

An IP packet consists of an IP header and an IP payload. The IP header contains information about the IP packet itself, and the IP payload is the data being encapsulated by the IP protocol to be transmitted to the receiving host. The following list describes the key fields in the IP header:

  • Source IP Address The IP address of the source of the IP datagram.

  • Destination IP Address The IP address of the destination of the IP datagram.

  • Identification Used to identify a specific IP datagram and all fragments of a specific IP datagram if fragmentation occurs.

  • Protocol Informs IP at the destination host whether to pass the packet up to TCP, UDP, ICMP, or other protocols.

  • Checksum A simple mathematical computation used to verify the integrity of the IP header. If the IP header does not match the checksum, the receiving host will disregard the packet. This checksum does not include any information outside the IP header.

  • Time To Live (TTL) Designates the number of networks on which the datagram is allowed to travel before being discarded by a router. The TTL is set by the sending host and used to prevent packets from endlessly circulating on an IP network. When forwarding an IP packet, routers decrease the TTL by at least one.

  • Fragmentation And Reassembly If a router receives an IP packet that is too large for the network to which the packet is being forwarded, IP fragments the original packet into smaller packets that fit on the downstream network. When the packets arrive at their final destination, IP on the destination host reassembles the fragments into the original payload. This process is referred to as fragmentation and reassembly. Fragmentation can occur in environments that have a mix of networking technologies, such as Ethernet and Token Ring. The fragmentation and reassembly works as follows:

    1. When an IP packet is sent, the sending host places a unique value in the Identification field.

    2. The IP packet is received at the router. If the router determines that the Maximum Transmission Unit (MTU) of the network onto which the packet is to be forwarded is smaller than the size of the IP packet, the router fragments the original IP payload into multiple packets, each of which is smaller than the receiving network s MTU size. Each fragment is sent with its own IP header that contains the following:

      The original Identification field, which identifies all fragments that belong together.

      The More Fragments flag, which indicates that other fragments follow. The More Fragments flag is not set on the last fragment because no other fragments follow it.

      The Fragment Offset field, which indicates the position of the fragment relative to the original IP payload.

    3. When the fragments are received by the destination host, they are identified by the Identification field as belonging together. The Fragment Offset field is then used to reassemble the fragments into the original IP payload.

ARP

Address Resolution Protocol performs IP address to MAC address resolution for outgoing packets. As each outgoing addressed IP datagram is encapsulated in a frame, source and destination MAC addresses must be added. Determining the destination MAC address for each frame is the responsibility of ARP. ARP is defined in RFC 826.

ICMP

Internet Control Message Protocol provides troubleshooting facilities and error reporting for packets that are undeliverable. For example, if IP is unable to deliver a packet to the destination host, ICMP sends a Destination Unreachable message to the source host. Table 18-1 shows the most common ICMP messages.

Table 18-1: Common ICMP Messages

Message

Description

Echo Request

Troubleshooting message used to check IP connectivity to a desired host. The Ping utility sends ICMP Echo Request messages.

Echo Reply

Response to an ICMP Echo Request.

Redirect

Sent by a router to inform a sending host of a better route to a destination IP address.

Source Quench

Sent by a router to inform a sending host that its IP datagrams are being dropped because of congestion at the router. The sending host then lowers its transmission rate.

Destination Unreachable

Sent by a router or the destination host to inform the sending host that the datagram cannot be delivered.

When the result of an ICMP request is a Destination Unreachable message, a specific message is returned to the requestor detailing why the Destination Unreachable ICMP message was sent. Table 18-2 describes the most common of these messages.

Table 18-2: Common ICMP Destination Unreachable Messages

Unreachable Message

Description

Host Unreachable

Sent by an IP router when a route to the destination IP address cannot be found

Protocol Unreachable

Sent by the destination IP node when the Protocol field in the IP header cannot be matched with an IP client protocol currently loaded

Port Unreachable

Sent by the destination IP node when the destination port in the UDP header cannot be matched with a process using that port

Fragmentation Needed and DF Set

Sent by an IP router when fragmentation must occur but is not allowed because of the source node setting the Don t Fragment (DF) flag in the IP header

ICMP does not make IP a reliable protocol. ICMP attempts to report errors and provide feedback on specific conditions. ICMP messages are carried as unacknowledged IP datagrams and are themselves unreliable. ICMP is defined in RFC 792.

Understanding Transport Layer Protocols

The transport layer is responsible for providing session and datagram communication services over the IP protocol. The two core protocols of the transport layer are the Transmission Control Protocol (TCP) and User Datagram Protocol (UDP):

How TCP Communication Works

When two computers communicate using TCP, the computer that initiates the communication is known as the client, regardless of whether it is running a client or server OS, and the responding computer is known as the host. If the client and host are on the same network segment, the client computer first uses ARP to resolve the host s MAC address by sending a broadcast for the IP address of the host. Once the client has the MAC address of the host, it can commence communication to the port on the host by using the transport layer protocol specified by the application. There are 65,535 TCP and UDP ports, beginning with 0. Ports 1023 and below are regarded as well-known ports for legacy reasons, and ports above 1023 are known as high ports. Functionally, no difference exists between the well-known ports and the high ports. On the host, an application is bound to a certain port it specifies and is initialized in a listening state, where it waits for requests from a client. When the client initiates a connection to a TCP port, a defined series of packets, known as a three-way handshake and illustrated in Figure 18-1, constructs a session for reliable packet transmission. The steps for establishing connections follow:

  1. The client sends the host a synchronization (SYN) message that contains the host s port and the client s Initial Sequence Number (ISN). TCP sequence numbers are 32 bits in length and used to ensure session reliability by facilitating out-of-order packet reconstruction.

  2. The host receives the message and sends back its own SYN message and an acknowledgement (ACK) message, which includes the host s ISN and the client s ISN incremented by 1.

  3. The client receives the host s response and sends an ACK, which includes the ISN from the host incremented by 1. After the host receives the packet, the TCP session is established.

    click to expand
    Figure 18-1: Three-way TCP handshake

When the communication between the client and host is complete, the session is closed once the following steps occur:

  1. The client sends a finalization (FIN) message to the host. The session is now half closed. The client no longer sends data but can still receive data from the host. Upon receiving this FIN message, the host enters a passive closed state.

  2. The host sends an ACK message, which includes the client s sequence number augmented by 1.

  3. The server sends its own FIN message. The client receives the FIN message and returns an ACK message that includes the host s sequence number augmented by 1.

  4. Upon receiving this ACK message, the host closes the connection and releases the memory the connection was using.

The Netstat.exe Command

To see port activity on your Windows 2000 or Windows XP computers, you can use the Netstat.exe command. Netstat.exe will also show the status of TCP ports. The syntax for using Netstat.exe follows, and Table 18-3 describes the options available when using this command.

NETSTAT [-a] [-e] [-n] [-o] [-s] [-p proto] [-r] [interval] 
Table 18-3: Netstat.exe Options

Option

Description

-a

Displays all connections and listening ports.

-e

Displays Ethernet statistics. This can be combined with the -s option.

-n

Displays addresses and port numbers in numerical form.

-o

Displays the owning process ID (PID) associated with each connection. This option exists in Windows XP only.

-p protocol

Shows connections for the protocol specified by protocol, which can be TCP, UDP, TCPv6, or UDPv6. If used with the -s option to display per-protocol statistics, the value for protocol can be IP, ICMP, TCP, or UDP.

-r

Displays the routing table.

-s

Displays per-protocol statistics. By default, statistics are shown for IP, ICMP, TCP, and UDP.

interval

Determines the refresh interval for the data displayed by Net stat.

Tip 

To find the process associated with a given active port in Windows XP, you can locate the PID associated with the port by typing netstat aon. You can then find the process associated with the PID by typing tasklist FI PID eq XX , where XX is the PID of the process.

As mentioned in Table 18-3, the -o option of Netstat.exe is not available in Windows 2000; however, you can download utilities from the Internet that have similar functionality and will run on Windows 2000.

Common Threats to TCP/IP

Several types of threats to TCP/IP can either compromise network security or lead to information disclosure. Although these attacks are more prevalent on the Internet, you should be concerned about them on internal computers as well. These common threats include:

Port Scanning

In order to communicate with TCP/IP, applications running on host computers must listen for incoming TCP or UDP connections, and host operating systems must listen for broadcast and other network maintenance traffic. By scanning a computer to see what ports a host is listening for and what protocols it uses, an attacker might be able to locate weaknesses in the host that he can later use to attack the computer. Attackers often perform port scans to reveal this information. Several types of port scans exist:

Spoofing

Attackers might want to spoof, or mimic, a legitimate TCP/IP packets to attack a computer or network. Usually spoofing a packet requires that the attacker handcraft a TCP/IP packet and send it to either the host he wants to attack or a third party host that he has previously compromised in order to attack the targeted host or network. Many types of spoofing attacks exist. These following three are among the most well-known:

More Info  

IP spoofing by predicting TCP/IP sequence numbers was the basis for the famous Christmas 1994 attack on Tsutomu Shimomura by Kevin Mitnick. The attack is chronicled in the book Takedown: The Pursuit and Capture of Kevin Mitnick, America s Most Wanted Computer Outlaw By The Man Who Did It (Hyperion, 1996).

Denial of Service

Denial-of-service attackers attempt to exploit the way the TCP/IP protocol works to prevent legitimate traffic from reaching the host system. One of the most common types of denial-of-service attacks is a SYN flood. A SYN flood attempts to create a situation in which the host system s maximum TCP connection pool is locked in a half-open state, thus denying legitimate traffic to and from the host. To carry out a SYN flood, the attacker creates a spoofed IP packet with an unreachable IP address for a source address, or she clips the receive wire on the Ethernet cable she is using. When the host receives the packet, it responds by sending a SYN/ACK response and waits for the final ACK in the TCP three-way handshake, which never comes. The session will remain in the half-open state until the predefined time-out is reached. This process is repeated until no more TCP sessions are allowed by the host system, which then cannot create any new sessions.

Configuring TCP/IP Security in Windows 2000 and Windows XP

The remainder of this section presents several ways you can secure your Windows 2000 and Windows XP computers against attacks on TCP/IP, including basic TCP/IP binding configurations, custom registry settings, and TCP/IP filtering.

Implementing Basic TCP/IP Security

Three basic settings, outlined in the following list, will increase the security of TCP/IP for each network adapter in Windows 2000 and Windows XP. You will need to ensure that each of these settings is compatible with your network and the applications that either run on the computer or must be accessible from the computer.

Configuring Registry Settings

Denial-of-service attacks are network attacks aimed at making a computer or a particular service on a computer unavailable to network users. Denial-of-service attacks can be difficult to defend against. To help prevent denial-of-service attacks, you can harden the TCP/IP protocol stack on Windows 2000 and Windows XP computers. You should harden the TCP/IP stack against denial-of-service attacks, even on internal networks, to prevent denial-of-service attacks that originate from inside the network as well as on computers attached to public networks. You can harden the TCP/IP stack on a Windows 2000 or Windows XP computer by customizing these registry values, which are stored in the registry key HKLM\System\CurrentControlSet\Services\Tcpip\Parameters\:

Table 18-4 lists the registry entries that you can make to harden the TCP/IP stack on your Windows 2000 and Windows XP computers.

Table 18-4: Registry Settings to Harden TCP/IP

Value

Data (DWORD)

EnableICMPRedirect

0

SynAttackProtect

2

TCPMaxConnectResponseRetransmissions

2

TCPMaxHalfOpen

500

TCPMaxHalfOpenRetired

400

TCPMaxPortsExhausted

5

TCPMaxDataRetransmissions

3

EnableDeadGWDetect

0

EnablePMTUDiscovery

0

DisableIPSourceRouting

2

NoNameReleaseOnDemand

1

PerformRouterDiscovery

0

Tip 

Tcpip_sec.vbs is a script that automatically configures the registry in Windows 2000 and Windows XP to use the settings for securing TCP/IP shown in Table 18-4. This script is located on the CD that is included with the Microsoft Windows Security Resource Kit.

Additionally, you can secure the TCP/IP stack for Windows Sockets (Winsock) applications such as FTP servers and Web servers. The driver Afd.sys is responsible for connection attempts to Winsock applications. Afd.sys has been modified in Windows 2000 and Windows XP to support large numbers of connections in the half-open state without denying access to legitimate clients. Afd.sys can use dynamic backlog, which is configurable, rather than a static backlog. You can configure four parameters for the dynamic backlog:

Each of these values must be added to the registry key HKLM\System\CurrentControlSet\Services\AFD\Parameters. Table 18-5 lists the parameters and the recommended levels of protection.

Table 18-5: Registry Settings to Harden Winsock

Value

Data (DWORD)

DynamicBacklogGrowthDelta

10

EnableDynamicBacklog

1

MinimumDynamicBacklog

20

MaximumDynamicBacklog

20,000

Tip 

Winsock_sec.vbs is a script that automatically configures the registry in Windows 2000 and Windows XP to use the settings for securing Winsock shown in Table 18-5. This script is located on the CD that is included with the Microsoft Windows Security Resource Kit.

Using TCP/IP Filtering

Windows 2000 and Windows XP include support for TCP/IP filtering, a feature known as TCP/IP Security in Windows NT 4.0. TCP/IP filtering allows you to specify which types of inbound local host IP traffic are processed for all interfaces. This feature prevents traffic from being processed by the computer in the absence of other TCP/IP filtering, such as that provided by Routing and Remote Access (RRAS), Internet Connection Firewall (on Windows XP), and other TCP/IP applications or services. TCP/IP filtering is disabled by default.

When configuring TCP/IP filtering, you can permit either all or only specific ports or protocols listed for TCP ports, UDP ports, or IP protocols. Packets destined for the host are accepted for processing if they meet one of the following criteria:

Note 

TCP/IP port filtering applies to all interfaces on the computer and cannot be applied on a per-adapter basis. However, you can configure allowed ports and protocols on a per-adapter basis.

In addition to being able to configure TCP/IP filtering on the Options tab of the TCP/IP advanced properties in the user interface, you can apply the settings directly to the registry. Table 18-6 lists the registry values to configure TCP/IP filtering. TCP/IP filtering is set in the key HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters, while the specific settings for each interface are configured in the key HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces\Interface_GUID.

Table 18-6: Registry Values for TCP/IP Filtering

Setting

Type

Description

EnableSecurityFilters

DWORD

1 enables TCP/IP filtering; 0 disables TCP/IP filtering.

UdpAllowedPorts

MULTI_SZ

0 allows all UDP ports; an empty (null) value blocks all UDP ports; otherwise, the specific allowed UDP ports are listed.

TCPAllowedPorts

MULTI_SZ

0 allows all TCP ports; an empty (null) value blocks all TCP ports; otherwise, the specific allowed TCP ports are listed.

RawIpAllowedProtocols

MULTI_SZ

0 allows all IP protocols; an empty (null) value blocks all IP protocols; otherwise, the specific allowed IP protocols are listed.

Using Internet Connection Firewall in Windows XP

Windows XP includes a personal firewall called Internet Connection Firewall (ICF). ICF is a stateful firewall it monitors all aspects of the communications between the Windows XP computer and other hosts, and it inspects the source and destination address of each message that it handles. To prevent unsolicited traffic from the public side of the connection from entering the private side, ICF keeps a table of all communications that have originated from the ICF computer. When used in conjunction with Internet Connection Sharing (ICS), ICF creates a table for tracking all traffic originated from the ICF/ICS computer and all traffic originated from private network computers. Inbound Internet traffic is allowed to reach the computers in your network only when a matching entry in the table shows that the communication exchange originated within your computer or private network. You can enable ICF on a per-interface basis on the Advanced tab of the interface.

You can configure services to allow unsolicited traffic from the Internet to be forwarded by the ICF computer to the private network. For example, if you are hosting an HTTP Web server service and have enabled the HTTP service on your ICF computer, unsolicited HTTP traffic will be forwarded by the ICF computer to the HTTP Web server. A set of operational information, known as a service definition, is required by ICF to allow the unsolicited Internet traffic to be forwarded to the Web server on your private network. The Services tab of ICF is shown in Figure 18-2.

click to expand
Figure 18-2: Services tab of ICF

In addition, you can add custom services to the Services tab of ICF. ICF can also perform port translation for incoming connections. When you create a custom service, you will need to specify the following:

Communications that originate from a source outside the ICF computer, such as the Internet, are dropped by the firewall unless an entry in the Services tab is made to allow passage. ICF silently discards unsolicited communications, preventing common attacks, such as port scanning and NetBIOS enumeration. ICF can create a security log so you can view the activity that is tracked by the firewall. You can choose whether to log dropped, successful, or dropped and successful packets. By default, packets are logged to c:\windows\pfirewall.log. The log file has a default maximum size of 4098 KB. Table 18-7 describes the fields in the packet log file.

Table 18-7: Description of Information Logged by ICF

Field

Description

Date

Specifies date that the recorded transactions occurred in the format YY-MM-DD.

Time

Specifies time that the recorded transaction occurred in the format HH:MM:SS.

Action

Specifies which operation was observed by the firewall. The options available to the firewall are OPEN, CLOSE, DROP, and INFO-EVENTS-LOST. An INFO-EVENTS-LOST action indicates the number of events that happened but were not placed in the log.

Protocol

Specifies which IP protocol was used for the communication.

Src-ip

Specifies the source IP address of the computer attempting to establish communications.

Dst-ip

Specifies the destination IP address of the communication attempt.

Src-port

Specifies the source port number of the sending computer. Only TCP and UDP will return a valid src-port entry.

Dst-port

Specifies the port of the destination computer. Only TCP and UDP will return a valid dst-port entry.

Size

Specifies the packet size in bytes.

Tcpflags

Specifies the TCP control flags found in the TCP header of an IP packet:

  • ACK Acknowledgment field significant

  • FIN No more data from sender

  • PSH Push function

  • RST Reset the connection

  • SYN Synchronize sequence numbers

  • URG Urgent Pointer field

Tcpsyn

Specifies the TCP synchronization number in the packet.

Tcpack

Specifies the TCP acknowledgment number in the packet.

Tcpwin

Specifies the TCP window size in bytes in the packet.

Icmptype

Specifies a number that represents the Type field of the ICMP message.

Icmpcode

Specifies a number that represents the Code field of the ICMP message.

Info

Specifies an information entry that depends on the type of action that occurred. For example, an INFO-EVENTS-LOST action will create an entry of the number of events that happened but were not placed in the log since the last occurrence of this event type.




Microsoft Windows XP Professional Resource Kit 2003
Microsoft Windows XP Professional Resource Kit 2003
ISBN: N/A
EAN: N/A
Year: 2005
Pages: 338
BUY ON AMAZON

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net