A Crash Course in Audit Logs

DevSecCon
29 Jun 202010:59

Summary

TLDRJustin Massey, a product manager at Datadog, discusses the importance of audit logs for security and analytics. He emphasizes the need for detailed logs that include user actions, IP addresses, and outcomes to detect threats like brute-force attacks. He also highlights the challenges of log management, such as responding to customer requests for logs and the 'right to be forgotten'. Massey suggests using a structured log format and central audit log function to improve log quality and monitoring.

Takeaways

  • 🔍 Audit logs are essential for analytics and threat detection, allowing you to detect outliers and suspicious activities, such as brute-force attacks.
  • 👥 It's crucial to have audit logs in a good format to quickly provide them to customers, especially during security incidents or investigations.
  • 🗑️ Customers may request deletion of audit logs (Right to be Forgotten), so logs should be structured to facilitate easy deletion.
  • ❓ Effective logs should answer basic questions: Who did what, where, when, and why. These details help in analyzing and troubleshooting.
  • 🗃️ Logs should be structured in a standardized format, such as using key-value pairs, to enable easy searching and parsing by machines.
  • ⚙️ A centralized audit log function should be used for consistent logging across different parts of an application.
  • 📏 Monitor changes to the audit log function file using code owners or CI checks to ensure integrity and consistency.
  • 🌐 Correctly logging IP addresses is vital. Ensure the original client IP is logged, not an intermediary, like a load balancer's IP.
  • 🔗 Use request IDs to correlate logs across different services and components, ensuring traceability of all actions within a system.
  • 📈 While CRUD operations (Create, Read, Update, Delete) are essential to log, reading operations may require special handling due to high volume.

Q & A

  • What is Justin Massey's role at Datadog?

    -Justin Massey is a product manager for Datadog.

  • What is the main focus of Justin's work at Datadog?

    -Justin's work focuses on threat detection, specifically dealing with audit logs and their analysis.

  • Why are audit logs important for analytics?

    -Audit logs are important for analytics because they can help detect outliers and unusual activities, such as a high number of failed logins by a specific user.

  • What is the purpose of threat detection using audit logs?

    -The purpose of threat detection using audit logs is to identify potential security threats such as brute-force attacks by analyzing patterns and anomalies in the logs.

  • Why do customers typically request audit logs?

    -Customers typically request audit logs during security incidents when they are investigating issues within their environment.

  • What is the 'right to be forgotten' in the context of audit logs?

    -The 'right to be forgotten' refers to the ability to quickly delete audit logs when requested by customers, ensuring compliance with data privacy regulations.

  • What common issues does Justin observe with application logs?

    -Justin observes that application logs often lack sufficient information such as IP addresses and user actions, making it difficult to analyze and search through them.

  • What basic questions should be answered by audit logs?

    -Audit logs should answer who is doing something, what the user is doing, where it is occurring from, and when it occurred.

  • Why is a structured format for audit logs recommended?

    -A structured format for audit logs is recommended because it makes it easier for machines to read and parse the logs, allowing for quick searching and filtering.

  • What is the purpose of a centralized audit log function?

    -The purpose of a centralized audit log function is to standardize the format of logs across different parts of an application, making it easier to monitor and analyze them.

  • Why is it important to monitor changes to the audit log function?

    -Monitoring changes to the audit log function ensures that any deviations from the standard format are noticed, maintaining consistency and reliability in log data.

Outlines

00:00

🔍 Audit Logs and Threat Detection

Justin Massey, a product manager for Datadog, emphasizes the importance of audit logs for threat detection. He points out that application logs often lack essential information needed for analytics and threat detection. Massey suggests structuring audit logs to include who performed an action, what action was taken, where it was done (e.g., IP address), and why it was done. He highlights the need for audit logs to be in a good condition for quick retrieval during security incidents and for compliance with 'right to be forgotten' requests. Massey also discusses common issues with logs, such as missing IP addresses or unclear user actions, and proposes a structured format for logs to facilitate easier searching and analysis.

