Configuring an FTP Inspection Policy Map for Additional Inspection Control
FTP command filtering and security checks are provided using strict FTP inspection for improved security and control. Protocol conformance includes packet length checks, delimiters and packet format checks, command terminator checks, and command validation.
Blocking FTP based on user values is also supported so that it is possible for FTP sites to post files for download, but restrict access to certain users. You can block FTP connections based on file type, server name, and other attributes. System message logs are generated if an FTP connection is denied after inspection.
If you want FTP inspection to allow FTP servers to reveal their system type to FTP clients, and limit the allowed FTP commands, then create and configure an FTP map. You can then apply the FTP map when you enable FTP inspection according to the "Configuring Application Inspection" section on page 25-5.
To create an FTP map, perform the following steps:
Step 1 (Optional) Add one or more regular expressions for use in traffic matching commands according to the "Creating a Regular Expression" section on page 21-12. See the types of text you can match in the match commands described in Step 3.
Step 2 (Optional) Create one or more regular expression class maps to group regular expressions according to the "Creating a Regular Expression Class Map" section on page 21-14.
Step 3 (Optional) Create an FTP inspection class map by performing the following steps.
A class map groups multiple traffic matches. Traffic must match all of the match commands to match the class map. You can alternatively identify match commands directly in the policy map. The difference between creating a class map and defining the traffic match directly in the inspection policy map is that the class map lets you create more complex match criteria, and you can reuse class maps.
To specify traffic that should not match the class map, use the match not command. For example, if the match not command specifies the string "example.com," then any traffic that includes "example.com" does not match the class map.
For the traffic that you identify in this class map, you can specify actions such as drop, drop-connection, reset, mask, set the rate limit, and/or log the connection in the inspection policy map.
If you want to perform different actions for each match command, you should identify the traffic directly in the policy map.
a. Create the class map by entering the following command:
hostname(config)# class-map type inspect ftp [match-all] class_map_name hostname(config-cmap)#
Where class_map_name is the name of the class map. The match-all keyword specifies that traffic must match all criteria to match the class map. match-all is the default and only option. The CLI enters class-map configuration mode, where you can enter one or more match commands.
b. (Optional) To add a description to the class map, enter the following command:
hostname(config-cmap)# description string c. (Optional) To match a filename for FTP transfer, enter the following command:
hostname(config-cmap)# match [not] filename regex [regex_name | class regex_class_name]
Where the regex_name is the regular expression you created in Step 1. The class regex_class_name is the regular expression class map you created in Step 2.
d. (Optional) To match a file type for FTP transfer,, enter the following command:
hostname(config-cmap)# match [not] filetype regex [regex_name | class regex_class_name]
Where the regex_name is the regular expression you created in Step 1. The class regex_class_name is the regular expression class map you created in Step 2.
e. (Optional) To disallow specific FTP commands, use the following command:
hostname(config-cmap)# match [not] request-command ftp_command [ftp_command...]
Where ftp_command with one or more FTP commands that you want to restrict. See Table 25-3 for a list of the FTP commands that you can restrict.
|
request-command deny Option |
Purpose |
|
appe |
Disallows the command that appends to a file. |
|
cdup |
Disallows the command that changes to the parent directory of the current working directory. |
|
dele |
Disallows the command that deletes a file on the server. |
|
get |
Disallows the client command for retrieving a file from the server. |
|
help |
Disallows the command that provides help information. |
|
mkd |
Disallows the command that makes a directory on the server. |
|
put |
Disallows the client command for sending a file to the server. |
|
rmd |
Disallows the command that deletes a directory on the server. |
|
request-command deny 0ption |
Purpose |
|
rnfr |
Disallows the command that specifies rename-from filename. |
|
rnto |
Disallows the command that specifies rename-to filename. |
|
site |
Disallows the command that are specific to the server system. Usually used for remote administration. |
|
stou |
Disallows the command that stores a file using a unique file name. |
f. (Optional) To match an FTP server, enter the following command:
hostname(config-cmap)# match [not] server regex [regex_name | class regex_class_name]
Where the regex_name is the regular expression you created in Step 1. The class regex_class_name is the regular expression class map you created in Step 2.
g. (Optional) To match an FTP username, enter the following command:
hostname(config-cmap)# match [not] username regex [regex_name | class regex_class_name]
Where the regex_name is the regular expression you created in Step 1. The class regex_class_name is the regular expression class map you created in Step 2.
Step 4 Create an FTP inspection policy map, enter the following command:
hostname(config)# policy-map type inspect ftp policy_map_name hostname(config-pmap)#
Where the policy_map_name is the name of the policy map. The CLI enters policy-map configuration mode.
Step 5 (Optional) To add a description to the policy map, enter the following command:
hostname(config-pmap)# description string
Step 6 To apply actions to matching traffic, perform the following steps.
a. Specify the traffic on which you want to perform actions using one of the following methods:
• Specify the FTP class map that you created in Step 3 by entering the following command:
hostname(config-pmap)# class class_map_name hostname(config-pmap-c)#
• Specify traffic directly in the policy map using one of the match commands described in Step 3. If you use a match not command, then any traffic that does not match the criterion in the match not command has the action applied.
b. Specify the action you want to perform on the matching traffic by entering the following command:
hostname(config-pmap-c)# {[drop [send-protocol-error] |
drop-connection [send-protocol-error]| mask | reset] [log] | rate-limit message_rate}
Not all options are available for each match or class command. See the CLI help or the Cisco Security Appliance Command Reference for the exact options available.
The drop keyword drops all packets that match.
The send-protocol-error keyword sends a protocol error message.
The drop-connection keyword drops the packet and closes the connection.
The mask keyword masks out the matching portion of the packet.
The reset keyword drops the packet, closes the connection, and sends a TCP reset to the server and/or client.
The log keyword, which you can use alone or with one of the other keywords, sends a system log message.
The rate-limit message_rate argument limits the rate of messages.
You can specify multiple class or match commands in the policy map. For information about the order of class and match commands, see the "Defining Actions in an Inspection Policy Map" section on page 21-8.
Step 7 To configure parameters that affect the inspection engine, perform the following steps:
a. To enter parameters configuration mode, enter the following command:
hostname(config-pmap)# parameters hostname(config-pmap-p)#
b. To mask the greeting banner from the FTP server, enter the following command:
hostname(config-pmap-p)# mask-banner c. To mask the reply to syst command, enter the following command:
hostname(config-pmap-p)# mask-syst-reply
Before submitting a username and password, all FTP users are presented with a greeting banner. By default, this banner includes version information useful to hackers trying to identify weaknesses in a system. The following example shows how to mask this banner:
hostname(config)# policy-map type inspect ftp mymap hostname(config-pmap)# parameters hostname(config-pmap-p)# mask-banner hostname(config)# class-map match-all ftp-traffic hostname(config-cmap)# match port tcp eq ftp hostname(config)# policy-map ftp-policy hostname(config-pmap)# class ftp-traffic hostname(config-pmap-c)# inspect ftp strict mymap hostname(config)# service-policy ftp-policy interface inside
Continue reading here: GTP Inspection Overview
Was this article helpful?