Block HTTPS upload traffic that includes Visa or Mastercard information using evaluation via logical expression
This example will allow users to create a subset of the existing DLP data type, credit-card. It can be very beneficial for an organization that wants to prevent only certain types of credit cards and not all.
This configuration will block HTTPS traffic that includes Visa or Mastercard information. Two dictionary entries with DLP data-type regex are created with custom patterns to match Visa and Mastercard numbers respectively, and a third dictionary entry is created with pre-defined data type credit-card. All three entries are used in the sensor using evaluation via logical expression to further supplement the detection.
In the CLI, evaluation via logical expression can be defined using the command match-eval
. It is a tool used to combine multiple entries to define an accurate DLP sensor.
In this example, a Microsoft Office document with Visa credit card information is sent securely to the receiver using the HTTP POST method. The FortiProxy intercepts the traffic using deep inspection and blocks the traffic as it matches the DLP profile configured on this FortiProxy.
To block HTTPS upload traffic that includes Visa or Mastercard credit card information in the GUI:
-
Configure the DLP dictionary:
- Go to Security Profiles > Data Loss Prevention, select the Dictionaries tab, and click Create New.
-
Create an entry for Visa:
-
Enter a name (Finance_Credit_Card_Visa).
-
In the Dictionary Entries section, click Create New.
-
Set the Type to regex.
-
Set Pattern to 4[0-9]{12}(?:[0-9]{3}) and click OK.
-
Click OK to save the dictionary.
-
-
Create an entry for Mastercard:
-
Enter a name (Finance_Credit_Card_Mastercard).
-
In the Dictionary Entries section, click Create New.
-
Set the Type to regex.
-
Set Pattern to (?:5[1-5][0-9]{2}|222[1-9]|22[3-9][0-9]|2[3-6][0-9]{2}|27[01][0-9]|2720)[0-9]{12} and click OK.
-
Click OK to save the dictionary.
-
-
Create an entry for Credit Card:
-
Enter a name (CC_Number).
-
In the Dictionary Entries section, click Create New.
-
Set the Type to credit-card and click OK.
-
Click OK to save the dictionary.
-
-
Configure the DLP sensor:
- Go to Security Profiles > Data Loss Prevention, select the Sensors tab, and click Create New.
-
Enter a name (Finance_Credit_Card_High).
-
In the Sensor Entries section, click Create New.
-
Set the Dictionary to Finance_Credit_Card_Visa and click OK.
-
Repeat the previous step twice to add Finance_Credit_Card_Mastercard and CC_Number in this order.
-
Click OK to save the sensor.
-
Edit the newly created sensor.
-
Set the Logical relationship to Evaluate.
-
In the Evaluated by field, enter (dict(1) > 0 && dict(3) > 0) || (dict(2) > 0 && dict(3) > 0).
-
Click OK to save the sensor.
For the DLP sensor with the Logical relationship set to Evaluate, Count and Status of any sensor entry will be ignored.
-
Configure the DLP profile:
- Go to Security Profiles > Data Loss Prevention, select the Profiles tab, and click Create New.
-
Enter a name (cc-block).
-
In the Rules section, click Create New.
-
Configure the following settings:
Name 1 Sensors Finance Credit Card High Severity Critical Action Block Type File File type builtin-patterns Protocol HTTP-POST, HTTP-GET -
Click OK.
-
Click OK to save the profile.
-
Add the DLP profile to a policy:
-
Go to Policy & Objects > Policy and click Create New.
-
Set the Type to any except SSH Tunnel which does not support DLP.
-
In the Security Profiles section, enable DLP Profile and select cc-block.
-
Set SSL/SSH Inspection to deep-inspection to inspect HTTPS traffic.
-
Configure the other settings as needed.
-
Click OK.
-
When a Visa or Mastercard credit card is included in HTTP GET or POST traffic, the file is blocked and a DLP log is generated. See the Sample log for details on how to test this configuration.
To block HTTPS upload traffic that includes Visa or Mastercard credit card information in the CLI:
-
Configure the DLP dictionary:
config dlp dictionary edit "Finance_Credit_Card_Visa" config entries edit 1 set type "regex" set pattern "4[0-9]{12}(?:[0-9]{3})" set repeat enable set comment "Visa" next end next edit "Finance_Credit_Card_Mastercard" config entries edit 1 set type "regex" set pattern "(?:5[1-5][0-9]{2}|222[1-9]|22[3-9][0-9]|2[3-6][0-9]{2}|27[01][0-9]|2720)[0-9]{12}" set repeat enable set comment "Mastercard" next end next edit "CC_Number" config entries edit 1 set type "credit-card" next end next end
-
Configure the DLP sensor:
config dlp sensor edit "Finance_Credit_Card_High" config entries edit 1 set dictionary "Finance_Credit_Card_Visa" next edit 2 set dictionary "Finance_Credit_Card_Mastercard" next edit 3 set dictionary "CC_Number" next end set match-type match-eval set eval "(dict(1) > 0 && dict(3) > 0) || (dict(2) > 0 && dict(3) > 0)" next end
-
Configure the DLP profile:
config dlp profile edit "cc_block" set feature-set proxy config rule edit 1 set name "1" set severity critical set proto http-get http-post set filter-by sensor set file-type 1 set sensor "Finance_Credit_Card_High" set action block next end next end
-
Add the DLP profile to a policy:
config firewall policy edit 1 set srcintf "port2" set dstintf "port3" set action accept set srcaddr "all" set dstaddr "all" set schedule "always" set service "ALL" set utm-status enable set ssl-ssh-profile "deep-inspection" set dlp-profile "cc_block" next end
When a Visa or Mastercard credit card is included in HTTP GET or POST traffic, a replacement message appears because it is blocked. A DLP log is generated. See the Sample log for details on how to test this configuration.
Sample log
From Windows, the following command can be used to generate a sample log via HTTP POST traffic, using the cURL tool to post data, which contains a sample Visa credit card number. See sample-data for sample credit card numbers.
# curl –k -d 4024007149133315 https://192.168.10.13/cc.doc -o? 1: date=2023-03-17 time=15:37:41 eventtime=1679092660998869199 tz="-0700" logid="0954024576" type="utm" subtype="dlp" eventtype="dlp" level="warning" vd="root" filteridx=1 filtername="1" dlpextra="builtin-patterns;Finance_Credit_Card_High" filtertype="sensor" filtercat="file" severity="critical" policyid=1 poluuid="26540ed0-ae54-51ed-80eb-89af8af4d53f" policytype="policy" sessionid=14854 epoch=570215534 eventid=0 srcip=172.20.120.13 srcport=58012 srccountry="Reserved" srcintf="port2" srcintfrole="undefined" srcuuid="3342cb44-9140-51ed-5dbe-8e0787bedeec" dstip=192.168.10.13 dstport=443 dstcountry="Reserved" dstintf="port3" dstintfrole="wan" dstuuid="3342cb44-9140-51ed-5dbe-8e0787bedeec" proto=6 service="HTTPS" filetype="msoffice" direction="incoming" action="block" hostname="192.168.10.13" url="https://192.168.10.13/cc.doc" agent="curl/7.83.1" httpmethod="POST" filename="cc.doc" filesize=12288 profile="cc-block"