Gateway DNS
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 Gateway DNS logs to SEKOIA.IO.
Related Built-in Rules
Benefit from SEKOIA.IO built-in rules and upgrade Cloudflare Gateway DNS with the following detection capabilities out-of-the-box.
SEKOIA.IO x Cloudflare Gateway DNS on ATT&CK Navigator
SEKOIA.IO Intelligence Feed
Detect threats based on indicators of compromise (IOCs) collected by SEKOIA's Threat and Detection Research team.
- Effort: elementary
Sliver DNS Beaconing
Detects suspicious DNS queries known from Sliver beaconing
- Effort: intermediate
Event Categories
The following table lists the data source offered by this integration.
Data Source | Description |
---|---|
DNS records |
DNS Gateway logs |
In details, the following table denotes the type of events produced by this integration.
Name | Values |
---|---|
Kind | event |
Category | network |
Type | info |
Event Samples
Find below few samples of events and how they are normalized by SEKOIA.IO.
{
"message": "{\"ApplicationID\":0,\"ColoCode\":\"CDG\",\"ColoID\":533,\"Datetime\":\"2023-02-24T12:12:07Z\",\"DeviceID\":\"\",\"DeviceName\":\"\",\"DstIP\":\"172.12.12.1\",\"DstPort\":23,\"Email\":\"\",\"Location\":\"AWS VM\",\"LocationID\":\"a26c188f-10c2-4333-8ed4-c823fafa06f6\",\"MatchedCategoryIDs\":[],\"MatchedCategoryNames\":[],\"Policy\":\"\",\"PolicyID\":\"\",\"Protocol\":\"udp\",\"QueryCategoryIDs\":[],\"QueryCategoryNames\":[],\"QueryName\":\"ip-111-30-40-252.eu-west-3.compute.internal\",\"QueryNameReversed\":\"internal.compute.eu-west-3.ip-111-30-40-252\",\"QuerySize\":72,\"QueryType\":1,\"QueryTypeName\":\"A\",\"RCode\":3,\"RData\":[],\"ResolvedIPs\":[\"104.18.4.35\",\"104.18.5.35\"],\"ResolverDecision\":\"allowedOnNoPolicyMatch\",\"SrcIP\":\"12.122.186.81\",\"SrcPort\":42424,\"TimeZone\":\"\",\"TimeZoneInferredMethod\":\"noScheduleConfigured\",\"UserID\":\"\"}",
"event": {
"category": [
"network"
],
"dataset": "gateway_dns",
"kind": "event",
"type": [
"info"
]
},
"destination": {
"ip": "172.12.12.1",
"port": 23,
"address": "172.12.12.1"
},
"@timestamp": "2023-02-24T12:12:07Z",
"dns": {
"question": {
"name": "ip-111-30-40-252.eu-west-3.compute.internal",
"type": "A",
"subdomain": "ip-111-30-40-252.eu-west-3.compute"
},
"resolved_ip": [
"104.18.4.35",
"104.18.5.35"
],
"response_code": "NXDomain"
},
"network": {
"protocol": "dns",
"transport": "udp"
},
"observer": {
"type": "dns",
"vendor": "Cloudflare"
},
"source": {
"port": 42424,
"ip": "12.122.186.81",
"address": "12.122.186.81"
},
"cloudflare": {
"ApplicationID": 0,
"ColoCode": "CDG",
"ColoID": 533,
"Location": "AWS VM",
"LocationID": "a26c188f-10c2-4333-8ed4-c823fafa06f6",
"QueryNameReversed": "internal.compute.eu-west-3.ip-111-30-40-252",
"QuerySize": 72,
"QueryType": "1",
"ResolverDecision": "allowedOnNoPolicyMatch",
"TimeZoneInferredMethod": "noScheduleConfigured"
},
"related": {
"ip": [
"104.18.4.35",
"104.18.5.35",
"12.122.186.81",
"172.12.12.1"
],
"hosts": [
"ip-111-30-40-252.eu-west-3.compute.internal"
]
}
}
{
"message": "{\"ApplicationID\":0,\"ColoCode\":\"CDG\",\"ColoID\":534,\"Datetime\":\"2023-05-02T16:24:19Z\",\"DeviceID\":\"b72ac397-e5c3-913e-11ed-03face9f2b6b\",\"DeviceName\":\"DESKTOP-ABCDEF\",\"DstIP\":\"162.159.36.1\",\"DstPort\":443,\"Email\":\"john.doe@test.com\",\"Location\":\"loc-01\",\"LocationID\":\"a26c158f-10c2-4223-8ed4-c845fafa06f6\",\"MatchedCategoryIDs\":[],\"MatchedCategoryNames\":[],\"Policy\":\"\",\"PolicyID\":\"\",\"Protocol\":\"https\",\"QueryCategoryIDs\":[21,80],\"QueryCategoryNames\":[\"Security threats\",\"Command and Control & Botnet\"],\"QueryName\":\"commandandcontrolandbotnet.testcategory.com\",\"QueryNameReversed\":\"com.testcategory.commandandcontrolandbotnet\",\"QuerySize\":72,\"QueryType\":65,\"QueryTypeName\":\"HTTPS\",\"RCode\":0,\"RData\":[{\"type\":\"65\",\"data\":\"GmNvbW1hbmRhbmRjb250cm9sYW5kYm90bmV0DHRlc3RjYXRlZ29yeQNjb20AAEEAAQAAADwAOgABAAABAAMCaDIABAAIaBIEI2gSBSMABgAgJgZHAAAAAAAAAAAAaBIEIyYGRwAAAAAAAAAAAGgSBSM=\"}],\"ResolvedIPs\":[],\"ResolverDecision\":\"allowedOnNoPolicyMatch\",\"SrcIP\":\"15.188.186.81\",\"SrcPort\":0,\"TimeZone\":\"\",\"TimeZoneInferredMethod\":\"noScheduleConfigured\",\"UserID\":\"2c46cdd9-92e3-5e5f-b3cf-67965d7c33e3\"}",
"event": {
"category": [
"network"
],
"dataset": "gateway_dns",
"kind": "event",
"type": [
"info"
]
},
"destination": {
"ip": "162.159.36.1",
"port": 443,
"address": "162.159.36.1"
},
"@timestamp": "2023-05-02T16:24:19Z",
"device": {
"id": "b72ac397-e5c3-913e-11ed-03face9f2b6b"
},
"dns": {
"question": {
"name": "commandandcontrolandbotnet.testcategory.com",
"type": "HTTPS",
"top_level_domain": "com",
"subdomain": "commandandcontrolandbotnet",
"registered_domain": "testcategory.com"
},
"resolved_ip": [],
"response_code": "NoError"
},
"host": {
"hostname": "DESKTOP-ABCDEF",
"name": "DESKTOP-ABCDEF"
},
"network": {
"protocol": "dns",
"transport": "https"
},
"observer": {
"type": "dns",
"vendor": "Cloudflare"
},
"source": {
"port": 0,
"ip": "15.188.186.81",
"address": "15.188.186.81"
},
"user": {
"email": "john.doe@test.com",
"id": "2c46cdd9-92e3-5e5f-b3cf-67965d7c33e3"
},
"cloudflare": {
"ApplicationID": 0,
"ColoCode": "CDG",
"ColoID": 534,
"Location": "loc-01",
"LocationID": "a26c158f-10c2-4223-8ed4-c845fafa06f6",
"QueryCategoryIDs": [
21,
80
],
"QueryCategoryNames": [
"Security threats",
"Command and Control & Botnet"
],
"QueryNameReversed": "com.testcategory.commandandcontrolandbotnet",
"QuerySize": 72,
"QueryType": "65",
"RData": [
{
"type": "65",
"data": "GmNvbW1hbmRhbmRjb250cm9sYW5kYm90bmV0DHRlc3RjYXRlZ29yeQNjb20AAEEAAQAAADwAOgABAAABAAMCaDIABAAIaBIEI2gSBSMABgAgJgZHAAAAAAAAAAAAaBIEIyYGRwAAAAAAAAAAAGgSBSM="
}
],
"ResolverDecision": "allowedOnNoPolicyMatch",
"TimeZoneInferredMethod": "noScheduleConfigured"
},
"related": {
"hosts": [
"DESKTOP-ABCDEF",
"commandandcontrolandbotnet.testcategory.com"
],
"ip": [
"15.188.186.81",
"162.159.36.1"
]
}
}
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.ApplicationID |
number |
ID of the application the domain belongs to (for example, 1, 2). Set to 0 when no ApplicationID is matched. |
cloudflare.ColoCode |
keyword |
The name of the colo that received the DNS query (for example, ‘SJC’, ‘MIA’, ‘IAD’). |
cloudflare.ColoID |
number |
The ID of the colo that received the DNS query (for example, 46, 72, 397). |
cloudflare.Location |
keyword |
Name of the location the DNS request is coming from. Location is created by the customer (for example, ‘Office NYC’). |
cloudflare.LocationID |
keyword |
UUID of the location the DNS request is coming from. Location is created by the customer (for example, ‘7bdc7a9c-81d3-4816-8e56-000000000000’). |
cloudflare.MatchedCategoryIDs |
array |
ID or IDs of category that the domain was matched with the policy (for example, [7,12,28,122,129,163]). |
cloudflare.MatchedCategoryNames |
array |
Name or names of category that the domain was matched with the policy (for example, [‘Photography’, ‘Weather’]). |
cloudflare.Policy |
keyword |
ID of the policy/rule that was applied (if any). |
cloudflare.QueryCategoryIDs |
array |
ID or IDs of category that the domain belongs to (for example, [7,12,28,122,129,163]). |
cloudflare.QueryCategoryNames |
array |
Name or names of category that the domain belongs to (for example, [‘Photography’, ‘Weather’]). |
cloudflare.QueryNameReversed |
keyword |
Query name in reverse (for example, ‘com.example’). |
cloudflare.QuerySize |
number |
The size of the DNS request in bytes (for example, 151). |
cloudflare.QueryType |
keyword |
The type of DNS query (for example, ‘1’, ‘28’, ‘15’, or ‘16’). |
cloudflare.RData |
array |
The rdata objects (for example, {“type”:“5”,“data”:“dns-packet-placeholder…”}). |
cloudflare.ResolverDecision |
keyword |
Result of the DNS query (for example, ‘overrideForSafeSearch’). |
cloudflare.TimeZone |
keyword |
Time zone used to calculate the current time, if a matched rule was scheduled with it. |
cloudflare.TimeZoneInferredMethod |
keyword |
Method used to pick the time zone for the schedule (from rule/ from user ip/ from local time). |
destination.ip |
ip |
IP address of the destination. |
destination.port |
long |
Port of the destination. |
dns.question.name |
keyword |
The name being queried. |
dns.question.type |
keyword |
The type of record being queried. |
dns.resolved_ip |
ip |
Array containing all IPs seen in answers.data |
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. |
event.type |
keyword |
Event type. The third categorization field in the hierarchy. |
host.hostname |
keyword |
Hostname of the host. |
network.protocol |
keyword |
Application protocol name. |
network.transport |
keyword |
Protocol Name corresponding to the field iana_number . |
observer.type |
keyword |
The type of the observer the data is coming from. |
observer.vendor |
keyword |
Vendor name of the observer. |
source.ip |
ip |
IP address of the source. |
source.port |
long |
Port of the source. |
user.email |
keyword |
User email address. |
user.id |
keyword |
Unique identifier of the user. |
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 :
-
Cloudflare API Token
- Go to
My Profile
, then on the left panel, click onAPI Tokens
. - Click on the
Create Token
button and select theCreate Custom Token
entry. - Give a name to your token and set the following permissions:
Scope Group Level Account Account Analytics Read Account Logs Read Account Logs Edit Zone Logs Read Zone Logs Edit - If you want zerotrust logs you should also add:
Scope Group Level Account Zero Trust Read - Go to
-
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 theZone ID
.
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/accounts/<CLOUDFLARE_ACCOUNT_ID>/logpush/jobs' \
-H 'Authorization: Bearer <CLOUDFLARE_API_TOKEN>' \
-H "Content-Type: application/json" \
-d '{
"dataset": "gateway_dns",
"enabled": true,
"max_upload_bytes": 5000000,
"max_upload_records": 1000,
"logpull_options":"fields=ApplicationID,ColoCode,ColoID,Datetime,DeviceID,DeviceName,DstIP,DstPort,Email,Location,LocationID,MatchedCategoryIDs,MatchedCategoryNames,Policy,PolicyID,Protocol,QueryCategoryIDs,QueryCategoryNames,QueryName,QueryNameReversed,QuerySize,QueryType,QueryTypeName,RCode,RData,ResolvedIPs,ResolverDecision,SrcIP,SrcPort,TimeZone,TimeZoneInferredMethod,UserID×tamps=rfc3339",
"destination_conf": "https://intake.sekoia.io/plain/batch?header_X-SEKOIAIO-INTAKE-KEY=<YOUR_INTAKE_KEY>"
}' # (1)
- will return
{ "errors": [], "messages": [], "result": { "id": "<ID>", "dataset": "gateway_dns", "frequency":"high", "kind":"", "max_upload_bytes": 5000000, "max_upload_records": 1000, "enabled": true, "name": "<DOMAIN_NAME>", "logpull_options": "fields=<LIST_OF_FIELDS>", "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, "time_created":"<TIMESTAMP>" }, "success": true }
Important
Replace :
<YOUR_INTAKE_KEY>
with the Intake key you generated in the Create the intake on SEKOIA.IO step.<CLOUDFLARE_ACCOUNT_ID>
with the ACCOUNT_ID found on the overview page<CLOUDFLARE_API_TOKEN>
with the API Token you generated
Useful Cloudflare API endpoints
On their documentation, Cloudflare provides a list API endpoints you can use. Find below some useful endpoints:
https://api.cloudflare.com/client/v4/accounts/<ACCOUNT_ID>/logpush/jobs/<JOB_ID>
to verify the job you previously created is correct (you need to specify theJOB_ID
)https://api.cloudflare.com/client/v4/accounts/<ACCOUNT_ID>/logpush/datasets/<DATASET>/jobs
to get all the jobs for a specific dataset (dns_log
,firewalls_events
orhttp_requests
in our case)https://api.cloudflare.com/client/v4/accounts/<ACCOUNT_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...)