05:01

💻 Centralized Audit Log Function and Monitoring

The speaker discusses the creation of a centralized audit log function, which standardizes the logging format to include attributes like user, event, and outcome. This function helps in monitoring changes to the log file and ensures that logs are consistent and machine-readable. The speaker also advises monitoring the log file for any changes and being aware of such changes promptly. They touch upon the importance of logging the correct IP address, especially in scenarios involving load balancers, and the use of request IDs to trace logs across the application stack. The paragraph also covers considerations for which events to log, distinguishing between state-changing and non-state-changing API calls, and the need to log reads for potential data breach investigations.

10:02

🗂️ Storage and Handling of Audit Logs

In the final paragraph, the focus shifts to how audit logs should be stored and handled. The speaker raises questions about the storage method, whether on-disk or replicated to a secure location like S3, and the importance of ensuring logs can only be read once. They also discuss how to handle deletion requests efficiently if logs are well-formatted. The speaker encourages considering both security and operational use cases when deciding what to log and emphasizes the need to clearly define what should be monitored and logged.

Mindmap

Keywords

💡Audit Logs

Audit logs are records of events that occur within a system, capturing who did what, when, and where. In the video, Justin emphasizes their importance for analytics, threat detection, and compliance, noting that well-structured audit logs can help identify anomalies like failed logins, support investigations during security incidents, and comply with regulations like the 'right to be forgotten'.

💡Threat Detection

Threat detection involves identifying suspicious or malicious activities within an environment, often using data from logs. The video discusses using audit logs to detect security threats, such as brute-force attacks, by analyzing authentication events and failed login attempts to identify outliers or unusual patterns.

💡Structured Log Format

Structured log format refers to a consistent and standardized way of formatting log entries, making them easier to read and analyze. Justin suggests using key-value pairs (e.g., 'user=John Doe') to enhance the readability and searchability of logs, allowing teams to more easily parse and filter data for analytics and security purposes.

💡Log Analytics

Log analytics is the process of analyzing log data to gain insights into system behavior, security, and performance. In the video, Justin highlights the importance of having logs in good condition for effective analytics, allowing users to detect anomalies, drill down into specific events, and visualize trends in audit data.

💡Event Outcome

The event outcome in logging refers to the result of an action, such as 'success' or 'failure'. In the video, Justin emphasizes the need to standardize outcomes (e.g., success vs. failure) to avoid ambiguity and ensure that log entries are consistently interpretable, aiding in analysis and monitoring.

💡IP Address Logging

IP address logging involves recording the source IP address associated with an event, such as a login attempt. Justin warns about common pitfalls, such as logging the IP of a load balancer instead of the actual client, which can mislead security analysis. Properly capturing the originating IP is crucial for accurate auditing and threat detection.

💡Centralized Logging Function

A centralized logging function is a standard method or tool used across an application to create consistent log entries. Justin suggests implementing such a function to enforce log formats, manage data integrity, and ensure consistent logging practices across different modules, which simplifies monitoring and analytics.

💡Right to be Forgotten

The right to be forgotten is a privacy principle that allows individuals to request the deletion of their data from systems. In the video, Justin mentions the importance of structuring logs in a way that enables quick identification and deletion of relevant data when customers exercise this right, ensuring compliance with privacy regulations.

💡CRUD Operations

CRUD stands for Create, Read, Update, and Delete—common operations in API and database contexts. The video discusses the importance of logging these operations, particularly the 'Read' actions, which are often high-volume but necessary to capture for security purposes, such as tracking data access during a breach investigation.

💡X-Forwarded-For Header

The X-Forwarded-For header is used in HTTP requests to identify the originating IP address of a client connecting through a proxy or load balancer. Justin highlights that improper use of this header can result in logging incorrect IP addresses, which could undermine the accuracy of security audits and threat detection processes.

Highlights

Audit logs are essential for performing analytics and threat detection on authentication events.

