CSG254: Network Security

Practical Systems Security Lab
Lab Assignment 3: Network Defense
Due: 6:00PM Eastern, February 15, 2006

Your team must complete either lab assignment 2 OR lab assignment 3 by the due date. You may complete both for bonus points, but if you plan on doing both, be sure to complete lab assignment 2 BEFORE lab assignment 3, otherwise it may be difficult to complete lab assignment 2. (All bonus labs are due on March 27, 2006.)

NOTE: Read this entire document before beginning the lab assignment.


Lab Assignment

  1. Basic Host Hardening

    Disabling Extraneous Services

    The most basic way to mitigate network attacks is to disable services which are not necessary for the operation of the specific system. Because so many software and OS vendors want their systems to work "out-of-the-box", they often enable every service by default, even if it isn't needed by the user. If users do not disable these services, an attacker can often glean a lot of information from them, and if a vulnerability is discovered in an extraneous service, the defender may not even know they are vulnerable to it, since they are not using it (even though it is running).

    1. Identify two services running your Linux router which are not currently needed. You can use netstat and lsof to help you determine what is listening on specific TCP/UDP ports and to determine what processes are holding those sockets open. If you are not sure if a certain service is needed, try searching the web to determine what its function is.

    2. Once you have determined what two services aren't needed, try stopping them via their /etc/init.d scripts. Verify that you can still use your system (eg, can still SSH to it, can still connect out to the internet with it...), and if everything is still working as expected, permanently disable these services from starting up by removing their /etc/rc?.d symlinks. (If you aren't sure what these symlinks are for, see this reference.)

    3. Search the web for information on "Simple TCP/IP Services", which is a service that can be configured to run on Windows. Learn about the specific protocols provided by this service. Now, shut down this service on your Windows server, and prevent it from starting up again. You can use netstat at the cmd prompt to verify the listening ports were closed.

    4. Search the web for information on the Windows "Remote Registry Service". This service is rarely needed by administrators that already have remote access to the system (eg, via RDP). Disable this service, and prevent it from starting up at boot.

    5. Search the web for information on "Hidden administrative shares". Learn about what they are for, how they may be useful, and why they might pose a security risk. Find a registry setting to disable these shares, and do so.

    6. Read this article on Null sessions, and search the web for additional kinds of attacks or information gathering techniques that are possible if they are enabled.

    7. Decide what level of Null sessions should be allowed on your system, and restrict them via the indicated registry setting(s).

    8. NOTE: After making registry changes to your Windows server, you will likely need to reboot it. You needn't do this for your Linux router.

  2. Mitigating Denial of Service (DoS) Attacks

    There are many forms of Denial of Service attacks. They fall mainly into two classes: resource-exhaustion attacks, and bug exploitation. This lab will focus on the former type, as these are often tied to difficult to change protocol specifications. The types of resources typically targeted are: processor, memory, and network bandwidth.

    A. SYN Floods

    1. One popular attack which attempts to exhaust the memory resources of a host is a SYN flood. Read more about how this attack works here.

    2. Next, read about SYN cookies and how they trade off the memory requirement of half-open connections for a bit more processing.

    3. The Linux kernel has a built-in SYN cookies option. When enabled, Linux will use SYN cookies if the TCP/IP stack detects it is getting overwhelmed with half-open connections. Use the /proc filesystem to enable SYN cookies on your Linux router. (If you are not familiar with the /proc filesystem, you may use this as a reference.)

    4. Unfortunately, Microsoft has yet to integrate any kind of SYN cookies protection into Windows. Their suggested mitigations involve registry settings which decrease the time half-open connections are kept around, along with some other settings. Review this document on the subject, and apply the changes to your Windows server that seem reasonable to you for mitigating SYN floods.

    B. Smurf/Fraggle Attacks

    1. Smurf and fraggle attacks are almost identical forms of an amplification attack. By sending a single spoofed broadcast packet to many hosts, many responses may be generated and directed at a victim. Search for references online and find out what the difference is between smurf and fraggle attacks.

    2. Read the documentation in man icmp and find out how to keep your Linux host from being an accomplice in these kinds of attacks. Update the indicated /proc setting accordingly.

  3. Firewalling with iptables

    Before learning about iptables, it is important to understand what a firewall is, what the difference is between a stateful and stateless firewall, and at what protocol layers firewalls typically operate. Please research this if you have never worked with firewalls before or don't feel comfortable with all of these definitions.

    1. The native Linux firewalling software is part of the netfilter project. The bulk of this software is compiled as a part of the kernel, but filter rules can be added and removed via the iptables command. Recent versions (2.4+) of the Linux kernel support stateful packet inspection, allowing one to configure a stateful firewall. Read the man page on the iptables command and become familiar with the options. In addition, these references may help. There are many other tutorials available online as well.

    2. A set of shell scripts have been provided to get you started building a proper firewall. These scripts are installed on your system in the directory /etc/iptables. Become familiar with these scripts. In particular, pay attention to the way /etc/iptables/start.sh defines ethernet interfaces through the variables OUTSIDE_IF and TRUSTED_IF, and how it kicks off all the other scripts. Also, review the structure of the /etc/iptables/ipv4/filter.sh script, as this is the primary place you'll be making changes.

    3. Make a backup copy of the /etc/iptables directory. Then, edit the /etc/iptables/ipv4/start.sh script by setting the correct TRUSTED and OUTSIDE_IP variables, based on your team's number. (See the script for details.)

    4. Next, add commands to the /etc/iptables/ipv4/start.sh script, right after the network definitions, which set all of the /proc changes that were made in section 2.

    5. One of the most basic functions of a firewall is the mitigation of spoofing attacks. Since routers and firewalls sit in a unique position on the network, they are ideal for limiting the types of spoofing possible. Specifically, one can configure a firewall to allow packets from a network segment only if those packets have a source address which falls within the designated network IP range. In addition, when receiving traffic from the internet, where almost any source IP is allowed, one can drop packets which contain source IPs belonging to segments within a trusted network.

      Open the script /etc/iptables/ipv4/filter.sh and make three changes:

      • Change the FORWARD chain's default policy to DROP. Also, add a rule to the end of the FORWARD chain which sends all traffic to the logdrop chain.
      • Add a rule at the top of the FORWARD chain which sends all packets coming from the TRUSTED network to the trusted-outside chain for further evaluation.
      • Add a rule as the second item in the FORWARD chain which sends all packets coming from in from the internet to the TRUSTED network to the outside-trusted chain for further evaluation.

      NOTE: The rules which jump to trusted-outside and outside-trusted must not allow obviously spoofed traffic. In particular, an external attacker should not be able to send packets in on the OUTSIDE_IF interface with a TRUSTED address. Also, you should not allow your TRUSTED users to send packets from something other than a TRUSTED IP address.

    6. Add rules to the outside-trusted chain such that the following kinds of traffic are allowed:

      • All ICMP traffic.
      • TCP packets with the SYN flag set, which are headed to destination ports: 21, 22, 23, 25, 80, 135, 137, 138, 139, 443, 445, and 3389.
      • All packets which are members of ESTABLISHED connections. (Hint: -m state)

    7. Next, add a rule at the end of that chain which sends all traffic to the logdrop chain.

    8. Now, carefully review your firewall rules to be sure you didn't make any typos. Once you are reasonably confident you have it right, run the /etc/iptables/start.sh script to install the rules. If you see the script spit out any error messages, it is likely because of improper usage of the iptables command, or due to syntax errors in the shell script itself. Fix any of these before continuing, and re-run the /etc/iptables/start.sh script each time to flush and re-load all rules.

    9. You should now test to make sure you can still access your Windows server's RDP port. This is port 3389/TCP, and simply logging in from the internet while the firewall is running should be sufficient. If this doesn't work for some reason, packets may be getting blocked. Log messages to this effect will show up in /var/log/kern.log Also, try pinging a system on the 10.0.0.0/24 network (besides your Fedora system) from your Windows server. Since you allowed all ICMP earlier, this should route just fine still. If somehow you lock yourself out of your Fedora system, contact the lab TA, and it will be rebooted.

    10. Take a look at the Smurf Amplifier Registry (SAR). Set up rules in your outside-trusted chain before your ICMP allow-all rule to block all ICMP echo-reply packets from these networks.

    11. Once you are SURE you are satisfied with your firewall rules, add the /etc/iptables/start.sh script to your boot-up scripts in runlevels 2, 3, 4, and 5 through symlinks in /etc/rc?.d.

    NOTE: The firewall rules you just setup are not complete, and this shouldn't be considered a "secure" firewall. This lab is merely intended to help you learn how to use iptables. Be sure to consider the INPUT chain and what traffic you actually need to have allowed if you use this firewall as a basis for the competition.

  4. Intrusion Detection with Snort

    1. Snort is an open source, signature-based network intrusion detection system (NIDS). Read a bit about Snort and the differences between anomaly-based and signature-based intrusion detection systems.

    2. Snort is already installed on your system, but it isn't configured and there aren't any signatures installed. First, create the directory /usr/local/etc/snort and make a copy of the sample snort configuration:

          mkdir /usr/local/etc/snort
          cp /usr/local/src/snort-2.4.3/etc/snort.conf /usr/local/etc/snort
           

    3. Next, obtain the latest, non-subscription ruleset from snort.org. (You may register if you wish, but this isn't required. The rules for the latest release version will be sufficient.) Once downloaded, extract these rules in the /usr/local/etc/snort directory.

    4. Now edit your copy of snort.conf and customize it for your network. Read through the comments in the file to determine how you should set each variable. (This will take a significant amount of time if done correctly.) In the end your configuration should have the following:

      • Snort listens on both eth0 and eth1.
      • Be sure to set your RULE_PATH correctly, to an absolute path.
      • Snort should not be configured as an inline IPS.
      • All rules you downloaded from snort.org should be enabled through include directives.
      • Snort will log to the local syslog daemon via the alert_syslog output plugin.

    5. Once you are happy with your configuration and ruleset, try running Snort as root:

          snort -c /usr/local/etc/snort/snort.conf
           
      Watch the output carefully, and address any errors in your config file. (Continue re-running snort until you get it working correctly.)

    6. Now, read about Snort's signature syntax in the Snort User's Manual. In particular, be sure to review the meta-data options reference and sid.

    7. Once you are somewhat familiar with the rule language, read through some of the web attacks rules files. These are files named in the form web-*.rules. Follow the references listed in a few of the rules and read about the type of attack the specific signatures are designed to detect. Also, review the documentation provided with your signatures. (Should be in the /usr/local/etc/snort/doc/signatures directory.) The signature documentation is broken up into files which are named based on their signature IDs.

    8. Now, select one web attack signature that seems straight-forward to understand. (It would be best if you select a signature that looks for "evil" data in an HTTP URL string.) Log into your Windows server, and open a browser. Based on the documentation provided with the signature you have selected, attempt to trigger the Snort signature by making a request to the system strawman-fedora.nslab.ccs.neu.edu which contains an attack string which should be detected.

    9. Now verify in your Snort logs (Hint: /var/log/messages will probably have something.) that your attack triggered an alert based on that signature.

Questions

  1. In part 1.2, which two services did you disable? What are they normally used for?

  2. Simple TCP/IP Services provides the Daytime service. How could the UDP version of this service be used in denial of service attacks against third parties? How could this service be used in conjunction with the UDP echo service to create a datagram loop?

  3. What kinds of information could an attacker obtain anonymously from your Windows 2000 Server if NULL sessions were fully enabled?

  4. When using SYN cookies, if the defending system doesn't store state about SYNs that were replied to previously, what's to stop an attacker from just sending an ACK outright to start a connection?

  5. What kinds of negative impacts do SYN cookies have on TCP connections?

  6. What SYN flood mitigation settings did you apply (in section 2.A.4) to your Windows server? Why did you choose these settings?

  7. Suppose you are the administrator of a webserver that hosts a large eCommerce application. For security, your webserver is configured to communicate with all clients over SSL for every request. Your boss asks you to set up Snort to monitor attacks against the web server and application. (He believes that the SSL implementation is secure, and isn't concerned about monitoring the SSL tunnel itself.) Propose a network design that would allow you to monitor this traffic without installing Snort on the webservers themselves. Draw a simple diagram that illustrates your design. (NOTE: You do not need to worry about specific products, and whether or not there exist products that do what you need for your design. If you need a router/server/etc that does something, assume you could build it.)

Submission Notes