Contents
Introduction IntroductionThe Embedded Event Manager (EEM) functionality initially added in Cisco IOS Software versions 12.0(26)S and 12.3(4)T adds reactive capabilities that can aid the security posture of a network. At a very simple level, EEM detects events and performs actions. At a more advanced level, EEM can leverage Tcl scripts to perform advanced, dynamic actions based on events. These capabilities are especially useful in situations in which logging and MIB data are insufficient or do not exist, or when actions must be performed without the assumption of network access. EEM is a comprehensive system with several components. At the center of EEM are event detectors (EDs), actions, and policies. There are two types of policies: applets and scripts. Event DetectorsEDs serve as the first line of the EEM system. Configured EDs are constantly monitoring the system for an event to take place. Every applet or script-based policy registers with exactly one ED. For script-based policies, this registration must be the first non-comment line in the policy. The available EDs are detailed in the following table:
Refer to the Cisco IOS documentation for the Embedded Event Manager at http://www.cisco.com/univercd/cc/td/doc/product/software/ios124/124newft/124t/124t2/ht_eem.htm for more information regarding EDs. ActionsAfter being triggered by an ED, a policy can perform one or many actions. The following actions are detailed in the Cisco IOS EEM documentation.
Applets and ScriptsPolicies that exist entirely in the configuration of the router and use a limited command set are known as applets; the much more advanced and flexible Tcl-based policies are called scripts. Applets provide an easy method for implementing reactive capabilities in a network device. However, their functionality is severely limited when compared to scripts. For example, it is not possible to parse CLI output within an applet. With applets, the selection of an event and one or more actions can be plainly viewed using the show running-config privileged EXEC command. Scripts are Tcl-based and exist in flat-text files on the device. After an administrator copies scripts to an IOS device, it is possible to view the contents of a script using the more device:tcl-script EXEC command. These policies are registered using the event manager policy policy-filename.tcl global configuration command. These Tcl files are afforded nearly all the functionality of standard Tcl. Cisco-specific functionality is also available in Cisco IOS versions that support EEM. Specific limitations of Tcl on IOS are available at http://www.cisco.com/en/US/products/ps6441/products_configuration_guide_chapter09186a00807c6784.html#wp1014310. See Writing Embedded Event Manager Policies Using Tcl at http://www.cisco.com/en/US/products/ps6441/products_configuration_guide_chapter09186a00807c6784.html for more information regarding the creation of Tcl-based policies. Security Relevance of EEMWith EEM, it is possible to alert the security operations staff if certain, previously uninstrumented, events take place. For example, a router can send a syslog message when its AAA configuration has been removed or send an e-mail if the number of packets dropped by Unicast RPF crosses a threshold. The possibilities range from simple applet-based configurations to elaborate Tcl scripts. It is a common scenario that identification or classification ACLs are placed at the edge of the network. However, ACL logging is rarely enabled due to the high CPU load impact. With EEM, it is possible to generate a syslog message when a configurable threshold has been crossed without encountering the ACL logging–induced CPU load. A sample EEM script for generating this message is in the “Examples” section of this document. A similar scenario would be the creation of a script to generate syslog messages when Unicast RPF failures are seen on a router. This capability demonstrates the how EEM provides insight into functionality for which syslogs and MIBS do not exist or where they have serious performance and availability implications. Another example of the usefulness of EEM includes the ability to block CLI commands from being executed. For example, users entering the tclsh command may be attempting to exploit the vulnerability disclosed by Cisco in Cisco Security Notice: Response to AAA Command Authorization Bypass. With EEM, administrators can detect users executing this command, then send a syslog message and block execution of the command. EEM ExamplesThe examples in this section demonstrate the security value of EEM; however, they are by no means an exhaustive catalog of how EEM can increase the security of an IOS device. These examples range from the very simple (blocking access to an unused and potentially vulnerable command) to the more complex (generating syslog messages based on statistics and user-configurable thresholds). Many of the lines in these examples are too long to be correctly displayed. As a result, lines have been wrapped using the backslash (\) convention. This will allow Tcl scripts to be directly cut and pasted into standalone files. However, IOS configuration lines wrapped with the backslash must be manually reconstructed before being placed on any device. Blocking Commands and Sending SyslogsThe example below demonstrates the ability of an EEM policy, and specifically the CLI ED, to block command execution. This is accomplished using the CLI ED in synchronous mode and using the _exit_status variable. The command is denied if _exit_status is 0 ; it is permitted if _exit_status is not 0. This policy denies access by any user to the tclsh command. Access to this command in environments that do not use Tcl may be an attempt to exploit the AAA bypass vulnerability detailed at http://www.cisco.com/warp/public/707/cisco-response-20060125-aaatcl.shtml.
With the preceding policy configured, attempts to execute tclsh are blocked and logged.
Threshold-Based Logging for ACL-Dropped PacketsFor environments in which IP Options are not used, it may be desirable to filter packets that contain IP options at the network edge. Administrators can implement infrastructure ACLs to perform this filtering. However, without ACL logging, it may be difficult and extremely tedious to detect when these ACLs are filtering packets. Using EEM, administrators can check the ACL counters at regular intervals and send a syslog message if drops are seen. This example details a script-based policy that interacts with the CLI and is configured using router configuration-based environment variables. The use of environment variables makes it possible to configure the rate-based thresholds without editing the script itself. In this example, a syslog is generated when 10 packets (EEM_ACL_COUNTERS_THRESHOLD) are dropped by a particular ACL (EEM_ACL_COUNTERS_ACL_NAME) in 20 seconds (EEM_ACL_COUNTERS_INTERVAL). These environment variables are configured using the following global configuration commands.
Because scripts exist in files on the flash file system of the router, their configuration is not present in the router configuration. However, the script must be registered with EEM via the event manager policy script-name global configuration command. The following command registers this script:
The following example shows the EEM script that performs the desired actions. The comments within the script describe its operation.
If the threshold is crossed in the interval specified—10 packets in 20 seconds in the preceding example—a syslog message is generated. This message will be sent to all logging destinations that have been configured on the router. The following is an example of the syslog generated: *Feb 20 22:42:52.011: %HA_EM-5-LOG: tmpsys:/eem_policy/EEM-ACL-COUNTERS.tcl: Sending a Syslog Message When Unicast RPF Failures OccurThis example details a script-based policy that interacts with the CLI and is configured using router configuration-based environment variables. The use of environment variables makes it possible to configure the rate-based thresholds without editing the script itself. In this example, a syslog message is generated when 10 packets (EEM_URPF_COUNTER_THRESHOLD) are dropped by Unicast RPF in 20 seconds (EEM_URPF_COUNTER_INTERVAL). These environment variables are configured using the following global configuration commands:
The command needed to register this script is shown below.
The following script-based policy performs the actions described above. Because scripts exist in files on the file system of the router, their configuration is not present in the router configuration. The following example shows the EEM script that performs the desired actions.
If the threshold is crossed in the interval specified—10 packets in 20 seconds in the preceding example—a syslog message is generated. This will be sent to all logging destinations that have been configured on the router. The following is an example of the syslog message generated. *Feb 22 05:57:53.759: %HA_EM-5-LOG: tmpsys:/eem_policy/EEM-URPF-COUNTER.tcl: Building a Control Plane Policing Baseline Using EEMThe policies earlier in this document provide a reactive functionality that overcomes an existing limitation. This next policy is different in that it provides a somewhat proactive capability. This script parses the configuration of Control Plane Policing on a device and records the number of packets and bytes matching each applied class map. The script output is saved into a CSV file for offline processing. Together, this script and the offline processing will allow an organization to tune a CoPP configuration based on real-world packet rates. This script uses the EEM timer ED to execute periodically as well as the EEM-native Tcl to interact with the CLI and parse its output. The configuration of this script is controlled using two environment variables. The first, EEM_COPP_BASELINE_DIR, is used to determine the output location for the created CSV files. The second, EEM_COPP_BASELINE_INTERVAL is used to configure the interval in seconds between two executions of the baselining script.
The following command registers this script:
The contents of the TCL policy follow. The comments within the code describe the operation of the script.
This policy creates a new output CSV file for each day. The dir command can be used on the directory configured in EEM_COPP_BASELINE_DIR to display the files currently present. The following is an example using the directory disk0:e/ :
The contents of the file can be examined on the router using the more command. router#more disk0:/e/2007-03-06_EEM_COPP_BASE.csv time,CM-COPP-MGMT packets,CM-COPP-MGMT bytes,CM-COPP-BGP packets,CM-COPP-BGP bytes,class-default packets,class-default bytes, 2007-03-06 13:36:45,0,0,0,0,127,32052, 2007-03-06 13:37:45,0,0,0,0,5,1739, 2007-03-06 13:38:45,0,0,0,0,3,1055, 2007-03-06 13:39:45,0,0,0,0,5,1739, 2007-03-06 13:40:45,0,0,0,0,5,1739, 2007-03-06 13:41:45,0,0,0,0,3,1055, 2007-03-06 13:42:45,0,0,0,0,5,1739, 2007-03-06 13:43:45,0,0,0,0,5,1739, 2007-03-06 13:44:45,0,0,0,0,3,1055, ... ReferencesCisco Beyond Embedded Event Manager Embedded Resource Manager IOS Network Management Command Reference: Writing Embedded Event Manager Policies Using Tcl: This document is part of the Cisco Security Center. This document is provided on an "as is" basis and does not imply any kind of guarantee or warranty, including the warranties of merchantability or fitness for a particular use. Your use of the information on the document or materials linked from the document is at your own risk. Cisco reserves the right to change or update this document at any time. |
