Skip to content

Firewall events

Overview

Cloudflare is a global network designed to make everything you connect to the Internet secure, private, fast, and reliable.

In this documentation, you will learn how to collect and send Cloudflare Firewall events to SEKOIA.IO.

Benefit from SEKOIA.IO built-in rules and upgrade Cloudflare WAF events with the following detection capabilities out-of-the-box.

SEKOIA.IO x Cloudflare WAF events on ATT&CK Navigator

CloudFlare Firewall Block Rule

Detects when one of CloudFlare Firewall rule (previously WAF's custom rule or managed rule) blocked an HTTP request

  • Effort: master
Covenant Default HTTP Beaconing

Detects potential Covenant communications through the user-agent and specific urls

  • Effort: intermediate
Potential Bazar Loader User-Agents

Detects potential Bazar loader communications through the user-agent

  • Effort: elementary
Potential Lemon Duck User-Agent

Detects LemonDuck user agent. The format used two sets of alphabetical characters separated by dashes, for example "User-Agent: Lemon-Duck-[A-Z]-[A-Z]".

  • Effort: elementary
Potential LokiBot User-Agent

Detects potential LokiBot communications through the user-agent

  • Effort: intermediate
SEKOIA.IO Intelligence Feed

Detect threats based on indicators of compromise (IOCs) collected by SEKOIA's Threat and Detection Research team.

  • Effort: elementary
Telegram Bot API Request

Detects suspicious DNS queries to api.telegram.org used by Telegram Bots of any kind

  • Effort: advanced
TrevorC2 HTTP Communication

Detects TrevorC2 HTTP communication based on the HTTP request URI and the user-agent.

  • Effort: elementary

Event Categories

The following table lists the data source offered by this integration.

Data Source Description
Web application firewall logs Cloudflare protect web application with its web application firewall

In details, the following table denotes the type of events produced by this integration.

Name Values
Kind event
Category network
Type ``

Event Samples

Find below few samples of events and how they are normalized by SEKOIA.IO.

{
    "message": "{\"Action\":\"block\",\"ClientIP\":\"113.206.179.28\",\"ClientRequestHost\":\"foo-bar-baz.xyz\",\"ClientRequestMethod\":\"GET\",\"ClientRequestPath\":\"/static/favicon.ico\",\"ClientRequestQuery\":\"\",\"Datetime\":1657630626219000000,\"EdgeResponseStatus\":403,\"RayID\":\"7299f155dda47d6b\"}",
    "event": {
        "action": "block",
        "kind": "event",
        "category": [
            "network"
        ],
        "dataset": "firewall-events",
        "type": [
            "denied"
        ]
    },
    "@timestamp": "2022-07-12T12:57:06.219000Z",
    "source": {
        "ip": "113.206.179.28",
        "address": "113.206.179.28"
    },
    "destination": {
        "domain": "foo-bar-baz.xyz",
        "address": "foo-bar-baz.xyz",
        "top_level_domain": "xyz",
        "registered_domain": "foo-bar-baz.xyz"
    },
    "http": {
        "request": {
            "method": "GET"
        },
        "response": {
            "status_code": 403
        }
    },
    "url": {
        "domain": "foo-bar-baz.xyz",
        "path": "/static/favicon.ico",
        "top_level_domain": "xyz",
        "registered_domain": "foo-bar-baz.xyz"
    },
    "observer": {
        "vendor": "Cloudflare",
        "type": "firewall"
    },
    "cloudflare": {
        "EdgeResponseStatus": 403,
        "RayID": "7299f155dda47d6b"
    },
    "related": {
        "hosts": [
            "foo-bar-baz.xyz"
        ],
        "ip": [
            "113.206.179.28"
        ]
    }
}

Extracted Fields

The following table lists the fields that are extracted, normalized under the ECS format, analyzed and indexed by the parser. It should be noted that infered fields are not listed.

Name Type Description
@timestamp date Date/time when the event originated.
cloudflare.ClientIPClass string The classification of the visitor’s IP address, possible values are: unknown
cloudflare.ClientRefererHost string The referer host
cloudflare.ClientRefererPath string The referer path requested by visitor
cloudflare.ClientRefererQuery string The referer query-string was requested by the visitor
cloudflare.ClientRefererScheme string The referer URL scheme requested by the visitor
cloudflare.EdgeColoCode string IATA airport code of data center that received the request
cloudflare.EdgeResponseStatus number HTTP status code returned by Cloudflare to the client
cloudflare.Kind string The dataset of the event
cloudflare.OriginResponseStatus number status returned by the origin server
cloudflare.OriginatorRayID string The RayID of the request that issued the challenge/jschallenge
cloudflare.RayID string ID of the request
cloudflare.clientASNDescription keyword The ASN of the visitor as string
cloudflare.matchIndex number Rules match index in the chain
cloudflare.metadata object Additional product-specific information. Metadata is organized in key:value pairs. Key and Value formats can vary by Cloudflare security product and can change over time
cloudflare.source keyword The Cloudflare security product triggered by this request
destination.domain keyword The domain name of the destination.
event.action keyword The action captured by the event.
event.category keyword Event category. The second categorization field in the hierarchy.
event.dataset keyword Name of the dataset.
event.kind keyword The kind of the event. The highest categorization field in the hierarchy.
http.request.bytes long Total size in bytes of the request (body and headers).
http.request.method keyword HTTP request method.
http.request.referrer keyword Referrer for this HTTP request.
http.response.status_code long HTTP response status code.
http.version keyword HTTP version.
network.protocol keyword Application protocol name.
observer.type keyword The type of the observer the data is coming from.
observer.vendor keyword Vendor name of the observer.
rule.id keyword Rule ID
rule.ruleset keyword Rule ruleset
source.as.number long Unique number allocated to the autonomous system.
source.geo.country_name keyword Country name.
source.ip ip IP address of the source.
source.port long Port of the source.
tls.cipher keyword String indicating the cipher used during the current connection.
tls.version_protocol keyword Normalized lowercase protocol name parsed from original string.
url.domain keyword Domain of the url.
url.path wildcard Path of the request, such as "/search".
url.query keyword Query string of the request.
url.scheme keyword Scheme of the url.
user_agent.original keyword Unparsed user_agent string.

Configuration

Create the intake on SEKOIA.IO

Go to the intake page and create a new intake from the format Cloudflare.

Configure events forwarding on Cloudflare

Retrieve necessary information

First, you will have to retrieve configuration information. Connect to Cloudflare Console to collect the following :

  1. Cloudflare Email Address
    • This is your Email Address that you can find in My Profile.
  2. Cloudflare API Token
    • Go to My Profile, then on the left panel, click on API Tokens.
    • Click on the Create Token button and select the Read analytics and logs template.
  3. Cloudflare Zone ID :
    • This information is specific to a Website.
    • On the left panel, click on Websites and select the Website you want.
    • On the right panel, there is an API section where you can retrieve the Zone ID.

Configure Logpush

Retrieve all available fields with your subscription

Depending on your subscription, you first need to get all the fields that you can forward to SEKOIA.IO by using the Cloudflare API Retrieve all available fields for a dataset.

With cURL you can use this command:

curl -s -H "X-Auth-Email: <Cloudflare Email Address>" \
-H "X-Auth-Key: <Cloudflare API Token>" \
"https://api.cloudflare.com/client/v4/zones/<Cloudflare Zone ID>/logpush/datasets/firewall_events/fields" \
| jq '.result' # (1)

  1. will return
    {
      "Action": "string; the code of the first-class action the Cloudflare Firewall took on this request. Possible actions are unknown | allow | block | challenge | jschallenge | log | connectionclose | challengesolved | challengefailed | challengebypassed | jschallengesolved | jschallengefailed | jschallengebypassed | bypass | managedchallenge | managedchallengeskipped | managedchallengenoninteractivesolved | managedchallengeinteractivesolved | managedchallengebypassed",
      "ClientASN": "int; the ASN number of the visitor",
      "ClientASNDescription": "string; the ASN of the visitor as string",
      "ClientCountry": "string; country from which request originated",
      "ClientIP": "string; the visitor's IP address (IPv4 or IPv6)",
      "ClientIPClass": "string; the classification of the visitor's IP address, possible values are: unknown | badHost | searchEngine | allowlist | monitoringService | noRecord | scan | tor",
      "ClientRefererHost": "string; the referer host",
      "ClientRefererPath": "string; the referer path requested by visitor",
      "ClientRefererQuery": "string; the referer query-string was requested by the visitor",
      "ClientRefererScheme": "string; the referer URL scheme requested by the visitor",
      "ClientRequestHost": "string; the HTTP hostname requested by the visitor",
      "ClientRequestMethod": "string; the HTTP method used by the visitor",
      "ClientRequestPath": "string; the path requested by visitor",
      "ClientRequestProtocol": "string; the version of HTTP protocol requested by the visitor",
      "ClientRequestQuery": "string; the query-string was requested by the visitor",
      "ClientRequestScheme": "string; the URL scheme requested by the visitor",
      "ClientRequestUserAgent": "string; visitor's user-agent string",
      "Datetime": "int or string; the date and time the event occurred at the edge",
      "EdgeColoCode": "string; the airport code of the Cloudflare datacenter that served this request",
      "EdgeResponseStatus": "int; HTTP response status code returned to browser",
      "Kind": "string; the kind of event, currently only possible values are: firewall",
      "MatchIndex": "int; rules match index in the chain",
      "Metadata": "object; additional product-specific information. Metadata is organized in key:value pairs. Key and Value formats can vary by Cloudflare security product and can change over time",
      "OriginResponseStatus": "int; HTTP origin response status code returned to browser",
      "OriginatorRayID": "string; the RayID of the request that issued the challenge/jschallenge",
      "RayID": "string; the RayID of the request",
      "RuleID": "string; the Cloudflare security product-specific RuleID triggered by this request",
      "Source": "string; the Cloudflare security product triggered by this request. Possible sources are unknown | asn | country | ip | iprange | securitylevel | zonelockdown | waf | firewallrules | uablock | ratelimit | bic | hot | l7ddos | validation | botfight | apishield | botmanagement | dlp | firewallmanaged | firewallcustom"
    }
    

Save the fields you want to send to SEKOIA.IO. It will be used to configure the Logpush job. It this example :

Action,ClientASN,ClientASNDescription,ClientCountry,ClientIP,ClientIPClass,ClientRefererHost,ClientRefererPath,ClientRefererQuery,ClientRefererScheme,ClientRequestHost,ClientRequestMethod,ClientRequestPath,ClientRequestProtocol,ClientRequestQuery,ClientRequestScheme,ClientRequestUserAgent,Datetime,EdgeColoCode,EdgeResponseStatus,Kind,MatchIndex,Metadata,OriginResponseStatus,OriginatorRayID,RayID,RuleID,Source

Create a Logpush job

Configure a Logpush job with the following destination:

https://intake.sekoia.io/plain/batch?header_X-SEKOIAIO-INTAKE-KEY=<YOUR_INTAKE_KEY>

To do so, you can manage Logpush with cURL:

$ curl -X POST https://api.cloudflare.com/client/v4/zones/<Cloudflare Zone ID>/logpush/jobs \
-h "x-auth-email: <Cloudflare Email Address>" \
-H "X-Auth-Key: <Cloudflare API Token>" \
-H "Content-Type: application/json" \
--data '{
    "dataset": "firewall_events",
    "enabled": true,
    "max_upload_bytes": 5000000,
    "max_upload_records": 1000,
    "logpull_options":"fields=<LIST_OF_FIELDS>&timestamps=rfc3339",
    "destination_conf": "https://intake.sekoia.io/plain/batch?header_X-SEKOIAIO-INTAKE-KEY=<YOUR_INTAKE_KEY>"
}' # (1)
  1. will return
    {
      "errors": [],
      "messages": [],
      "result": {
        "id": 147,
        "dataset": "firewall_events",
        "enabled": false,
        "name": "<DOMAIN_NAME>",
        "logpull_options": "fields=<LIST_OF_FIELDS>&timestamps=rfc3339",
        "destination_conf": "https://intake.sekoia.io/plain/batch?header_X-SEKOIAIO-INTAKE-KEY=<YOUR_INTAKE_KEY>",
        "last_complete": null,
        "last_error": null,
        "error_message": null
      },
      "success": true
    }
    