Outlier detection: Identifying unusual behaviors, such as a specific user with more failed logins, is critical for security analysis.

Audit logs need to be in a structured format to easily perform analytics, drill down into specific users or IP addresses, and filter events.

Threat detection: Properly formatted audit logs are key to detecting potential security incidents, such as brute-force attacks.

Audit logs should be quickly retrievable in the event of security incidents or customer requests, especially when investigating suspicious activities.

Handling data deletion requests, such as the right to be forgotten, requires structured audit logs to efficiently remove specific records.

Many application logs lack critical information such as IP addresses, making it difficult to answer essential security questions.

To improve log searchability, logs should use a consistent format, such as key-value pairs with clear identifiers like user and IP.

A structured log format that includes user identity, event type, outcome, and IP address is more easily parsed by machines for analytics.

A centralized audit log function should be implemented to standardize the log format across different types of authentication (e.g., OAuth, SAML).

It's important to monitor changes to audit log configurations and formats, ensuring any adjustments are tracked and audited.

Correctly logging IP addresses is crucial to avoid logging load balancer IPs, which can lead to misinterpretations of audit data.

Use request IDs to join logs from various parts of the application stack, enabling better tracing of user actions across systems.

Considerations for logging read events: While non-state-changing, read operations should still be logged for security purposes.

Define and monitor for specific security and operational events to ensure relevant data is logged for analysis and threat detection.

Transcripts

play00:00

so my name is Justin Massey I'm a

play00:01

product manager for data dog

play00:03

and rather than dive into the demo the

play00:06

data dog product or talked too much

play00:07

about it we have a sponsor booth for

play00:09

that you can check out that but let's

play00:11

dive deep into audit logs I work on our

play00:15

threats about threat detection product

play00:17

and I I work with a lot of our customers

play00:20

I looked to them about their application

play00:22

logs and best practices and I've worked

play00:25

on many different environments before

play00:28

and the application logs always seem to

play00:30

be lacking some information so one thing

play00:33

we want to do with these application

play00:35

logs is we want to do analytics on them

play00:36

and analytics we have like our analytics

play00:40

on the right-hand side and our actual

play00:42

logs on the left-hand side now these are

play00:44

all of our authentication events so

play00:46

imagine you wanted to detect a an

play00:51

outlier and you see that this outlier

play00:53

this user admin has more is it has more

play00:57

failed logins than the rest if you

play00:59

wanted to drill down to this specific

play01:01

user you want to be able to ask

play01:03

questions about that why and you may

play01:06

want to drill down to a specific IP

play01:08

address and you want to take a look at

play01:09

that now you want to you you've now

play01:12

quickly drilled down you can see all of

play01:13

this information regarding this specific

play01:17

audit blog but first to get here you

play01:19

have to have your audit logs in a good

play01:21

condition the next thing you want to do

play01:24

on these audit logs is you want to do

play01:26

threat detection on them you're going to

play01:28

want to look at they sim audit logs and

play01:30

ensure for this example you may be

play01:34

wanting to detect it like a potential

play01:35

potential brute-force attack now another

play01:39

thing that you use your audit logs for

play01:42

is customers ask for them and then when

play01:45

they're asking for them it's typically

play01:47

not at a good situation your audit the

play01:49

customers are asking for those auto logs

play01:51

because something else in the

play01:52

environment is going going on maybe they

play01:55

have a security incident and they are

play01:56

investigating so you want to be able to

play01:58

return these audit logs in a quick

play02:00

manner next after the customers ask for

play02:04

them they're going to ask you to delete

play02:05

them so this is the right to be

play02:07

forgotten so you want your audit logs in

play02:10

a good format where you can quickly

play02:12

delete

play02:13

when the customers have requested that

play02:16

so yes what's the problem well I've

play02:21

logged into many different applications

play02:25

when I'm starting a new job and I've

play02:26

taken a look at our application logs and

play02:28

something like this happens you see John

play02:31

Doe logs in and it doesn't necessarily

