Content EBookSecurityMonitoringBestPracticesGuide
Content EBookSecurityMonitoringBestPracticesGuide
Datadog
Cloud SIEM
BEST PRACTICE SERIES
Blazing trails As previously mentioned, AWS CloudTrail records each instance of activity
(such as API requests and user logins) it detects in your environment as
an event, which is a JSON object that specifies the activity’s particulars,
including the time at which it occurred, who performed the activity, the
resources that were affected by the activity, and more. You can view and
filter all of your events in the Event History page in the AWS CloudTrail
console, where they are available for up to 90 days after they occur.
Most AWS customers use a consolidated trail for all CloudTrail events.
However, you can create an event stream that filters in or out events. For
instance, in order to reduce your log load, you might want to create an
event stream that solely consists of activity related to a certain AWS
service or resource. To do this, you create a trail, or an event stream that
sends events to a chosen AWS S3 bucket as log files. This way, your
events are available according to the retention policy you specify, can be
quickly filtered to find critical issues, and can be alerted on using Amazon
CloudWatch or Amazon Simple Notification Service (SNS).
CloudTrail saves your audit logs in gzip archive form to the S3 bucket that
you specify when creating the trail. The name of the file includes the trail
creator’s account number, the Region in which the log was recorded, and
the month, day, and year when the file was created. For more information
on finding your CloudTrail log files, see the AWS documentation.
By default, trails are Region agnostic; that is, a trail will log relevant events
across every Region. You can create single-Region trails to focus on a single
Region’s activity, but we recommend creating an all-Region trail, as doing
so will give you more visibility and automatically track data from new
Regions as they come online.
[Link] Best practices for monitoring AWS CloudTrail logs 5
You can also set up an organization trail to monitor all of the logs gener-
ated by the AWS accounts within an AWS Organization. AWS Organizations
allows you to centrally manage the access permissions of users in all of
the accounts in the organization, and can be set up at no additional cost.
Organizations are recommended when your team needs to manage many
different AWS accounts by governing your ever-changing environment and
enforce configurations on your primary and member accounts.
Understanding AWS CloudTrail records three different types of events from most AWS
AWS CloudTrail services based on the actions users perform in the AWS Management
audit logs Console, Command Line Interface (CLI), and SDKs/APIs, as well as
automated actions performed by AWS. For a list of services that are
not tracked by CloudTrail, see the AWS documentation. The three event
types are:
– Management events: entries for management and network (control plane)
operations performed on the resources in your AWS account, such as
security group configuration changes, IAM role permission adjustments,
and AWS Virtual Private Cloud (VPC) network alterations.
– Data events: entries for data request operations—such as Get , Delete ,
and Put API commands—performed on an AWS data plane resource.
– Insight events: entries that reflect unusual API activity in your AWS
account in comparison to your historical API usage, such as excessive
API calls in a short frame of time.
As management and data events make up the vast majority of event logs
in CloudTrail, we’ll look at them in more detail. For more information on
using insight events to track and discover anomalies in your AWS data,
see the AWS documentation.
MANAGEMENT EVENTS
Management events include all management operations performed on
resources in your account, as well as most non-API actions. Non-API actions
include logins ( AwsConsoleSignIn ) to the AWS console and automated
service actions like cryptographic key rotations ( AwsServiceEvent ). AWS
CloudTrail logs management events by default.
The sample management event below records a console login, indicated
by the field eventType: AwsConsoleSignIn . It shows that someone with
the userName Alice successfully signed in to the AWS console without
multifactor authentication.
[Link] Best practices for monitoring AWS CloudTrail logs 6
{
"eventVersion": "1.05",
"userIdentity": {
"type": "IAMUser",
"principalId": "AIDABBBBBBBBBBBBBBBBB",
"arn": "arn:aws:iam::111111111111:user/alice",
"accountId": "111111111111",
"userName": "alice"
},
"eventTime": "2020-09-23T09:09:56Z",
"eventSource": "[Link]",
"eventName": "ConsoleLogin",
"awsRegion": "us-east-1",
"sourceIPAddress": "[Link]",
"userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_6)
AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.135
Safari/537.36",
"requestParameters": null,
"responseElements": {
"ConsoleLogin": "Success"
},
"additionalEventData": {
"LoginTo": "[Link]
"MobileVersion": "No",
"MFAUsed": "No"
},
"eventID": "6894a571-9f34-47b8-b75c-5f4ca34f281e",
"eventType": "AwsConsoleSignIn",
"recipientAccountId": "111111111111"
}
DATA EVENTS
Data events provide details on the operations performed on or within a
resource or service, such as AWS IAM roles, Amazon EC2 instances, Amazon
S3 buckets, and AWS Lambda functions. Because they are often high-
volume activities, data events are disabled by default when you create a
trail; you must add the resources or resource types to a trail in order to
track them in AWS CloudTrail.
The below example shows that user Alice successfully performed the
PutObject Amazon S3 operation on a bucket called example-bucket to
upload the file [Link] .
[Link] Best practices for monitoring AWS CloudTrail logs 7
{
"eventVersion": "1.07",
"userIdentity": {
"type": "IAMUser",
"principalId": "AIDAAAAAAAAAAAAAAAAAA",
"arn": "arn:aws:iam::111111111111:user/Alice",
"accountId": "111111111111",
"accessKeyId": "AKIAAAAAAAAAAAAAAAAAA",
"userName": "Alice"
},
"eventTime": "2020-09-22T20:15:25Z",
"eventSource": "[Link]",
"eventName": "PutObject",
"awsRegion": "us-east-1",
"sourceIPAddress": "[Link]",
"userAgent": "[Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_5)
AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.102
Safari/537.36]",
"requestParameters": {
"X-Amz-Date": "20200922T201524Z",
"bucketName": "example-bucket",
"X-Amz-Algorithm": "AWS4-HMAC-SHA256",
"x-amz-acl": "private",
"X-Amz-SignedHeaders": "content-md5;content-type;host;x-amz-acl;
x-amz-storage-class",
"Host": "[Link]",
"X-Amz-Expires": "300",
"key": "[Link]",
"x-amz-storage-class": "STANDARD"
},
"responseElements": null,
"additionalEventData": {
"SignatureVersion": "SigV4",
"CipherSuite": "ECDHE-RSA-AES128-GCM-SHA256",
"bytesTransferredIn": 12,
"AuthenticationMethod": "QueryString",
"x-amz-id-2": "d2UncmUgaGlyaW5nIDopIGh0dHBzOi8vd3d3LmRhdGFkb2docS
5jb20vY2FyZWVycy8K",
"bytesTransferredOut": 0
},
"requestID": "EEEEEEEEEEEEEEEE",
"eventID": "f378e059-d87f-44b7-aee2-7ebfa1beff93",
"readOnly": false,
"resources": [
{
"type": "AWS::S3::Object",
"ARN": "arn:aws:s3:::example-bucket/[Link]"
},
{
"accountId": "111111111111",
"type": "AWS::S3::Bucket",
"ARN": "arn:aws:s3:::example-bucket"
}
],
"eventType": "AwsApiCall",
"managementEvent": false,
"recipientAccountId": "111111111111",
"eventCategory": "Data"
}
[Link] Best practices for monitoring AWS CloudTrail logs 8
{
"eventVersion": "1.05",
"userIdentity": {
"type": "IAMUser",
"principalId": "AIDAAAAAAAAAAAAAAAAAA",
"arn": "arn:aws:iam::111111111111:user/Alice",
"accountId": "111111111111",
"accessKeyId": "AKIAAAAAAAAAAAAAAAAAA",
"userName": "Alice"
},
"eventTime": "2020-09-21T10:31:20Z",
"eventSource": "[Link]",
"eventName": "CreateUser",
"awsRegion": "us-east-1",
"sourceIPAddress": "[Link]",
"userAgent": "[Link]",
"requestParameters": {
"userName": "bob",
"tags": []
},
"responseElements": {
"user": {
"path": "/",
"userName": "bob",
"userId": "AIDABBBBBBBBBBBBBBBBB ",
"arn": "arn:aws:iam::111111111111:user/bob",
"createDate": "Sep 21, 2020 10:31:20 AM"
}
},
"requestID": "604e7549-4ea4-4185-83b0-acff4e462d27",
"eventID": "600e50af-0a2c-4352-95a8-7b813c744072",
"eventType": "AwsApiCall",
"recipientAccountId": "111111111111"
}
[Link] Best practices for monitoring AWS CloudTrail logs 9
Because the entry returns identification details for the newly created
user ( responseElements ), we know that the command was successfully
performed. Otherwise, the JSON response would have included
an errorCode and errorMessage element, as seen in the AWS
documentation.
Before we look at the most important CloudTrail logs to monitor, it’s
essential to understand the different user identity types defined by
CloudTrail, and how CloudTrail identifies the user who performed an action.
Let’s say a user in account A wants to list all of the AWS Regions enabled
in account B. First, the user would AssumeRole into a role in account B
that has DescribeRegions permissions, obtain the temporary credentials
returned by the AssumeRole command, and then use them to perform
the command. The CloudTrail log in which a user ( userName: Alice )
from account A ( accountId: 222222222222 ) assumes a role in account B
( accountId: 11111111111 ) would look like this:
{
"eventVersion": "1.05",
"userIdentity": {
"type": "IAMUser",
"principalId": "AIDAAAAAAAAAAAAAAAAAA",
"arn": "arn:aws:iam::222222222222:user/Alice",
"accountId": "222222222222",
"accessKeyId": "AKIAAAAAAAAAAAAAAAAAA",
"userName": "Alice"
},
"eventTime": "2020-09-22T16:23:50Z",
"eventSource": "[Link]",
"eventName": "AssumeRole",
"awsRegion": "us-east-1",
"sourceIPAddress": "[Link]",
"userAgent": "aws-sdk-go/1.16.8 (go1.12.7; linux; amd64)",
"requestParameters": {
"roleArn": "arn:aws:iam::111111111111:role/ExampleRole",
"roleSessionName": "ExampleRoleSession",
"externalId": "ffffffffffffffffffffffffffffffff",
"durationSeconds": 3600
},
"responseElements": {
"credentials": {
"accessKeyId": "ASIADDDDDDDDDDDDDDDD",
"expiration": "Sep 22, 2020 5:23:50 PM",
"sessionToken": "d2UncmUgaGlyaW5nIDopIGh0dHBzOi8vd3d3
LmRhdGFkb2docS5jb20vY2FyZWVycy8K"
},
"assumedRoleUser": {
"assumedRoleId": "AROAEEEEEEEEEEEEEEEEE:ExampleRoleSession",
"arn": "arn:aws:sts::111111111111:assumed-role/ExampleRole/
ExampleRoleSession"
}
},
"requestID": "4da64d92-6130-4355-86f2-1609a6eb53e1",
"eventID": "ffef7974-b1a0-4e88-b27f-0b143965f30c",
"resources": [
{
"accountId": "111111111111",
"type": "AWS::IAM::Role",
"ARN": "arn:aws:iam::111111111111:role/ExampleRole"
}
],
"eventType": "AwsApiCall",
"recipientAccountId": "111111111111",
"sharedEventID": "4f61c867-6a49-4c41-a267-388c38e99866"
}
[Link] Best practices for monitoring AWS CloudTrail logs 11
{
"eventVersion": "1.05",
"userIdentity": {
"type": "AssumedRole",
"principalId": "AROAEEEEEEEEEEEEEEEEE:ExampleRoleSession",
"arn": "arn:aws:sts::111111111111:assumed-role/ExampleRole/
ExampleRoleSession",
"accountId": "111111111111",
"accessKeyId": "ASIADDDDDDDDDDDDDDDD",
"sessionContext": {
"sessionIssuer": {
"type": "Role",
"principalId": "AROAEEEEEEEEEEEEEEEEE",
"arn": "arn:aws:iam::111111111111:role/ExampleRole",
"accountId": "111111111111",
"userName": "ExampleRole"
},
"webIdFederationData": {},
"attributes": {
"mfaAuthenticated": "false",
"creationDate": "2020-09-22T15:58:31Z"
}
}
},
"eventTime": "2020-09-22T16:26:02Z",
"eventSource": "[Link]",
"eventName": "DescribeRegions",
"awsRegion": "us-east-1",
"sourceIPAddress": "[Link]",
"userAgent": "aws-sdk-go/1.16.8 (go1.12.7; linux; amd64)",
"requestParameters": {
"regionSet": {}
},
"responseElements": null,
"requestID": "0a857cb2-90c4-4f09-9624-1149fb27f8a1",
"eventID": "26fe99a5-8ed5-4923-9cf7-b6cdf96fa5f3",
"eventType": "AwsApiCall",
"recipientAccountId": "111111111111"
}
[Link] Best practices for monitoring AWS CloudTrail logs 12
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"AWS": "arn:aws:iam::<AccountNumber>:root"
},
"Action": "sts:AssumeRole",
"Condition": {
"StringLike": {
"sts:RoleSessionName": "${aws:username}"
}
}
}
]
}
With this configuration, you can easily track and filter the actions
performed in each assumed role session—or catch anyone who fails to
provide a valid session name. For more examples of controlling session
names, see the related AWS blog post.
Key CloudTrail IAM policies in AWS are complex; they can potentially provide users with
audit logs permissions to access all resources within an AWS account. This means
to monitor that there is ample opportunity for security misconfigurations that will
inadvertently allow someone to manipulate your environment and give
themselves further access to your assets. By monitoring your audit logs,
you can get a fuller picture of user activity and the ways in which users
interact with your resources—including whether or not they’re authorized
to perform those interactions in the first place.
[Link] Best practices for monitoring AWS CloudTrail logs 13
USER ACCOUNTS
One of the most common ways for an attacker to infiltrate your environment
is by using an exposed AWS Secret Access Key and enumerating the key’s
permissions. If the exposed key has extensive management permissions,
the attacker can proceed to give themselves further permissions while
disabling your security infrastructure. Monitoring your CloudTrail logs for
the following activity can help alert you to attackers as they inspect their
permissions and attempt to maintain persistence in your environment:
– Unauthorized Activity
Unauthorized user activity logs contain the following error message in
the responseElements :
[Link] Best practices for monitoring AWS CloudTrail logs 14
{
[...],
"errorCode": "[Link]",
"errorMessage": "You are not authorized to perform this operation.",
"requestParameters": {
"regionSet": {}
},
"responseElements": null,
"requestID": "0a857cb2-90c4-4f09-9624-1149fb27f8a1",
"eventID": "26fe99a5-8ed5-4923-9cf7-b6cdf96fa5f3",
"eventType": "AwsApiCall",
"recipientAccountId": "111111111111"
}
BUCKETS
Attackers often target S3 buckets when attempting to breach your environ-
ment. As with user accounts, an attacker might gain access to a bucket’s
contents due to a security misconfiguration or human error. By monitoring
your CloudTrail logs, you can spot the following bucket enumeration and
modification attack techniques.
– AWS S3 Buckets Enumerated
– AWS S3 Bucket Policy Modified
If an attacker gets access to an EC2 instance, the first thing they might do is
enumerate all of the S3 buckets that they have access to from the relevant
instance profile, or attempt to change a bucket’s access policy altogether.
[Link] Best practices for monitoring AWS CloudTrail logs 15
NETWORKING COMPONENTS
Attackers may also attempt to access your environment through a miscon-
figured network resource, such as a VPC, a route table, a network gateway,
a network access control list, or a security group. CloudTrail logs can help
you spot the following types of possible network attacks and take the
proper steps to resolve the breach.
– AWS VPC Created or Modified
– AWS Route Table Created or Modified
– AWS Network Gateway Created or Modified
– AWS Network Access Control List Created or Modified
– AWS Security Group Created or Modified
To check the posture of your networking resources and make sure that
they are securely configured, we recommend using Datadog’s Compliance
Monitoring tool, which scans your AWS environment for misconfigurations
in real-time.
Collect and The benefits of using Datadog as your log monitoring platform for your AWS
analyze infrastructure include:
CloudTrail logs – direct integrations with AWS CloudTrail, Amazon S3, AWS Kinesis Firehose,
with Datadog and Amazon Lambda that streamline the log export process
– automatic field parsing of all AWS CloudTrail logs streaming from your
AWS environment using log processing pipelines
– cost-effective collection and archiving of all CloudTrail logs using
Datadog’s Logging without Limits™
– expanded scope of log context for security and compliance analysis
Once you’ve set up the AWS integration for your services and have
CloudTrail logs streaming into Datadog, you can build custom dashboards
to get a high-level perspective on the health and security of your AWS
[Link] Best practices for monitoring AWS CloudTrail logs 16
Beyond filtering your audit logs to find potential problems, you can use
them to build high-level Datadog dashboards with custom data
visualizations. This way, you can get a quick, top-down perspective of
your incoming logs without endlessly filtering through them.
Start moni- In this post, we reviewed how to interpret AWS CloudTrail audit logs:
toring your we looked at how each event type works, outlined best practices for follow-
AWS CloudTrail ing users and roles across multiple logs, and highlighted the most
audit logs important audit logs to investigate. We also walked through how to import
your CloudTrail logs into Datadog using Amazon Kinesis Data Firehose,
as well some of the best ways to use Datadog to triage your logs and catch
security issues as they occur. For more information on monitoring your
AWS audit logs and securing your applications with Datadog, check out our
documentation. And if you’re not already using Datadog, get started now
with a 14-day free trial.
Best practices for monitoring
GCP audit logs
Justin Massey Google Cloud Platform (GCP) is a suite of cloud computing services for
deploying, managing, and monitoring applications. A critical part of deploy-
Mallory Mooney ing reliable applications is securing your infrastructure. Google Cloud Audit
Logs record the who, where, and when for activity within your environment,
providing a breadcrumb trail that administrators can use to monitor access
and detect potential threats across your resources (e.g., storage buckets,
databases, service accounts, virtual machines). GCP collects audit logs
from all GCP services, so you can get more context around user and service
account activity for security analysis and identify possible vulnerabilities
that you should address before they become bigger issues.
In this guide, we’ll cover:
– the structure of GCP audit logs
– best practices for using audit logs to monitor GCP security
– how to export audit logs from GCP
– how Datadog can help you collect and monitor your GCP audit logs
Before we dive into audit logs, let’s first look at the Google Cloud resource
hierarchy, as it plays a role in interpreting your logs.
[Link] Best practices for monitoring GCP audit logs 20
To grant access to your resources, you can create Cloud IAM policies.
A policy can include members of several different account types, includ-
ing Google accounts and service accounts. These policies propagate
down the hierarchy. In the example above, if you grant a Google group
the editor role for the Engineering folder, their Google account credentials
will automatically give them read and write access to all the resources
in both the Demo and Lab projects. Understanding the hierarchy of your
organization, as well as the roles of individual users and services, will
help you quickly sift through this data in your audit logs and pinpoint any
potential threats to your applications.
Understanding Google Cloud can emit three different types of audit logs for every
Google Cloud organization, folder, and project within your resource hierarchy:
Audit Logs – Admin Activity: entries for API calls or user administrative activity that
changes resource configurations
– System Event: entries for Google system administrative activity that
modifies resource configurations
– Data Access: entries for API calls that read resource configurations or
metadata, or user-level API calls that read or write resource data
[Link] Best practices for monitoring GCP audit logs 21
Most Google Cloud services emit each of these audit log types, enabling
you to view resource activity for different levels of your hierarchy. This
includes G Suite if you are sharing that data with Cloud Logging, so you
can also view the Admin Activity and Data Access audit logs that G Suite
writes at the organizational level.
You can access your logs using GCP console. After logging in, select
Logging then Log Viewer from the navigation menu.
It’s important to note that, while you can see project-level logs in the
con-sole, you can only view organization- and folder-level logs with the
Cloud Logging API. To view all of your audit logs in one place, you can ship
them to Datadog. We’ll cover how to configure Datadog to collect your
audit logs later.
Next, we’ll go through each type of log in more detail.
[Link] Best practices for monitoring GCP audit logs 22
{
"protoPayload": {
"@type": "[Link]/[Link]",
"status": {},
"authenticationInfo": {
"principalEmail": "[Link]@[Link]",
"principalSubject": "user:[Link]@[Link]"
},
"requestMetadata": {},
"serviceName": "[Link]",
"methodName": "[Link]",
"authorizationInfo": [
{
"resource": "projects/-/serviceAccounts/123456789012345678901",
"permission": "[Link]",
"granted": true,
"resourceAttributes": {}
}
],
"resourceName": "projects/-/serviceAccounts/123456789012345678901",
"request": {
"@type": "[Link]/[Link].v1.
CreateServiceAccountKeyRequest",
"name": "projects/-/serviceAccounts/
ab6c214d4e4fgh1234567@[Link]",
"private_key_type": 2
},
"response": {},
"insertId": "vwqyhke39pfj",
"resource": {
"type": "service_account",
"labels": {}
},
"timestamp": "2020-05-18T15:09:50.746563735Z",
"severity": "NOTICE",
"logName": "projects/sample-project/logs/[Link].
com%2Factivity",
"receiveTimestamp": "2020-05-18T15:09:51.695275787Z"
}
Users require either the Cloud IAM Logging Viewer or Project Viewer role
to view Admin Activity logs. They are enabled by default and, although you
are not able to configure or disable them, you are not charged for them.
[Link] Best practices for monitoring GCP audit logs 23
{
"protoPayload": {
"@type": "[Link]/[Link]",
"authenticationInfo": {
"principalEmail": "system@[Link]"
},
"serviceName": "[Link]",
"methodName": "[Link]",
"resourceName": "projects/sample-project/zones/us-central1-a/
instances/gke-default-pool-123",
"request": {
"@type": "[Link]/[Link].
migrateOnHostMaintenance"
}
},
"resource": {
"type": "gce_instance",
"labels": {
"zone": "us-central1-a",
"instance_id": "123456789012345",
"project_id": "sample-project"
}
},
"timestamp": "2020-05-07T19:59:34.633Z",
"severity": "INFO",
"logName": "projects/sample-project/logs/[Link].
com%2Fsystem_event"
}
Like Admin Activity logs, System Event audit logs are enabled by default,
do not incur charges, and require either the Logging Viewer or Project
Viewer role.
Due to the potentially large volume of Data Access logs your environment
can generate, they are not enabled by default. You need to explicitly enable
each sub-type for any services you want to monitor. A service account
retrieving a list of storage buckets, for example, may generate the following
ADMIN_READ Data Access log:
{
"protoPayload": {
"@type": "[Link]/[Link]",
"status": {},
"authenticationInfo": {
"principalEmail": "[Link]",
"serviceAccountKeyName": "//[Link]/projects/
sample-test/serviceAccounts/a1bcd2e3456k9f00934gh@test-bot.
[Link]/keys/e123e0b9dde1234b1d22a4cb123456d51ree"
},
"requestMetadata": {},
"serviceName": "[Link]",
"methodName": "[Link]",
"authorizationInfo": [
{
"permission": "[Link]",
"granted": true,
"resourceAttributes": {}
}
],
"resourceLocation": {},
"insertId": "14suazjdct0e",
"resource": {
"type": "gcs_bucket",
"labels": {
"project_id": "sample-project",
"location": "global",
"bucket_name": ""
}
},
"timestamp": "2020-05-20T13:03:05.396618238Z",
"severity": "INFO",
"logName": "projects/sample-project/logs/cloudaudit.
[Link]%2Fdata_access",
"receiveTimestamp": "2020-05-20T13:03:06.387630414Z"
}
Note that, unlike Admin Activity and System Event logs, GCP charges you
for Data Access logs. Users need either the Cloud IAM Logging Viewer,
Logging Private Logs Viewer, Project Viewer, or Project Owner role to view
these logs.
[Link] Best practices for monitoring GCP audit logs 25
"protoPayload": {
"@type": "[Link]/[Link]",
"status": {},
"authenticationInfo": {
"principalEmail": "test-bot@example-project.
[Link]",
"serviceAccountKeyName": "..."
},
"requestMetadata": {},
"serviceName": "[Link]",
"methodName": "[Link]",
"authorizationInfo": [
{
"permission": "[Link]",
"granted": true,
"resourceAttributes": {}
}
],
"resourceLocation": {}
}
You can tell which requests are from a user versus a service account
by looking at the domain of the principalEmail . If the domain is
[Link] , the account is a service account. If the domain
is [Link] , it is a Google service performing admin activity. If it is
any other domain, it is a user making the request.
Calls to list storage buckets within a project are typically made by users,
not service accounts. If you see log entries that show service accounts
making these calls then you may need to troubleshoot further by monitor-
ing any other calls the account is making. Or, you can identify which team
within your organization owns the service to confirm that the calls were
necessary.
[Link] Best practices for monitoring GCP audit logs 26
The resource section provides more details about the specific resources
being queried or modified. The snippet below, for example, shows that
the test-bot service account made a call to list all Cloud Storage buckets
( gcs_bucket ) in the project sample-project .
"resource": {
"type": "gcs_bucket",
"labels": {
"project_id": "sample-project",
"location": "global",
"bucket_name": ""
}
}
You can look at the log entry’s logName for information including a suffix
identifying the log sub-type (e.g., Admin Activity, System Access, Data
Access) and where in the hierarchy the request was made. Here, we can
see that this is an Admin Activity log recording a request to a project,
sample-project:
"logName": "projects/sample-project/logs/cloudaudit.
[Link]%2Factivity"
Your GCP resources can produce a large volume of audit logs, making it
difficult to find the logs you need to detect unusual activity or troubleshoot
problems before they turn into security incidents. Next, we’ll highlight
some of the critical log events you should track to make sure your envi-
ronment is secure. Then, we’ll walk through shipping those logs to a
monitoring service like Datadog.
[Link] Best practices for monitoring GCP audit logs 27
Cloud IAM policies are complex and can grant users and service accounts
access to resources at every level of your environment’s hierarchy.
Monitoring audit logs provides a better understanding of who is accessing
a resource, how they are doing it, and whether or not the access was
permitted.
Some common scenarios that lead to your GCP account being compromised
include:
– publicly accessible GCP resources, such
as storage buckets or compute instances
– misconfigured IAM permissions
– mishandled GCP credentials
Attackers often look for these types of vulnerabilities in order to gain
access to your environment. Once they have access, they can modify
GCP services, escalate privileges and create new accounts, and exfiltrate
sensitive data.
As an example of misconfigured permissions, a Cloud Storage IAM policy
for your storage buckets can include the value allAuthenticatedUsers
as a member of the role Storage Object Admin . This would grant all
authenticated users to GCP—not just authenticated users within your
account—the ability to create, delete, and read all objects within the
storage bucket.
GCP provides security guidelines that are mapped to frameworks such
as CIS Benchmarks, which offer baseline best practices for securing your
environment. Your audit logs complement these guidelines and provide
a detailed history of activity, ensuring that you can mitigate potential
threats to your environment. Next, we’ll look at the following key audit
logs you can monitor for your resources:
[Link] Best practices for monitoring GCP audit logs 28
"protoPayload": {
"status": {
"code": 7,
"message": "PERMISSION_DENIED"
}
}
A single denied call for a user or service account does not mean the account
is compromised. For example, it could be a user navigating around the GCP
console who is not permitted to access certain GCP services. Or, if you have
an internal service that is a part of a build pipeline requesting access each
time a build runs, it might be denied due to a misconfigured build job or
IAM permission.
However, if this is the first time a service account is receiving PERMISSION_
DENIED responses, it may be worth investigating why the account is being
denied access. This type of unauthorized activity could be an indicator that
an attacker has access to a compromised user or service account.
[Link] Best practices for monitoring GCP audit logs 29
Once they have access, attackers may then try to create new service
accounts or service account keys in order to create a backdoor into your
environment and maintain persistence.
– Service Account Created
– Service Account Key Created
Logs for new service accounts include an entry for a [Link].
[Link] API call in the methodName JSON attribute.
When a new service account key is created, you will see a log entry for a
[Link] call.
These logs do not always indicate a security threat, but you should
ensure that the calls were legitimate. For example, an attacker may create
a key on a service account with domain-wide delegation enabled. If a
service account with this enabled has the ability to access a G Suite
account, it could be used to leverage permissions within that account,
such as creating new G Suite administrators. Google does not log whether
or not the service account has been delegated domain-wide authority
when creating a Service Account Key; if you notice new key creation
activity, you should investigate further. To protect your service accounts,
CIS recommends ensuring that you do not grant them any admin, editor,
or owner roles.
BUCKETS
Storage buckets are often a component of a breach in public clouds. This
may be due to a misconfigured bucket or an attacker exploiting another
vulnerability to gain access to a storage bucket. Monitoring your Cloud
Audit Logs can detect the following bucket misconfigurations or attacker
techniques.
– Bucket Enumerated by a Service Account
To enumerate their permissions, an attacker will first attempt to use a
compromised service account to list storage buckets. For these types of
events, you will see a service account making a [Link] call.
Service accounts typically do not need to list storage buckets because they
are already configured to access the buckets they need, so if you see this
type of log you should investigate.
– Bucket Exposed to World
If a bucket is publicly accessible, you will see audit log entries that show
the [Link].
member JSON attribute is set to allUsers or allAuthenticatedUsers
and the action is set to ADD :
[Link] Best practices for monitoring GCP audit logs 30
"protoPayload": {
"serviceData": {
"policyDelta": {
"bindingDeltas": [
{
"action": "ADD",
"member": "allUsers",
"role": "roles/[Link]"
}
]
}
}
}
You should review your permission policies any time you see this level of
access to a GCP resource as it could be an indicator that the resource is
accessible to any users outside your network.
Shipping your As part of its Operations Suite (formerly Stackdriver), GCP provides Cloud
audit logs Logging for querying and analyzing all of your logs. Cloud Logging uses
sinks for exporting logs to another source. All sinks include an export
destination and a logs query. You can use Cloud Logging sinks to export
your logs to a destination such as cloud storage, a BigQuery dataset,
[Link] Best practices for monitoring GCP audit logs 31
Collect and Datadog provides turnkey integrations for GCP and G Suite that offer
analyze audit several benefits for collecting and monitoring your logs:
logs with – the G Suite integration simplifies the process for ingesting
Datadog authentication logs
– Datadog automatically parses all Google Cloud and G Suite audit logs
streaming from your GCP environments
– Datadog enriches Google Cloud and G Suite logs with more
contextual information for improved investigations
Once you enable the integrations, you can build custom dashboards
to get a high-level view of log activity and use Datadog’s built-in threat
detection rules to sift through key audit logs and automatically identify
critical security and compliance issues in your environments. First,
we’ll walk through setting up your GCP account to forward Cloud Audit
Logs to Datadog.
protoPayload.@type:"[Link]/[Link]"
[Link] Best practices for monitoring GCP audit logs 32
To create a sink with this query, click on the “Create Sink” button in the
console’s Logs Viewer, provide a name for the sink, and select Pub/Sub
as the sink’s service. In the example configuration below, we’ve set the
export destination for the queried logs as a Pub/Sub topic called datadog-
exporter-topic . You can create a new topic by navigating to the Cloud
Pub Sub console of your GCP account.
To send organization and folder logs to Datadog, you will need to use the
Logging API and the gcloud command line utility. You can create sinks for
these logs with the following commands:
After running each of the commands, you will need to grant the newly
generated service account permission with the role of Pub/Sub Publisher
on the topic.
Ideally, it’s best to forward all audit logs to your monitoring service. This
ensures that you do not miss critical events that can negatively affect your
applications. However, it’s important to note that your environment can
generate a lot of Data Access audit logs, and Pub/Sub throughputs are
subject to quota limits. If you are running into those limits, you can split
[Link] Best practices for monitoring GCP audit logs 33
your logs over several topics to break up throughput. You can also create
an alert in Datadog to automatically notify you when you are close to
hitting the quota limits.
Once you create the sink, Cloud Logging will export all new Data Access,
Admin Activity, and System Activity logs to the selected topic. In order
to direct those logs to Datadog, create a new Pub/Sub subscription for
the datadog-exporter-topic topic and add Datadog as a subscriber,
as seen in the example below.
The delivery type uses the Push method to send logs to a Datadog endpoint.
Note that the endpoint requires a Datadog API key, which you can find in
your account’s settings.
With the GCP integration enabled and configured to receive data, you will
start seeing new Cloud Audit Logs in Datadog as GCP services generate
them. If you enabled the G Suite integration, you will also see G Suite logs
streaming alongside your other logs. Datadog’s log processing pipelines
automatically parse properties from your Google Cloud and G Suite audit
logs as tags, which you can use in the Log Explorer to sort and filter all
your logs and search for a subset of them that you need. For example, you
might want to look for accounts that made a call to list buckets within a
specific project.
[Link] Best practices for monitoring GCP audit logs 34
You can create facets from attributes in your ingested logs and use them
to build visualizations, such as a list of the top five sources in your envi-
ronment of Admin Activity audit logs.
[Link] Best practices for monitoring GCP audit logs 35
In the example signal above, you can see that a service account enumer-
ated a storage bucket. The signal includes a sample of the Cloud Audit Log
that triggered the rule as well as the name of the service account that made
the calls.
Datadog’s GCP detection rules can also help you automatically monitor
changes to a Cloud Logging sink or Cloud Pub/Sub topic or subscription,
which could disrupt the flow of logs to your Datadog account.
[Link] Best practices for monitoring GCP audit logs 36
Start monitoring In this post, we looked at GCP audit logs and how they can provide
your Cloud Audit invaluable insight into activity in your environment so that you can
Logs quickly identify possible misconfigurations and threats. We then walked
through some best practices for collecting audit logs as well as how
Datadog can provide deeper visibility into GCP security. You can check
out our documentation for more information on getting started moni-
toring the security of your applications and GCP resources. Or, sign up
for a free trial to start monitoring your applications today.
Best practices for monitoring
Microsoft Azure platform logs
Justin Massey Microsoft Azure provides a suite of cloud computing services that allow
organizations across every industry to deploy, manage, and monitor full-
Jonathan Epstein scale web applications. As you expand your Azure-based applications,
securing the full scope of your cloud resources becomes an increasingly
complex task. Azure platform logs record the who, what, when, and
where of all user-performed and service account activity within your
Azure environment. Collecting and analyzing Azure platform logs is vital
for monitoring the security of your Azure assets and identifying poten-
tially malicious activity before it can propagate across your system and
cause serious issues.
In this guide, we’ll take a look at:
– the types and structure of Azure platform logs
– key Azure platform logs to monitor
– how Datadog can help you collect and monitor your Azure logs
But, before we jump into Azure logs, it’s important to understand the
organizational hierarchy of your Azure resource directory, as it provides
the foundation for properly interpreting and acting on those logs.
[Link] Best practices for monitoring Microsoft Azure platform logs 38
Azure uses Azure Active Directory (Azure AD) to manage identity and
access management (IAM) across all resources within an organization,
referred to as a tenant. To help structure which users and services have
permission to access resources, Azure AD organizes a tenant’s cloud
resources in a directory structure across four levels: management groups,
subscriptions, resource groups, and resources. These levels act as a
hierarchy, so permissions configured for an entity at a higher level apply
to all sub-resources within that entity. At the very top of each tenant’s
Azure AD hierarchy is a root management group, which controls global
policies applied to the rest of the directory.
Azure AD creates a managed identity for every resource in your directory.
The identity provides access credentials based on that resource’s resource
group and subscription. When a user or resource attempts to perform an
action (such as reading from a storage bucket or creating a VM), it requests
an access token from Azure AD, which is used to authenticate the request.
The request is logged and contains detailed information about the action
performed in your environment.
[Link] Best practices for monitoring Microsoft Azure platform logs 39
Understanding Microsoft Azure generates three categories of platform logs that record
Azure platform different types of actions:
logs – Azure Active Directory reports detail changes made in Azure AD and
login activity.
– Activity logs record operations performed on an Azure resource
(i.e., operations coming from the the control plane), such as creating
a VM. Activity logs also record Service Health events.
– Resource logs capture operations performed within an Azure
resource (i.e., operations coming from the data plane), such as querying
a database or writing to a storage bucket.
In the following sections, we’ll look at each type of log and how you can
differentiate between them by looking at the category field that Azure
includes in all logs.
Azure Active Directory logs track actions like sign-ins, and can be viewed in the Active Directory
portal.
ACTIVITY LOGS
Azure activity logs (not to be confused with the AD activity log subtype)
record either creates and changes (i.e., PUT , POST , and DELETE
operations) performed on the resources within your Azure subscriptions,
such as starting a virtual machine or editing the configuration of an
Azure Pipeline. Each activity log contains key information on the parti-
culars of the event, including which user (if any) performed the operation,
which resource the operation was attempted on, when the operation
occurred, and whether it was successful. There are multiple categories
of activity logs, but the majority of actions on your subscription-level
assets will be related to configuration changes, so you likely will most
frequently see ‘Administrative’ or ‘Policy’ values in the Category field.
In order to store and access your activity logs, you need to create a
workspace in Log Analytics, Azure’s log management tool. Once you’ve
done this, you can access your logs in the Azure portal using the side
navigation bar, or with the Azure CLI.
The abridged sample below shows an Administrative type activity
log in which Caller: [Link]@[Link]
has successfully updated a network security group ( "authorization.
action": "[Link]/networkSecurityGroups/write" ).
The log’s [Link] field also tells us which subscription
and resource group the network security group is a part of, which can
help us discern which access permissions allowed the user to make
the configuration changes.
[Link] Best practices for monitoring Microsoft Azure platform logs 41
{
"authorization": {
"action": "[Link]/networkSecurityGroups/write",
"scope": "/subscriptions/12345678-1234-1234-1234-123456789101/
resourcegroups/stanfield/providers/[Link]/
networkSecurityGroups/Jumpbox-nsg"
},
"caller": "[Link]@[Link]",
"channels": "Operation",
[...]
"category": {
"value": "Administrative",
"localizedValue": "Administrative"
},
"eventTimestamp": "2021-02-25T14:14:37.4666455Z",
"id": "/subscriptions/12345678-1234-1234-1234-123456789101/
resourcegroups/stanfield/providers/[Link]/
networkSecurityGroups/Jumpbox-nsg/events/
306b539b-397d-4bd1-9364-61f1cb4bbab7/ticks/637498592774666455",
"level": "Informational",
"operationId": "cf187bda-b64d-4221-bae6-d3d71b067fac",
"operationName": {
"value": "[Link]/networkSecurityGroups/write",
"localizedValue": "Create or Update Network Security Group"
},
"resourceGroupName": "stanfield",
"resourceProviderName": {
"value": "[Link]",
"localizedValue": "[Link]"
},
"resourceType": {
"value": "[Link]/networkSecurityGroups",
"localizedValue": "[Link]/networkSecurityGroups"
},
"resourceId": "/subscriptions/12345678-1234-1234-1234-123456789101/
resourcegroups/stanfield/providers/[Link]/
networkSecurityGroups/Jumpbox-nsg",
"status": {
"value": "Succeeded",
"localizedValue": "Succeeded"
},
"subStatus": {
"value": "",
"localizedValue": ""
},
"submissionTimestamp": "2021-02-25T14:15:38.1594455Z",
"subscriptionId": "12345678-1234-1234-1234-123456789101",
"tenantId": "98765432-9876-9876-9876-987654321098",
"properties": {
"eventCategory": "Administrative",
"entity": "/subscriptions/12345678-1234-1234-1234-123456789101/
resourcegroups/stanfield/providers/[Link]/
networkSecurityGroups/Jumpbox-nsg",
"message": "[Link]/networkSecurityGroups/write",
"hierarchy": "98765432-9876-9876-9876-987654321098/
12345678-1234-1234-1234-123456789101"
},
"relatedEvents": []
}
[Link] Best practices for monitoring Microsoft Azure platform logs 42
RESOURCE LOGS
Resource logs detail all of the actions that occur within an existing Azure
resource, such as reads and writes to a vault in Azure Key Vault, or to a
database in Azure SQL Database. Like activity logs, resource logs each
contain a schema of standardized fields that provide key information such
as the ID of the resource in which the request was made (as well as the
IDs of the subscription and resource group to which the resource belongs),
the timestamp of the request, and whether or not the request succeeded.
Like activity logs, you need to create a Log Analytics workspace In order
to store and access your resource logs.
Because there are so many types of resource logs, it’s best to assume
that any log with a Category type not mentioned in the above Azure AD
and activity log sections is a resource log. Resource log categories depend
on the type of resource being modified and are often descriptive of the
“scope” of the actions taken, such as Execution or Request . For a full
list of resource log categories, see Azure’s documentation.
It’s important to note that, unlike Azure AD and activity logs, Azure
services do not emit resource logs by default due to their volume. In order
to enable resource log collection, you need to create a diagnostic setting
for each resource and designate which Log Analytics workspace will
receive its logs. We’ll look at this process later in this post.
The following abridged sample resource log shows that caller: john.
doe@[Link] successfully added a new key
( OperationNameValue: [Link]/vaults/write ) to an
instance of Azure Key Vault.
[Link] Best practices for monitoring Microsoft Azure platform logs 43
{
"authorization": {
"action": "[Link]/vaults/write",
"scope": "/subscriptions/12345678-1234-1234-1234-123456789101/
resourcegroups/stanfield/providers/[Link]/vaults/sekret"
},
"caller": "[Link]@[Link]",
"channels": "Operation",
[...]
"description": "",
"eventDataId": "8912ad72-5a13-4b09-8d0f-d4d62319be5d",
"eventName": {
"value": "EndRequest",
"localizedValue": "End request"
},
"category": {
"value": "Administrative",
"localizedValue": "Administrative"
},
"eventTimestamp": "2021-02-26T18:56:41.6480881Z",
"id": "/subscriptions/12345678-1234-1234-1234-123456789101/
resourcegroups/stanfield/providers/[Link]/vaults/sekret/
events/8912ad72-5a13-4b09-8d0f-d4d62319be5d/ticks/637499626016480881",
"level": "Informational",
"operationId": "5fb0b823-f5d4-4278-98b3-25d84a06a87f",
"operationName": {
"value": "[Link]/vaults/write",
"localizedValue": "[Link]/vaults/write"
},
"resourceGroupName": "stanfield",
"resourceProviderName": {
"value": "[Link]",
"localizedValue": "[Link]"
},
"resourceType": {
"value": "[Link]/vaults",
"localizedValue": "[Link]/vaults"
},
"resourceId": "/subscriptions/12345678-1234-1234-1234-123456789101/
resourcegroups/stanfield/providers/[Link]/vaults/sekret",
"status": {
"value": "Accepted",
"localizedValue": "Accepted"
},
"subStatus": {
"value": "OK",
"localizedValue": "OK (HTTP Status Code: 200)"
},
"submissionTimestamp": "2021-02-26T18:57:36.1579484Z",
"subscriptionId": "12345678-1234-1234-1234-123456789101",
"tenantId": "98765432-9876-9876-9876-987654321098",
"properties": {
"statusCode": "OK",
"serviceRequestId": "6f1140e7-57b3-4002-823c-deb47b0615e7",
"eventCategory": "Administrative",
"entity": "/subscriptions/12345678-1234-1234-1234-123456789101/
resourcegroups/stanfield/providers/[Link]/aults/sekret",
"message": "[Link]/vaults/write",
"hierarchy": "98765432-9876-9876-9876-987654321098/
12345678-1234-1234-1234-123456789101"
},
"relatedEvents": []
}
[Link] Best practices for monitoring Microsoft Azure platform logs 44
Key Azure Because Azure generates platform logs for nearly every action that occurs
platform logs across your directories, it can be difficult to sift through the massive
to monitor quantity of logs and find the ones that are useful for detecting threats.
In this section, we’ll look at some of the most important platform logs
and consider the best approaches to remediating the threats they may
represent. In particular, we’ll cover two main types of logs that can alert
you to different types of potential vulnerabilities:
– authentication logs
– resource-based logs
[Link] Best practices for monitoring Microsoft Azure platform logs 45
AUTHENTICATION LOGS
Your Azure Active Directory and activity logs provide a record of user
activity, including all successful and unsuccessful login events. These
logs are invaluable for detecting suspicious login activity. One example
of this is a brute force attack, in which an attacker repeatedly attempts
to guess a user’s login credentials. When Azure records a failed login
attempt, the resulting Azure AD log will have a category of SignInLog .
If a user’s login attempts fail ( outcome: failure ) multiple times in
a row, you should investigate the rest of the logs' details.
Of course, multiple login attempts are not always indicative of a brute
force attack; the user may have legitimately forgotten their credentials.
But it’s worth determining if the user was compromised and potentially
rotating their credentials. In the following logs, we can see that a user
failed multiple single-factor authentication attempts in a row; however,
because they then successfully logged in with multi-factor authentica-
tion, we know that this was not the work of an attacker.
RESOURCE-BASED LOGS
When attempting to gain persistence in your Azure environment,
an attacker will often begin by trying to find instances of the following
types of resources that have overly permissive access policies
attached to them:
– Azure roles including user, Active Directory administrator,
and classic subscription administrator
– Virtual Machines and other compute resources
– Azure Storage objects, such as blobs, files, disks, etc.
– Network security groups
Once an attacker finds a misconfigured resource, they can then read or
modify its contents, exfiltrate its sensitive data, or escalate its access
policies to allow for further exploitation. The most vulnerable resources
[Link] Best practices for monitoring Microsoft Azure platform logs 46
are those that are accessible from the public internet, so you may consider
enabling resource logging on them and closely monitoring the logs that
they emit.
For instance, you might have a network security group that’s open to
inbound traffic from all IP addresses. If the group is mistakenly associated
with a network interface that’s meant for private communications, an
attacker could exploit the misconfiguration and gain further access to your
network. In this case, it’s important to look out for resource logs that record
action: action: [Link]/networkSecurityGroups/write
and sourceAddressPrefix values of [Link] or * , such as the sample
log below.
Similarly, it’s worth inspecting activity logs that detail instances of creating
or modifying security groups or security group rules, as these logs may
represent an attacker delegating overreaching permissions to themselves.
In the following log snippet, user [Link]@[Link]
has initiated an update to a security group ( "operationName": { "value":
"[Link]/networkSecurityGroups/securityRules/write",
"localizedValue": "Create or Update Security Rule" } ) called
Jumpbox-nsg .
Because Azure emits such a large volume of logs, it can be difficult to get a
big-picture perspective of the activity in your environment. For this reason,
it’s best to use a third-party log management solution. In the following
section, we’ll look at how to export Azure logs, and how Datadog can help
you get the most context out of your logging inventory.
[Link] Best practices for monitoring Microsoft Azure platform logs 47
{
"authorization": {
"action": "[Link]/networkSecurityGroups/
securityRules/write",
"scope": "/subscriptions/12345678-1234-1234-1234-123456789101/
resourceGroups/stanfield/providers/[Link]/
networkSecurityGroups/Jumpbox-nsg/securityRules/Port_8080"
},
"caller": "[Link]@[Link]",
"channels": "Operation",
[...]
"description": "",
"eventDataId": "7495ef59-0d7a-41a5-80e2-e033c0356b2a",
"eventName": {
"value": "BeginRequest",
"localizedValue": "BeginRequest"
},
"category": {
"value": "Administrative",
"localizedValue": "Administrative"
},
"eventTimestamp": "2021-02-25T20:36:51.5686671Z",
"id": "/subscriptions/12345678-1234-1234-1234-123456789101/
resourceGroups/stanfield/providers/[Link]/
networkSecurityGroups/Jumpbox-nsg/securityRules/Port_8080/
events/7495ef59-0d7a-41a5-80e2-e033c0356b2a/ticks/637498822115686671",
"level": "Informational",
"operationId": "405fe015-c0e1-41af-8b7d-bf92076d6650",
"operationName": {
"value": "[Link]/networkSecurityGroups/
securityRules/write",
"localizedValue": "Create or Update Security Rule"
},
"resourceGroupName": "stanfield",
"resourceProviderName": {
"value": "[Link]",
"localizedValue": ""[Link]"
},
"resourceType": {
"value": "[Link]/networkSecurityGroups/securityRules",
"localizedValue": "[Link]/networkSecurityGroups/
securityRules"
},
"resourceId": "/subscriptions/12345678-1234-1234-1234-123456789101/
resourceGroups/stanfield/providers/[Link]/
networkSecurityGroups/Jumpbox-nsg/securityRules/Port_8080",
"status": {
"value": "Started",
"localizedValue": "Started"
},
"subStatus": {
"value": "",
"localizedValue": "OK"
},
"submissionTimestamp": "2021-02-25T20:37:51.1436369Z",
"subscriptionId": "12345678-1234-1234-1234-123456789101",
"tenantId": "98765432-9876-9876-9876-987654321098",
"properties": {
"requestbody": "{\"properties\":{\"protocol\":\"*\",\"sourcePortRanges\":null,\
"sourcePortRange\":\"*\",\"sourceAddressPrefixes\":null,\"sourceAddressPrefix
\":\"*\",\"destinationPortRanges\":null,\"destinationPortRange\":\"8080\",\
"destinationAddressPrefixes\":null,\"destinationAddressPrefix\":\"*\",\
"access\":\"Allow\",\"priority\":310,\"direction\":\"Inbound\",\"sourceApplica
tionSecurityGroups\":[],\"destinationApplicationSecurityGroups\":[]},\"id\":\"
/subscriptions/12345678-1234-1234-1234-123456789101/resourceGroups/stanfield/
providers/[Link]/networkSecurityGroups/Jumpbox-nsg/securityRules/
Port_8080\",\"name\":\"Port_8080\"}",
"eventCategory": "6f1140e7-57b3-4002-823c-deb47b0615e7",
"eventCategory": "Administrative",
"entity": "/subscriptions/12345678-1234-1234-1234-123456789101/resourceGroups/
stanfield/providers/[Link]/networkSecurityGroups/Jumpbox-nsg/
securityRules/Port_8080",
"message": "[Link]/networkSecurityGroups/securityRules/write",
"hierarchy": "98765432-9876-9876-9876-987654321098/12345678-1234-1234-1234-
123456789101"
},
"relatedEvents": []
}
[Link] Best practices for monitoring Microsoft Azure platform logs 48
Shipping your While there are multiple ways to ship your platform logs to third-party
Azure platform applications, Azure recommends using Event Hubs, which are distributed
logs data streaming pipelines that can handle the large volume of platform
logs generated by your Azure environment. Event Hubs let you to ship
your logs in near real-time, and using Datadog’s Event Hub integration,
you can easily keep track of the health of your Hubs and make sure that
you’re receiving your logging data as instantaneously as possible.
In the next section, we’ll look at the benefits of using Datadog to manage
and analyze your Azure platform logs, including multiple features that
help you monitor these critical logs and use them to alert you to these
potential threats. We’ll also go over how to set up an Event Hub and
configure it to send your logs to Datadog.
Collect and There are a number of benefits that come with using Datadog as your log
analyze Azure monitoring platform, including:
platform logs – Datadog’s Azure integration that collects data from all of your Azure
with Datadog services, including Virtual Machine, Load Balancer, Event Hub,
and SQL Database
– automatic parsing and enrichment of your Azure platform logs via
Datadog’s log processing pipeline
– cost-effective collection and archiving of all you Azure platform logs
using Logging without Limits™
– built-in security and compliance analysis across all of your logs
Once you’re collecting your Azure platform logs with Datadog, you
can build custom dashboards that visualize log data for a full-picture
perspective of your Azure environment’s activity. Datadog’s built-in
Threat Detection Rules automatically watch your logs for potential
malicious activity, including the key events we’ve discussed, so you
are notified as soon as security and compliance issues occur.
To use this script, open Cloud Shell in Azure and run the following two
commands. The first command downloads the resource automation script:
(New-Object [Link]).DownloadFile("[Link]
[Link]/DataDog/datadog-serverless-functions/master/azure/eventhub_
log_forwarder/activity_logs_deploy.ps1", "activity_logs_deploy.ps1")
Upon successful configuration, you’ll start to see your Azure platform logs
appear in real time in Datadog’s Log Explorer. Datadog’s log processing
pipeline automatically parses metadata from your Azure platform logs
and uses it to create log attributes, which you can use as tags to quickly
filter, sort, and group your logs by key facets like service, action, user,
subscription, and resource group.
You can sort through all of your ingested Azure platform logs by tag in the Datadog Log Explorer.
[Link] Best practices for monitoring Microsoft Azure platform logs 50
Security rules trigger alerts based on the custom logic you provide. In this example, an alert is
triggered whenever an AD user attempts to login without multi-factor authentication.
[Link] Best practices for monitoring Microsoft Azure platform logs 51
Start monitoring In this post, we reviewed how Azure platform logs are organized, how
your Azure the hierarchy of Azure environments affects their contents, and how to
platform logs analyze each type of platform log to get visibility into activity across
with Datadog your Azure services. We also looked at some of the most important logs
to watch in order to secure your environment, as well as how Datadog
can help your organization triage your logs and catch such security issues
as they occur. For more information on the benefits of monitoring your
Azure platform logs with Datadog, check out our Azure documentation.
If you’re not already using Datadog, get started now with a 14-day free trial.
Best practices for monitoring
Kubernetes security via audit logs
Mallory Mooney Kubernetes continues to be a popular platform for deploying containerized
applications, but securing Kubernetes environments as you scale up is
Justin Massey challenging. Each new container increases your application’s attack surface,
or the number of potential entry points for unauthorized access. Without
complete visibility into every managed container and application request,
you can easily overlook gaps in your application’s security as well as
malicious activity.
Kubernetes audit logs provide a complete record of activity (e.g., the who,
where, when, and how) in your Kubernetes control plane. Monitoring your
audit logs can be invaluable in helping you detect and mitigate miscon-
figurations or abuse of Kubernetes resources before confidential data is
compromised. However, Kubernetes components and services can generate
millions of log events per day, so knowing which logs to focus on is difficult.
In this post, we’ll cover:
– How to interpret Kubernetes audit logs
– Some key audit logs for monitoring Kubernetes cluster security
– How Datadog can help you monitor your audit logs and alert you
to suspicious activity in your environments
First, we’ll briefly look at audit log policies and how Kubernetes uses them
to generate audit logs.
[Link] Best practices for monitoring Kubernetes security via audit logs 53
A primer on When a request comes in to the Kubernetes API server, it can create one
generating of several different audit events such as creating a new pod or service
audit logs account. The server filters these events through an audit policy. An audit
policy is a set of rules that specifies which audit events should be recorded
and where they should be sent, for example to either a JSON log file or an
external API backend for storage.
The scope of cluster activity that Kubernetes will capture with audit logs
depends on your audit policy’s configuration and the levels you set for each
of your resources, so it’s important that the policy collects the data you
need for monitoring Kubernetes security. Otherwise, you may not be able to
easily surface legitimate threats to your applications. For instance, a policy
that doesn’t collect data about pod activity makes it more difficult to know
when an unauthorized account creates new pods with privileged containers.
On the other hand, policies that collect audit events from endpoints not
directly related to cluster activity, such as /healthz or /version , create
noise.
Interpreting In addition to capturing the right audit logs, knowing how to interpret log
your Kubernetes entries is necessary for pinpointing flaws in your environment’s security
API server settings. Let’s break down a sample audit log—which creates a new pod—
audit logs to show you what information is most useful for Kubernetes security
monitoring.
The requestURI and verb attributes show the request path (i.e., which
API endpoint the request targets) and action (e.g., list, create, watch) that
are used to make the request. The API server maps the action to a cor-
responding HTTP method. In the example entry above, you can see that a
user made a POST request to create a new pod in the “default” namespace.
The request path can also capture commands that users run inside a
container via the kubectl exec command, giving you more context for
how a user or service interacts with your application. For example, you
can detect when a user account is passing an ls command to a pod to list
and explore its directories.
[Link] Best practices for monitoring Kubernetes security via audit logs 54
[Link]
ini{
"kind":"Event",
"apiVersion":"[Link]/v1",
"metadata":{ "creationTimestamp":"2020-10-21T21:47:07Z" },
"level":"RequestResponse",
"timestamp":"2020-10-21T21:47:07Z",
"auditID":"20ac14d3-1214-42b8-af3c-31454f6d7dfb",
"stage":"ResponseStarted",
"requestURI":"/api/v1/namespaces/default/pods",
"verb":"create",
"user": {
"username":"[Link]@[Link]",
"groups":[ "system:authenticated" ]
},
"sourceIPs":[ "[Link]" ],
"objectRef": {
"resource":"pods",
"namespace":"default",
"apiVersion":"v1"
},
"requestReceivedTimestamp":"2020-10-21T21:47:07.603214Z",
"stageTimestamp":"2020-10-21T21:47:07.603214Z",
"annotations": {
"[Link]/decision": "allow",
"[Link]/reason": "RBAC: allowed by RoleBinding
'demo/test-account' of Role 'cluster-admin' to ServiceAccount
'demo/test-account'"
}
}
Key Kubernetes There are several techniques an attacker can use to access and modify
audit logs Kubernetes resources, accounts, and services. Many of these techniques
to monitor focus on exposing simple misconfigurations in your Kubernetes environ-
ment or RBAC policies. We’ll look at some important audit logs you can
monitor to easily surface suspicious activity in your cluster and detect a
few of the techniques used in the following areas:
– access to your Kubernetes environment
– changes to Kubernetes resources
– user and service account activity
The Kubernetes API server manages all requests from users and other
Kubernetes resources in your environment and is one of the first components
an attacker may try to access. With access to the API server, an attacker
will attempt to find and control other resources in your environment, such
as service accounts and pods. Monitoring your audit logs for the following
activity can help you identify vulnerabilities as well as detect an attack
before it escalates to other parts of your Kubernetes environment.
– Anonymous requests allowed
Kubernetes’s default settings allow anonymous requests to the API server.
Additionally, by default each node’s kubelet also allows anonymous
requests. CIS Benchmarks recommends disabling these settings because,
for example, they potentially give attackers full access to the kubelet API
to run commands in a pod, escalate privileges, and more.
[Link] Best practices for monitoring Kubernetes security via audit logs 56
If your API server and kubelets allow anonymous access, the username
and groups attributes in your audit logs will show system:anonymous
and system:unauthenticated , respectively.
[Link]
"user": {
"username":"system:anonymous",
"groups":["system:unauthenticated"]
},
"sourceIPs":[ "[Link]" ],
If you see these types of calls, you should troubleshoot further and
determine if you need to disable this setting for your environment.
To mitigate this, you can disable anonymous access and review your
role-based access control (RBAC) policies to ensure they are configured
correctly.
It’s important to note that managed Kubernetes services (e.g., Google
Kubernetes Engine, Amazon Elastic Kubernetes Service) generally disable
anonymous access, but it is still an important configuration to check.
A sudden increase in anonymous requests—even denied anonymous
requests—could mean that an attacker is probing the kubelet and API
server to discover what kinds of service data they can retrieve.
– Arbitrary execution in pod
– Attempt to get secrets from a cluster,
namespace, or a pod in a namespace
Once attackers know they have access to the kubelet and API server, they
will often start running arbitrary commands in a pod—such as launching
an interactive shell in a pod—or listing secrets via kubectl to see if they
can broaden their access. If you see an unauthorized IP address (e.g.,
in the sourceIPs , username , and group audit log attributes) running
commands in a pod such as listing a pod’s directories (e.g., in the
requestURI and verb attributes), it could be an indicator that an attacker
already has access to your environment and is finding ways to create,
modify, or control Kubernetes resources, which we’ll look at in the next
section.
[Link] Best practices for monitoring Kubernetes security via audit logs 57
ACCOUNT ACTIVITY
Monitor Datadog offers a built-in Kubernetes audit log integration, so you can
Kubernetes easily track environment activity in real time. To start collecting your
security audit logs, you will need to deploy the Datadog Agent to your Kubernetes
with Datadog environment, then enable log collection.
Once you’re collecting Kubernetes audit logs with Datadog, you can
create facets from attributes in your ingested logs and use them to build
visualizations to explore and focus on the most important log data—check
out some real life examples in Datadog’s KubeCon North America 2019 talk,
Making the Most Out of Kubernetes Audit Logs. And Datadog’s out-of-
the-box Threat Detection Rules automatically monitor your audit logs and
identify critical security and compliance issues in your environments.
Start monitoring In this post, we looked at some key Kubernetes audit logs and how they
your Kubernetes can help you detect unusual activity in your clusters. We also walked
audit logs through how Datadog can provide better visibility into Kubernetes
environment security. Check out our documentation to learn more about
Datadog’s Kubernetes audit log integration, or sign up for a free trial to
start monitoring your Kubernetes applications today.
Best practices for monitoring
authentication logs
Justin Massey If you are running a user-facing web application, you likely implement
some form of authentication flow to allow users to log in securely. You may
Maxim Brown even use multiple systems and methods for different purposes or separate
groups of users. For example, employees might use OAuth-based authen-
tication managed by a company-provided Google account to log in to
internal services while customers can use a username and password system
or their own Google credentials. Being able to log, monitor, and analyze all
authentication events is key for identifying security threats and managing
customer records for compliance purposes.
Authentication logs from these different sources and parts of your envi-
ronment might have different formats and be managed by different teams or
implemented using different third-party services like Google, Okta, or Auth0.
This can make meaningful analysis of all authentication activity difficult.
Making sure that your applications write authentication logs that contain
enough information and that use a standard, easily parsable format makes it
easier to perform complex analysis on all authentication logs. For example,
you can quickly identify users or IP addresses associated with the most
failed login attempts. Or, you might want to track trends in login sources
(e.g., username vs. Okta vs. G Suite) and flows (e.g., password vs. OAuth
vs. SAML). A second benefit of standardizing your logs is that it makes it
easier to quickly audit or delete authentication events for specific users for
compliance purposes.
[Link] Best practices for monitoring authentication logs 62
Best practices In order to extract the most information from your authentication events
for writing in a way that is useful, you should:
authentication – Make sure to log everything from all authentication flows
logs
– Write logs that include all the information you may need
– Make sure your logs use a standardized, easily parsable format
LOG EVERYTHING
You are probably logging events from authentication flows that you manage
internally, such as when your employees log in using company-provided
Google credentials. But if, for example, your application allows customers
to create accounts and log in with their own Google credentials, which you
don’t manage, you are likely not collecting those logs.
In order to get visibility into all of your authentication activity, you should
make sure you log events for all login flows at the application level. This
ensures that you’re logging everything, eliminating gaps in your monitoring
coverage. It also gives you more control over how you log authentication
events and what data you are collecting.
This log provides the “who” (John Doe), the “what” (logged in), and the
“when” (2020-01-01 12:00:01) of the authentication event. But it doesn’t
give you information like “how” (e.g., did John use a username and pass-
word, or did he log in with his Google account?) or “where” (e.g., what IP
address did John log in from?). You would also need a separate log event
to indicate a login failure. Without this data, you can’t, for example, monitor
trends in login sources and methods, or identify potential authentication
attacks. Next, let’s look at a log that includes that information:
[Link] Best practices for monitoring authentication logs 63
2020-01-01 12:00:01 google oauth login success by John Doe from [Link]
This log provides more details about the event that you can use to perform
complex analysis more easily. By logging all authentication events at
the application level, you can ensure that your logs contain this level of
information.
2020-01-01 12:00:01 google oauth login success by John Doe from [Link]
If we log this using a key-value format, it might look like the following:
{
"usr": {
"id": "John Doe"
},
"evt": {
"category": "authentication",
"name": "google oauth",
"outcome": "success",
},
"network": {
"client": {
"ip": "[Link]"
}
}
}
[Link] Best practices for monitoring authentication logs 64
Using the same format across all of your authentication logs means you
can easily use these attributes to slice and dice log data to view exactly
the information you need. For example, you can easily look for which users
( [Link] ) have the highest number of failed logins ( [Link]:failure ).
A key-value format also makes it easy to add custom attributes to logs.
For example, you might want each log to include a reCAPTCHA v3 score
to identify possible bot activity. Another important point is to use quotes
to wrap any attribute values that may contain spaces. This ensures that
you capture the full value in a way that is easily parsable.
It’s important to use a standard naming convention for the attributes in
your logs to ensure that you can search and aggregate data across all of
them, regardless of where they come from. We recommend making sure
your authentication logs include the following standard attributes:
– [Link]
– [Link]
– [Link]
– [Link]
– [Link]
[Link]
This attribute identifies the user who is requesting authentication. You
should make sure that the value for [Link] is a username or email address
rather than any unique identifier you might use to identify users in your
database. You should also make sure to include a unique username even if
the user does not have one in your database. This allows you to track which
user IDs are failing to login, which can be used to detect an attack.
[Link]
Setting this to authentication makes it easy to search for authentication
events and filter them out from the rest of your event logs.
[Link]
The [Link] should include more detailed information about the source
and method of authentication, such as whether it used SAML ( evt.
name="saml" ) or was a Google login using OAuth ( [Link]="google
oauth" ).
[Link]
This should be set to either success or failure . You can use this attribute
to easily look for patterns in login failures across your applications.
[Link] Best practices for monitoring authentication logs 65
[Link]
This is the IP address of the user or client who is requesting authentication.
Recording this provides insight into where requests are coming from.
Use authentica- Now that you are collecting and parsing key data out of your authentication
tion logs to logs, you can use them to detect possible security threats. For example,
detect common if you see a significant number of failed login attempts from a single user
security threats within a short period of time, it could indicate a brute force attack.
If those failed login attempts are followed by a successful one, it could be
a successful account takeover that you should investigate immediately.
Another common authentication attack technique that you can easily look
for in your logs is credential stuffing. Credential stuffing is when an attacker
mixes and matches breached login credentials to try to match a real user
account. In order to detect this type of attack, you can look for logins using
multiple [Link] values all coming from the same [Link]
Multiple logins from one IP address using several different user IDs could indicate a credential
stuffing attack.
Next, we’ll look at how Datadog can help you automatically detect
malicious activity like these and other attacks by monitoring your
authentication logs.
[Link] Best practices for monitoring authentication logs 66
Monitor With Datadog Cloud SIEM, you can easily monitor your authentica-tion logs
your authenti- and get alerted to possible attacks or other suspicious activity.
cation logs You can create custom dashboards to visualize key authentication data
with Datadog like counts of logins by source and outcome. This provides you with a high-
level view of activity across your entire user base and helps you see trends
in how users are logging in and the top sources of failed logins, so you can
identify suspicious spikes that you need to investigate.
Datadog includes turn-key Detection Rules that scan 100 percent of your
ingested logs in real time for common attacker techniques. If any log trig-
gers one of these rules, it generates a Security Signal that includes key data
about the event, such as the type of attack detected and suggestions on
a response strategy. You can easily view, filter, and sort all of your Security
Signals in the explorer to triage them and see where to focus your efforts.
[Link] Best practices for monitoring authentication logs 67
Datadog ingests and analyzes all of your logs, ensuring that you can
detect threats across your entire environment. You can archive any logs
that you don’t want to index, and then quickly rehydrate them in the
future for investigations, audits, and compliance purposes.
[Link] Best practices for monitoring authentication logs 68
Get insight In this post we looked at some best practices for managing authentication
into all of your logs that can help you easily track and analyze user activity and identify
authentication security threats across your environment. With Datadog, you can get even
events more insight into the security of your applications as well as the health
and performance of the rest of your stack, all from a unified platform.
If you’re not a Datadog user, sign up for a free trial to start monitoring your
authentication logs today.