Important

Replace :

  • <YOUR_INTAKE_KEY> with the Intake key you generated in the Create the intake on SEKOIA.IO step.
  • <LIST_OF_FIELDS> with the fields you identified in the Retrieve all available fields with your subscription section (for instance Action,ClientASN,ClientASNDescription,ClientCountry,ClientIP,ClientIPClass,ClientRefererHost,ClientRefererPath,ClientRefererQuery,ClientRefererScheme,ClientRequestHost,ClientRequestMethod,ClientRequestPath,ClientRequestProtocol,ClientRequestQuery,ClientRequestScheme,ClientRequestUserAgent,Datetime,EdgeColoCode,EdgeResponseStatus,Kind,MatchIndex,Metadata,OriginResponseStatus,OriginatorRayID,RayID,RuleID,Source).
Useful Cloudflare API endpoints

On their documentation, Cloudflare provides a list API endpoints you can use. Here is some useful endpoints :

  • https://api.cloudflare.com/client/v4/zones/<ZONE_ID>/logpush/jobs/<JOB_ID> to verify the job you previously created is correct (you need to specify the JOB_ID)
  • https://api.cloudflare.com/client/v4/zones/<ZONE_ID>/logpush/datasets/<DATASET>/jobs to get all the jobs for a specific dataset (dns_log, firewalls_events or http_requests in our case)
  • https://api.cloudflare.com/client/v4/zones/<ZONE_ID>/logpush/jobs/<JOB_ID> to update a job if you noticed a mistake after the creation of the job (wrong fields, wrong SEKOIA API Key...)