play02:33

say what IP address it was from the next

play02:37

one is a login from that's likely

play02:39

addressed but what user just did it then

play02:42

you have password reset was cents it to

play02:44

who you're not answering all the

play02:46

questions here and even though that this

play02:48

John Doe logged in and this failed login

play02:51

these proposed the communication events

play02:53

where the outcome may have been

play02:54

successful or unsuccessful there are

play02:56

very similar logs but you're not showing

play02:59

that and it's going to be very hard to

play03:02

present this in an analytical way or

play03:05

search for these logs once they're

play03:08

stored so if you want to do things like

play03:11

show your top audit logs you need a

play03:14

better format so how do we talk to

play03:17

developers about these audit logs what

play03:20

what can we suggest well I'm gonna pose

play03:23

some very very very basic questions we

play03:25

want to know who is doing something

play03:27

typically this is a user what is that

play03:31

user doing where is that occurring from

play03:34

maybe that's what an IP address when did

play03:38

it occur

play03:39

why so you may don't always be able to

play03:43

answer the question of why why did John

play03:44

do login I don't know but if your audit

play03:47

logs said we lock this user out because

play03:51

the user failed to login five times

play03:54

that's your reason why but you may not

play03:56

have a Y for every single log so we take

play03:59

this example log we have the timestamp

play04:02

John Doe logged in from 1.2.3.4 with

play04:06

OAuth so this gives us a little bit more

play04:09

information it asks it answers all of

play04:10

those questions however your developers

play04:14

may have done this for OAuth but for

play04:16

something like sam'l the format may have

play04:18

changed even though the login was still

play04:21

a login it was just a different type so

play04:23

being able to search these it makes it

play04:25

very difficult

play04:26

so I'm gonna pose that we use a little

play04:29

bit more structured format what if we

play04:31

said user equals John Doe and we've used

play04:34

the equal as a delimiter and we've put

play04:37

quotations around that users name and

play04:40

we've said that the event is an

play04:42

authentication event the outcome of that

play04:44

event was successful so we answered to

play04:47

what questions here what was the event

play04:49

and what was the outcome now we have an

play04:52

IP address where they logged in from the

play04:55

type of authentication and the type type

play04:58

people's on it we've appended this audit

play05:00

so that we can quickly search to search

play05:02

and filter down to all of our audit

play05:03

events now a machine can easily read

play05:07

this you're seeing this imagine if you

play05:11

had a grok parser or some sort of reg X

play05:16

you can quickly filter down these key

play05:18

value pairs and you get something that

play05:19

looks like this user John Doe event and

play05:22

then you can see how much easier it is

play05:25

to gather that information about what

play05:27

the specific event was and graph this

play05:30

and display this and whatever way you're

play05:33

doing your log management now how do you

play05:36

get there

play05:38

you want some sort of central audit log

play05:40

function this is a very basic function

play05:43

[Music]

play05:44

pseudocode looks something like python

play05:48

it takes in a couple of different

play05:50

attributes it would take in the request

play05:52

object the event and the outcome now

play05:56

you'll see that the first thing I do in

play05:58

the outcome is I put it allow list here

play06:01

for success in failure and the success

play06:04

and failure I do this because there's

play06:06

many different ways to say success you

play06:08

can say success successful or failure

play06:11

you can say fail failed failure that

play06:13

there's a lot of different ways to say

play06:15

this so we just put a little allow list

play06:16

here and require that they are in this

play06:19

list the next thing we do is we put it

play06:23

in that exact format and we're gonna let

play06:25

the let the logger handle the timestamp

play06:28

format so once you have this centralized

play06:32

audit function I want you to monitor it

play06:34

and what I mean by monitor is if there

play06:37

are changes to this file maybe this is

play06:39

just in like

play06:40

if this was like say it's like lager pie

play06:42

if there's ever a change to this file

play06:45

you should know so whether that's

play06:47

setting a code owners file in github or

play06:49

having something in a CI check please

play06:52

monitor make sure that it's when it has

play06:55

changed

play06:56

you are aware of that change so a couple

play07:00

things to keep in mind when you're

play07:03

talking about users may be you may be

play07:05

asking the question you know was this

play07:07

request from an API key or was it from a

play07:09

browser session or what happens if the

play07:12

user has five API keys and I need to one

play07:16

of these API keys is compromised so I

play07:19

need to know which one was the one

play07:20

making the request so you should take us

play07:24

in mind when adding this into your log

play07:26

file next thing I want to talk about is

play07:29

IP issues I've seen many many logs where

play07:32

they are in the wrong where they're

play07:34

logging the wrong IP address and

play07:36

typically this happens in HTTP logs due

play07:38

to the improper use of x-forwarded-for

play07:40

headers you take a look at this if John

play07:43

Doe makes a request to a web application

play07:46

through a load balancer you may be

play07:49

getting the IP address of the load

play07:52

balancer and logging that into your

play07:54

application looks that is not good that

play07:56

is not what you want you want the

play07:59

original IP address of John Doe so

play08:03

please please please make sure if your

play08:06

web application should only be external

play08:07

to external applications maybe you can

play08:09

make sure that the IP address matches an

play08:14

external IP address format next thing I

play08:17

want to talk about are joints if you

play08:20

take that same scenario where you have a

play08:21

load balancer in a web application you

play08:24

may want to gather other information

play08:26

from that initial request in your web

play08:28

application log you may not have the

play08:30

user agent but you want to know that

play08:32

user agent information how do you gather

play08:35

that information well if you don't have

play08:37

an ID to join them together it's not

play08:40

going to be possible

play08:41

so I recommend adding a some sort of

play08:45

request ID in here so you can trace it

play08:47

through the entire application stack and

play08:49

that should be logged in all the all the

play08:51

logs so that you can quickly filter down

play08:53

and see every

play08:54

single every every single log that was

play09:00

associated with that request so next

play09:04

thing I want to talk about are some

play09:05

considerations with which events to log

play09:08

when we're talking about API we commonly

play09:11

talked about crud create reads updates

play09:14

deletes one of these is not like the

play09:16

other reads reads are non state changing

play09:20

API calls however they should be logged

play09:23

but you're going to have a large number

play09:27

of reads very very likely you're gonna

play09:29

have a high number of reads so you may

play09:31

need to consider the storage of the

play09:34

reads differently than the stateful

play09:37

configurations now don't know don't

play09:39

think you don't have to log the reads

play09:40

you should log the reads because you're

play09:42

going to need say the data breach

play09:44

happens and you want to identify what

play09:47

content was accessed you want those

play09:50

reads so what should you monitor for

play09:54

this is just a when you're when you're

play09:57

figuring out what's a log you need to

play09:58

think about like what exactly are you

play09:59

monitoring for and if you're in security

play10:01

it's not only security use cases

play10:03

there's also operational use cases you

play10:05

need to ask so just think about this

play10:07

write down exactly what you want to

play10:09

monitor for and make sure that those

play10:11

events make it into the logs a couple of

play10:15

things extra things to ponder is how

play10:17

you're storing your audit logs you know

play10:19

are you storing these on disk and then

play10:21

replicating them to you know some

play10:24

offline or like s3 are you making sure

play10:28

that these can only be like read once

play10:32

right many like how are you storing

play10:34

these audit logs how do you handle those

play10:38

deletion request I mentioned earlier if

play10:40

you have logged that information and in

play10:44

a nice format it maybe is going to make

play10:46

your life a lot easier to run a script

play10:48

and delete that content that has to be

play10:50

deleted with that that's that's all the

play10:55

talk today Sam I'll hand it back to you

Rate This

5.0 / 5 (0 votes)

Связанные теги
Audit LogsSecurityAnalyticsDatadogThreat DetectionLog ManagementComplianceMonitoringData PrivacyProduct Management
Вам нужно краткое изложение на английском?