By now, you know what your cloud assets are, and you have put some reasonable protections in place for them. Everything’s good, right?
When you’re two-thirds of the way through a mystery novel and the mystery appears to be solved, you know the story isn’t over. It’s probably not a big surprise that you’re not done with cloud security yet either, since there are still pages left in this book.
All of the previous chapters have dealt with identifying your assets and protecting them. Unfortunately, you won’t always be successful. In fact, in some organizations and industries, minor security incidents are a routine part of life! At some point attackers will almost certainly attempt, sometimes successfully, to gain unauthorized access to your assets. At that point, the trick is to detect them as quickly as possible, kick them out, and do whatever damage control is needed. As part of this, it is helpful to understand what attackers often do and how attacks often proceed.
We’ve seen many high-profile breaches in the past few years. What often distinguishes a bad breach from a really bad breach—there are no good ones—is how long it took to detect what was going on and how effectively the victim responded. One recent study of more than 550 organizations showed that the mean time to identify a breach was 277 days, and that companies that identified a breach in fewer than 200 days saved more than $1 million compared to those that took more than 200 days. With that in mind, let’s see what we can do to detect issues and respond to them before they become disasters.
MITRE ATT&CK and Kill Chains
There are several resources that attempt to describe what an attacker might do. The most popular as of this writing are the MITRE ATT&CK framework (pronounced “attack”) and the Lockheed Martin Cyber Kill Chain , but there are others, such as the Unified Kill Chain .
MITRE ATT&CK is generally more detailed than the kill chains and shows different tactics, techniques, and procedures (TTPs) that an attacker might use in different phases of the attack and in different computing environments.
The kill chains are more like outlines, listing common steps in the order that attackers typically take them in, such as reconnaissance, weaponization, delivery, exploitation, installation, command and control, and action on objectives.
I recommend that your incident response team read through and understand at least one kill chain model, as well as some of the TTPs in the MITRE ATT&CK cloud matrix. Understanding what attackers are likely to try can help when responding to an active attack. We’ll look at one example later in this chapter.
Differences from Traditional IT
Take another look at the shared responsibility model diagram from Chapter 1 ( Figure 1-8 ).
In a traditional environment, you had to worry about what was happening at every one of these levels. The good news about cloud environments is that intrusion detection and response are the provider’s job, in the areas that are their responsibility. Rarely, you could be affected by a breach at your provider, in which case you should be notified and may need to perform response and recovery activities specific to the services you’re using. However, in the vast majority of cases, all of your detection, response, and recovery activities will be in the areas marked “consumer responsibility.”
For the most part, you don’t get to see any logs from the levels that are the provider’s responsibility, although you can sometimes see actions the provider has taken on your behalf, such as accessing your encryption keys. However, there’s an important new source of privileged user logs in a cloud environment: you can track things your team did using the provider’s portals, APIs, and command-line interfaces.
You won’t be allowed to touch the physical hardware in a cloud environment. Many incident response teams use a “jump bag” with forensic laptops, hard drive duplicators, and similar technology. Although you may still need such tools for dealing with incidents involving non-cloud infrastructure (for example, malware infections on on-premises servers), you will need virtual, cloud-based equivalents of the jump bag tools for incident response in the cloud. This also means that the forensic parts of cloud incident response can be done from anywhere, although there may still be benefits to being physically colocated with other people involved in the response.
What to Watch
Any system of reasonable size offers so many different logs and metrics that it’s easy to get buried in data that’s not useful for security purposes. Picking what to watch is very important! Unfortunately, this will necessarily be specific to your environment and application, so you really need to think about your threat model—what assets you have and who is most likely to attack them—as well as what logs come out of the systems in your asset management pipeline, discussed in Chapter 3 .
As an example, if you have many terabytes of data, watching metrics on the volume of your network traffic and the length of connections might be very useful to spot someone in the process of stealing it. However, network traffic metrics like that won’t be as useful if you’re distributing software that you think someone may try to compromise with a backdoor. In that case, the volume of data, destination, and session length won’t change, but the content will be corrupted.
As another example, if you’ve paid for a specific tool such as antivirus software, and have done the work to ensure that all of your cloud VMs are running it, it’s pretty silly to ignore it when it’s screaming that it has found something. When you see alerts from that tool, it may have successfully protected you from the entire attack. However, it may also have blocked only part of the attack, or it may have detected something suspicious but not blocked it. You need to investigate to see how the malware got on the system and whether the attack was fully blocked or not.
Once you have a threat model in mind, and a good idea of what components make up your environment, the following sidebar covers some good general starting points for what to watch. We will look at more concrete examples when we consider the sample application at the end of the chapter.
Logs, Events, Alerts, and Metrics
A log , or event , is a record of a specific thing that happened. For example, your environment might generate a log record whenever someone authenticates, or makes a web request, or changes a configuration, or any number of other things that could happen in a complex environment.
An alert is a type of event where the system’s rules indicate that it’s worth notifying someone. The fact that antivirus software pulled updated definitions is an event. The fact that it actually found malware should be an alert!
Metrics are sets of numbers that give information about something. Metrics are usually time-based, so you might have a metric collected every minute for how many authentication requests have happened, how much free disk space is available, or the number of web requests made.
The primary advantage of logs is that they provide a lot more information about what has happened, but the cost of storing and searching logs can increase quickly as activity increases. If you have twice as many web requests, you have twice as many log records! On the other hand, while the numbers reported by metrics during each time period will get larger as activity increases, the cost of storing and processing the metrics doesn’t increase (because it usually takes the same space to store the numbers 100 and 200). Both logs and metrics can be useful for detecting security incidents and generating alerts, and metrics can sometimes be a better choice for alerting when there are too many log entries to deal with.
For each of the following types of events, you need to make sure that the log entries contain enough data to be useful. At a minimum, this usually means when , what , and who : when the event happened, what happened, and who triggered the event. In some cases “who” might be a system or other automatic tool, such as when a system reports high CPU usage.
Warning
With one exception, you should never put passwords, API keys, sensitive personal information, protected health information, or any other sensitive data in logs. In most cases, not every individual who has access to the logs is authorized to see that information. In addition, having copies of sensitive information in more places than necessary increases the risk that it will be accidentally disclosed.
In fact, for privacy reasons, you should avoid directly logging personally identifiable data wherever feasible. If you need to be able to figure out who is referred to in logs, use non-personally identifiable unique IDs, such as GUIDs, and keep a table elsewhere that lets you correlate those GUIDs to the actual entities.
The exception to the rule about sensitive data in logs is session recording for privileged user monitoring, which may occasionally log API keys used on a command line or other sensitive information. In this case, access to the session records must be very tightly controlled, such as by sending them to a “deposit only” location so that only a small monitoring team is able to see them after they’re generated. The risk reduction from being able to audit privileged user sessions will often outweigh the increased risk of occasional secrets in those records.
Privileged User Access
Almost everyone should be logging and at least spot-checking privileged user logins at all levels of their environments. Watching these can be a great way to trigger questions that lead to detecting malicious activity, such as “Why is that person logging in at all?” or “Didn’t that person leave the company?” or “Does anyone recognize this account?”
Monitoring privileged user access doesn’t mean you don’t trust your administrators. In a perfect world, you wouldn’t have to place 100% trust in any single individual. Every task that involves a risk would need to be approved by at least two people, requiring collusion in order to perform such tasks without being detected. 1 That level of diligence certainly isn’t necessary for all tasks in all organizations, although you should consider it for high-value actions such as money transfers or access to secret data stores. What we’re mostly focused on here is detecting an unauthorized person pretending to be an administrator. Given that one of the most prevalent causes of security incidents is lost or stolen credentials, watching what your administrators are doing is a great way to catch someone pretending to be an admin.
Cloud providers can keep good logs of when someone logged on as one of your administrators using the cloud administrative interfaces (the web portal, APIs, or command-line interfaces), and what they did—for example, you may see logs such as “created an instance,” “created a database,” or “created an administrative user.” These logs may be collected by cloud services like AWS CloudTrail, Azure Activity Log, Google Cloud’s operations suite, and IBM Cloud Activity Tracker; but in some cases you have to explicitly turn on the logging feature, specify where and how long to retain logs, and pay for the storage.
In addition to privileged user logs collected by the cloud provider, administrators often also have privileged access to the systems created in the cloud environment. For example, you may have administrative accounts on virtual machines, or on firewall appliances, or on databases. Access to these may be reported using a protocol like syslog. You may also have other systems used by administrators, such as a password vault to check out shared IDs. Generally speaking, any systems used by administrators to perform privileged actions should log those actions for later inspection.
Administrative activity logs should be divided into two types, which I’ll label toxic logs and sanitized logs.
Toxic logs might contain sensitive information, such as passwords and API keys that could give an attacker direct access to the system. You may not have any toxic logs in your environment. In general, toxic logs should be accessed only during a suspected incident, or by a small, monitored team that regularly spot-checks administrative sessions. When toxic logs are accessed, that should also trigger some form of notification so that at least two people know the logs were accessed. Here are some examples of toxic logs:
-
Secure shell session logs or other logs showing commands and options
-
The exact commands executed by admins on virtual machines via a cloud provider feature such as Amazon EC2 Run Command, unless you have some way to keep secrets from being logged with those commands
-
The exact commands executed by admins on containers, such as those beginning with
kubectl exec, unless you have some way to keep secrets from being logged with those commands
Sanitized logs are specifically designed not to contain secrets. The vast majority of logs should fall into this category. Here are some examples of sanitized logs:
-
Actions that the admin performs via a cloud API or the cloud provider console
-
Actions that the admin performs on the Kubernetes console, such as deploying a new application or authorizing additional users
-
Successful and failed authentication and authorization attempts for any of the components in the system (for instance, if an administrator successfully logs into the cloud console but is not allowed to create a resource there, both events should be logged)
Session Recording Tools
One of the functions usually included in privileged access management or privileged identity management systems is session management—the ability to record privileged sessions, as well as watch what a privileged user is doing in real time and disconnect sessions that are suspicious. This is particularly important in areas where the systems being managed have high confidentiality or integrity requirements, and there’s a significant incentive for attackers to either access or change the data managed by these systems.
Session recording tools generally work in one of two models: either all sessions go through one central location for recording and control, or session recording happens using agents on the servers themselves. Having everything go through a central location has the downside of a single point of failure. Having everything logged by a local agent on the server has the downside that the privileged user often has the privileges to turn off the agent. In general, I recommend having centralized session recording, with a break-glass process to gain access if the session recording infrastructure is down.
The privileged users of most of the systems being managed and the privileged users who manage the session recording tool should generally be different groups. Again, you want to set up a system where no single individual (or attacker pretending to be that individual) can issue malicious commands and also disable the logging of those malicious commands.
As previously mentioned, session recording logs are “toxic,” in that they may contain passwords or other secrets. I generally recommend that session recording tools be configured to deposit logs in a “drop box” fashion, where the recording tool can send logs to a centralized location but does not have a local copy and cannot see or modify the logs after sending them.
Logs from Defensive Tooling
If you have defensive tools like antivirus software, firewalls, web application firewalls, intrusion detection systems, or network monitoring tools, you need to be looking at the logs that these produce. You can’t be certain that those tools will be 100% effective in preventing all attacks. In some cases, the tools may block the initial attack and let a subsequent attack through, or they may only log that something happened without blocking the attack. You need to collect and analyze the logs from these services, or you may be giving up a big early-warning advantage.
The problem is that some of these tools are necessarily noisy and have a high percentage of false positive alerts. Don’t underestimate the risk of false positives! It’s very easy to train yourself and your staff to ignore alerts that may actually be important. You need a feedback loop so that people seeing false positives have a way to try to either filter out specific logs from processing altogether or tune the system so that the tools don’t produce false alerts as often. This is an art, of course, because you run the risk of filtering or tuning out true positives, but in most cases you should accept a small risk of tuning out a true positive to prevent your team from ignoring the alerts altogether. Just as you should have multiple layers of protection, you should also have multiple detection layers so that you’re not dependent on only one tool to detect malicious activity.
The logging recommendations for most defensive tooling in cloud environments are very similar to in on-premises environments.
Anti-DDoS
Systems used to defend against denial-of-service attacks should be configured to alert on attacks. This should generally be a high-priority alert, such as paging someone, because DDoS attacks often escalate over time or are followed by an extortion attempt. In addition, a DDoS attack can be a distraction to cover up other breach activity, although there is disagreement as to how common this is.
Web application firewalls
Both distributed and centralized WAF solutions can alert on attacks that were blocked or on requests that look suspicious. These alerts can be useful to understand when an attack against your web applications has been attempted.
Tip
WAFs are often used in lieu of manual code reviews for PCI DSS certification. As part of that, you’ll also need to show that you’re retaining and analyzing the logs from the WAF systems.
Firewalls and intrusion detection systems
Internet-facing firewalls and IDSs will need to be tuned fairly low for alerting, because systems exposed to the internet are under constant low-grade attack (such as port scans and password guessing). However, the historical data provided by these systems may be of use when an incident is suspected.
On the other hand, a firewall or IDS deployed inside your perimeter should be tuned to be fairly sensitive, because alerts here are probably indicative of misconfiguration or an actual attack. Aside from other defensive tools, which can be allowlisted so that they don’t cause alerts, nothing else should really be scanning your internal network or causing failed connections.
In this same general category are network traffic analysis systems, which typically aggregate flow data from routers and switches to give an overall picture of how data is moving into, out of, and through your environment. These can also be configured to send alerts that might indicate something is wrong.
Antivirus
Ensure that you will get alerts if any in-scope systems in your asset management system aren’t running antivirus software, and if any malware is found.
Note that when an attacker exploits a vulnerability to get into your system, their first step is usually to drop some malware on the system. If the attacker is smart, they’ll make sure the malware they use is custom enough not to trip any antivirus software you have in place. Attackers can use services or may have labs to run their malware through every piece of antivirus software available to make sure it isn’t detected. Fortunately, not all attackers are that smart, and these tools are still very helpful to catch the dumb ones. Don’t reject tools just because they’re not 100% effective!
Note
In the infamous 2013 Target breach, one of the mistakes was not responding to the alerts from the antivirus software.
Detection and response tools
Whereas traditional anti-malware software focuses primarily on blocking malicious activity, endpoint detection and response (EDR) software is more focused on allowing teams to investigate and respond to threats that have gotten through the first line of defenses. If antivirus software is like the flame-retardant materials in a physical structure, the EDR software is like the smoke detector and sprinkler systems.
EDR is typically done by recording lots of information about the running systems, such as hash values of each executable or library that has run on the system, or a history of what network connections were attempted or made. While some of this information may be obtained via operating system or network logs, EDR software can accumulate it all in one place easily. There, it can be associated with threat intelligence feeds, such as newly discovered command-and-control servers or newly reported malware signatures, to detect both current and historical activity. Some EDR software can also be used to quarantine and investigate systems when an attack is identified.
While these capabilities are often used interactively by a response team, EDR solutions can also send alerts when threats are discovered in your environment, so they overlap somewhat with antivirus software.
All the DRs
The market is filled with many types of detection and response tools—as of this writing, EDR, NDR, and XDR are the most common categories. The definitions of these overlap somewhat and are not universally agreed upon, and many vendors will try to convince you that their tool can do everything. Let’s take a quick look at each.
Endpoint detection and response (EDR) tools, as described earlier, offer three main benefits over traditional antivirus tools. The first is the use of many other signals besides signatures and process behaviors to alert on suspicious activity. The second is the ability to look back in history to see who or what is already infected, based on new information. The third is the ability to quickly quarantine an entire system that appears to have been compromised, rather than just quarantining a suspicious file.
Network detection and response (NDR) is similar, but for network flows. NDR tools often offer behavioral analysis in addition to signature checking, similar to network traffic analysis systems, as well as the ability to quickly lock down network flows in response to an active attack.
Extended detection and response (XDR) is typically a combination of several different security products integrated together, although different vendors combine different functions and call it XDR.
Regardless of the technologies you use, ensure that you’re consuming the alerts from the tools and responding to them.
File integrity monitoring
Some files shouldn’t change regularly, and if they are changed, that might be evidence of an attack. For example, if someone modifies the configuration of the logging system, that’s suspicious. In fact, on a Linux system, most changes to the /etc directory tree should be viewed with some suspicion.
File integrity monitoring (FIM) software can alert when specific files are changed, and some products also allow you to alert when certain Windows registry entries are changed. Some cloud providers offer FIM capability as part of the IaaS cloud management platform. There are also free and paid versions of FIM products that you can deploy to your systems.
Tip
File integrity monitoring is explicitly required for PCI DSS certification, and some auditors may require it to cover not only flat files but also changes to the Windows registry.
Cloud provider monitoring tools
Cloud provider monitoring tools, such as AWS CloudTrail, Azure Monitor, and IBM Cloud Activity Tracker, can provide important insight into what the different entities inside your cloud account are doing. This is particularly important for privileged users or highly privileged service accounts.
These tools will typically have the ability to both collect logs and set alerts for actions that either should never happen or should be rare enough that they warrant notifying other users. Some examples of these types of actions may be assuming a privileged role inside the cloud account or changing security parameters of the cloud account or critical services in the account.
Cloud Service Logs and Metrics
In addition to logging administrator actions, most cloud providers also offer useful logs and metrics about their services. Browse through the logs and metrics available for the cloud services you’re using, and think about which ones might go haywire in an attack and/or be useful for figuring out how bad things are after the fact. Here are some examples:
CPU usage metrics
Spikes in CPU usage not explained by increased usage might indicate active ransomware encryption or cryptomining.
Network logs and metrics
For example, if you are using virtual private cloud subnets, many cloud providers can provide metrics on the data passing into and out of these subnets, as well as flow logs showing accepted and denied traffic. Denied traffic when the source is your own component indicates either a misconfiguration or an attack, and should be investigated. Spikes in network traffic might indicate that a denial-of-service attack is beginning or that an attacker is actively stealing data.
Storage input/output (I/O) metrics
A spike in I/O not explained by increased usage might indicate active ransomware, a denial-of-service attack, or an attacker in the process of stealing data.
Metrics on requests to platform components, such as databases or message queues
If your database starts going crazy, that may be an indication of an attacker stealing large amounts of data. If your message queue starts going crazy, perhaps an attacker is in part of the system and is attempting to send messages to other components.
End-user logins and activity on SaaS offerings
If a user starts pulling down huge amounts of data from a cloud storage service, that could be an indication that the account is compromised. If you’re using a cloud access security broker (CASB) to mediate access to a cloud service, it may also generate more detailed events related to user activity that you can monitor.
Platform service logs and metrics
Each platform service may have logs and metrics that are useful for detection and response in addition to operational monitoring. For example, if you’re using an orchestration platform such as Kubernetes, you can turn on auditing. The Kubernetes documentation explains how to turn on audit logging and how to direct those logs to a collection point. Similarly, object storage, databases, and other cloud services have service-specific logs and metrics.
Operating System Logs and Metrics
If you are running virtual machines or bare-metal machines in the cloud, the security of the operating system is generally your responsibility, and this includes collecting and analyzing logs. This is similar to on-premises infrastructure:
-
The CIS Benchmarks list is a reasonable base set of events to log for many different operating systems, products, and services that you may have in your environment.
-
If you’re using Windows, Microsoft provides some good information about event IDs to monitor. For example, a fairly common type of attack is a pass-the-hash attack, and the documentation provides information about specific event IDs to monitor in order to spot such an attack.
-
If you’re using Linux, many Linux operating system vendors provide instructions on how to enable audit logging to meet different industry and regulatory requirements. Even if you don’t have to comply with those requirements, the instructions can be a useful starting point for what to log and analyze in your environment.
-
Metrics such as memory usage, CPU usage, and I/O can be very useful to security teams as well as operations teams.
Middleware Logs
If you’re running your own database, queue manager, application server, or other middleware, you may need to turn on logging and metrics collection. In addition to any privileged user activities (see “Privileged User Access” ), you may be able to set up alerts for all access to sensitive databases that originates from anywhere except a legitimate application ID or system, or for access to specific tables, or other alerts useful for tracking access to sensitive data.
Secrets Server
If you’re running a secrets server, as discussed in Chapter 4 , you should log all access to secrets. Here are some examples of unusual activity that you may wish to alert on and investigate:
-
Authentication or authorization failures on the secrets server, which may indicate an attack
-
An unusual amount of activity for secrets retrieval
-
The use of administrative credentials
Your Application
If you’ve written a custom application or are running a third-party application, it may produce its own logs and metrics that could be useful to both operations teams and security teams. For example, a banking application may log all transfers, and transfers over a certain threshold might generate an alert.
Deception Techniques
In addition to other detection technologies, some technologies are designed to make life more difficult for an attacker without bothering your normal users and administrators. The most common example of this is a honeypot , which is a system that sits around pretending to be a functional part of the infrastructure, but whose sole purpose is to distract and slow down attackers and alert you when they’re in the system.
In addition to honeypot systems, there are also honey tokens and honey IDs. Honey tokens can be embedded in useful-looking but fake files (such as next-quarter-secret-plans.docx ) and alert you when and by whom those files are opened. They can also be normally unused items like API keys embedded in source code that alert you when used. Honey IDs are often unused, non-privileged IDs that look appealing to an attacker (like “superadmin”) and which generate an immediate alert if someone tries to use them.
It’s important to note that although “security through obscurity” is ineffective in general, secrecy is essential in the specific case of deception techniques. Do not document the presence of honeypots, honey tokens, or honey IDs in any location where anyone outside of your core security team can learn about them.
Deception technologies can be a useful way to leverage your “home court advantage” in defending your environment, because you can lay traps for attackers that only you know about. However, this is an advanced technique. Make sure you have your logging, monitoring, alerting, response, and recovery plans running effectively before investing much time and effort in deception.
Deception techniques can be used both on-premises and in the cloud. One cloud native example is Microsoft Sentinel Deception .
How to Watch
Now that we’ve covered what types of events and metrics might be good to watch for in your environment, let’s look at how to effectively collect and use them to detect and respond to intrusions. Figure 7-1 shows the different steps in this process. These steps may all be done by a single product or service, such as a SIEM, or by multiple products and services acting together.
Figure 7-1. Logging and alerting chain
Tip
Make sure the time is synchronized on all of your systems, generally by using the Network Time Protocol (NTP). In addition, make sure either that all timestamps contain time zone information or that you use the same time zone (such as GMT) for all logs. This is usually very easy to configure, and it can avoid the nightmare of trying to correlate events between different log sources when the system clocks or time zones are off.
Aggregation and Retention
All of the logs described earlier need to be stored somewhere and kept for a minimum length of time. While allowing logs to collect on various different systems is far better than having no logs at all, it’s far from ideal. Individual system disks may fill up, causing loss of logs and operational problems, and an attacker who gets into a system can erase the logs to cover their tracks. Plus, it can be very slow and inconvenient to get into dozens of different systems to search logs and pull together a picture of what’s going on.
In the past, important logs would often be printed onto paper and shipped to a physically secure location. While that’s a pretty safe way of securing them and making them unerasable by computer, paper has some pretty big drawbacks—it’s not searchable by automation, it’s heavy, it’s expensive, and it’s a fire hazard.
In the cloud, you can get many of the same benefits much more easily by locating your log aggregation service in a separate cloud account with different administrative credentials so that the logs can’t be wiped out by someone with access to the primary systems. (This is also a good idea for backups, as discussed later.) Most cloud providers have services that can aggregate, retain, and search logs so you don’t have to set up log aggregation from scratch.
Tip
You should retain most logs for at least one year. Longer retention periods can sometimes be helpful for investigating security incidents, but longer retention periods can sometimes conflict with privacy regulations. If you’re subject to any industry or regulatory standards, look at the specific retention requirements for those logs, but as of this writing, one year is usually a safe choice.
Once you have all of your logs and alerts in a central, secure location with the proper retention period configured, you need to tackle the problems of looking through those logs to alert on suspicious behavior and of making sure the alerts get to the right people and are acknowledged and investigated.
Parsing Logs
If you have all your logs aggregated in a safe place, congratulations! A determined human can eventually go through all of those logs and get answers to important questions, although it may take a while. However, one of the primary motivations for inventing computers was to process data much faster than humans can.
Log parsers pull specific pieces of information (fields) out of the different types of events. Here are some examples of log parsers at work:
-
For an operating system event, the parser will recognize the timestamp, the name of the system generating the event, and the event text. Further parsing may happen for some types of events; for example, for a failed login event, the parser can also recognize the IP address from which the login was attempted.
-
For firewall logs, the parser will recognize the timestamp, source IP address, destination IP address, and accepted/denied result.
-
For antivirus logs, the parser will recognize the timestamp, hostname, and event details such as a failed update or the discovery of malware.
Unfortunately, there are thousands of different log formats. There are a few common event log formats that make parsing a little easier, however. Many tools can parse logs in these formats into specific fields, although that doesn’t always mean the fields are useful. Here are some examples:
-
Syslog is a standard format for log messages, although “format” is a little generous. 2 There are actually a couple of popular syslog formats: RFC 3164 describes a collection of things seen in the wild, and RFC 5424 is more prescriptive. Typically, a syslog record will contain a timestamp, the name of the system generating the message, the type of process sending the message, a severity level, and a mostly free-form message. It’s often up to the parser to figure out what generated the free-form message and perform further parsing on it.
-
The Common Log Format (CLF) and Extended Log Format (ELF) are primarily used by web servers to log requests.
-
The Common Event Format (CEF) is an extension of the syslog format, primarily used by MicroFocus ArcSight, that provides additional structured fields.
-
The Cloud Auditing Data Federation (CADF) standard is intended to allow switching between cloud providers without changing the log aggregation and parsing systems.
Searching and Correlation
Once the logs are aggregated and parsed, you can search based on the parsed fields and correlate events between different systems. For example, you can search for all login failures during a certain time period, all cases where a successful login happened without a VPN connection for the same user, or malware detection followed by a login.
The ability to perform quick searches across multiple different log sources and types of logs can be invaluable during incident response. Test the ability of the system to quickly handle multiple searches by many frantic people before you’re in the middle of a security incident!
Note
Many systems have the idea of hot and cold storage. Hot storage can be queried instantly, whereas cold storage may need to be retrieved and reloaded before it can be searched.
Alerting and Automated Response
When an automated system sees something a human should look at, it raises an alert (occasionally called an “offense”), and in some cases may automatically respond by disabling access to or shutting down a component. Alerts may be based on certain events, on correlations of events happening, or on certain thresholds being reached.
This is really where the art lies in log analysis. If the system is tuned so sensitively that your security team is constantly getting false alerts, all of the alerts will quickly be ignored. On the other hand, if you’re not getting at least some alerts regularly, you’re probably not following up on some things that you should be. You need a feedback loop for each type of false alert to determine whether it makes sense to filter out those types of events, raise thresholds, or take other actions to reduce the false alerts. Consider running periodic tests that you know will generate alerts, to ensure that they’re not ignored.
There are some alerts that you should almost always follow up on. Multiple login failures for privileged users, malware found on systems, and other alerts that may be precursors of a security incident should at least get a look, even if they’re usually false alarms.
Don’t forget that you also need to have alerts when logs stop flowing. That’s a security issue too! In many cases, it just means something is malfunctioning, which might prevent you from seeing a future problem. In some cases, however, it might actually be an indicator of an attack in progress.
Automated response sounds great in principle, but it really has the potential to disrupt your business. In addition to outages caused by an incorrect response or an automated overreaction, automated response systems can be deliberately leveraged by attackers to cause outages. It’s not fun to realize that you’ve spent a considerable amount of money to prevent denial-of-service attacks, only to unintentionally enable an attacker to conduct an easy denial-of-service attack using a simple port scanner or a few failed logins. Some environments have high enough security requirements that you’re willing to suffer an outage rather than accept even a small risk of letting a possible attack continue until a human can investigate, but in most cases the operational and security risks have to be balanced carefully.
Alerting shouldn’t be a fire-and-forget activity. You often need a way to rotate different individuals in and out, because nobody wants to be on call all the time, and you need some way to ensure that an alert is acknowledged within a certain amount of time or escalated to someone else to handle. There are cloud-based services for everything, and alerting is no exception. In most cases, the same system can be used for both operational response and security response activities.
Larger organizations will usually either build a system or contract with a managed security service provider (MSSP) for a 24×7 security operations center (SOC) to monitor and respond to alerts. A room with lots of screens displaying important-looking graphics is optional, but looks impressive to your C-suite management and customers and can help present important information quickly in an urgent situation. In many cases, organizations use a hybrid model where some of the lower-level monitoring and alerting is performed by an MSSP, and the more important alerts are escalated to in-house staff.
Modern systems can produce billions of log events. You can use even more automation to help deal with them—and this is where a SIEM can come in handy.
Security Information and Event Managers
A security information and event manager (SIEM) can perform some or all of the steps described in the previous sections. For example, you may have your SIEM aggregate logs, or you may instead have a separate system aggregate and filter logs and feed only a subset of them to the SIEM. Because many cloud providers have lower-cost, high-volume log aggregation services, and because logs are often used for operational troubleshooting in addition to security incident detection and response, many organizations have a cloud log aggregator feed security-relevant events into the SIEM.
SIEM rules can be used to detect potential bad behavior, sometimes by correlating events that happened in two different places or by comparing current and historical data. Here are some questions that might be raised by a security operator viewing alerts from a properly configured SIEM:
-
“Database traffic is up 200% from the monthly average. Maybe the application is just really popular right now, but is someone systematically stealing our data?”
-
“We just saw an outbound connection to an IP address that has been used by a known threat actor recently, according to this threat intelligence feed. Is that a compromised system talking to a command-and-control server?”
-
“There were 150 failed login attempts on an account, followed by a success. Is that a successful brute-force attack?”
-
“We saw a single failed login attempt on 300 different accounts, followed by a success on account #301. Is that a successful password spraying attack?”
-
“A port scan was followed by a lot of traffic from a port that hasn’t been used in months. Port scans happen all the time, but perhaps a vulnerable service was found and compromised?”
-
“John doesn’t normally log in at 3:00 AM EST, or from that country. Maybe that’s not really John?”
-
“Three different accounts logged in from the same system over the course of 30 minutes. It seems unlikely all of those people are actually using that system, so maybe the system and those accounts are compromised?”
-
“A new administrative account was just created outside of normal business hours. Maybe someone’s working late, but maybe there’s an issue?”
-
“Someone was just added to the administrator group. That’s a rare event, so shouldn’t we check on it?”
-
“Why are there firewall denies with an internal system as the source? Either something is misconfigured or there’s an unauthorized user trying to move around the network.”
A SIEM can be run in-house, as a cloud service, or as part of a managed security services engagement. Many cloud infrastructure and platform providers have built-in services that provide at least some SIEM functions, and there are also many third-party solutions. Regardless of whether you choose to use a SIEM or not, make sure that you are meeting your requirements for aggregation and retention, parsing, searching and correlation, alerting, and automated response capabilities.
To SIEM or Not to SIEM
Do you need a security information and event manager? Smaller organizations may be able to make do with a log aggregation facility that generates simple alerts, or that security personnel can dig through to find threats. However, there’s a reason these dedicated SIEM products and services exist. The logic and rules required to pull relevant data out of a lot of different log formats, correlate logs from different sources, know what common attacks look like, and get a threat intelligence feed on current attacks around the world can be very complicated. All of this work is difficult to reproduce internally, so many larger environments either run a SIEM product or service, or hire a managed security service to run one for them and assist with response.
Threat Hunting
Only after you have the basics down—that is, you’re collecting security-relevant logs and metrics, parsing them, and responding to alerts generated by your systems—should you move on to threat hunting.
Threat hunting is one of the few cases where it’s okay to go “looking for trouble,” rather than reacting to specific alerts. You start by creating a hypothesis , such as “Perhaps I’m being targeted by Advanced Persistent Threat 12345” or “Maybe someone is after the secret plans to my spaceship.” You then query the data you have collected, and collect new data if needed, to gather evidence to either prove or disprove that hypothesis.
Preparing for an Incident
You have the logs, and you are doing useful things with them, such as getting alerts. Now you need to plan for what to do when one of those alerts is the real deal. Depending on the risk to your environment, your plans don’t have to be exhaustive, because even a little bit of planning can help enormously.
The first decision that you need to make is this: at what point are you going to call for outside help? This will depend heavily upon the perceived risk to your organization, the severity of the incident, and the size of your security team. However, even large, well-prepared organizations may need outside help for more serious security incidents. A quick search will turn up many incident response firms, and it’s a good idea to have vetted a couple of them ahead of time in case you need them.
In addition, you may want to consider cybersecurity insurance, particularly if you have a small team and little incident response can be done in-house. In some cases, this insurance may be included with general business protection policies, although many exclude cybersecurity incidents. As with any insurance, you need to carefully read the coverage and exclusions, as some policies exclude common types of attacks such as social engineering attacks, or deny coverage based on unclear security requirements for the insured. However, these policies can pay for most or all expenses associated with incident response.
The most important preparation work is the collection and retention of logs, described earlier, so that you can call up a reasonable amount of current and historical data to perform investigations. In addition to that, you need to put together a team, a plan, and some tools.
Team
The incident response team 3 has the stressful job of figuring out what’s going on during an attack and containing the incident as much as possible. The first thing you need to do is identify primary and backup technical incident response leaders, because response activities cannot wait for someone to return from vacation. These people will be responsible for running any internal investigations and coordinating with any outside help.
You also need to identify primary and backup business leaders who can be available immediately to sign off on business decisions such as taking systems down or authorizing payments. In smaller organizations, the technical leaders and business leaders might be the same people, but you still need at least one primary and one backup person.
In addition to the team leadership, you will also need technical specialists in the different areas that are most likely to be attacked in your threat model. For example, if you are worried about someone taking data on your customers from your cloud web application, you might need to line up network specialists, web server specialists, database specialists, and specialists familiar with the inner design and workings of the application itself. You don’t want to realize in the middle of an incident that you can’t reach any of the people who understand a component where the problem is suspected.
Finally, you also need these primary and backup contacts:
-
Your legal department (or someone from your legal firm), to help with questions about complying with contracts and regulations
-
Your communications department, or someone authorized to speak with the media and to speak to law enforcement authorities should that be necessary
-
Your HR department, or someone authorized to make hiring/firing decisions in case an insider threat is identified
All of these responsibilities may fall to different individuals, or these tasks may be performed by the leaders identified earlier in this section, provided that you have primary and backup coverage for each area.
Whether you have a full-time incident response team or not, you should also have the equivalent of a volunteer fire department. Identify knowledgeable people who can be trained in incident response, and get management preapproval to pull them off of what they’re currently doing to deal with a high-priority incident.
A few other notes on creating and maintaining an incident response team follow:
-
Nobody wants to be on call during a weekend or over a holiday. Unfortunately, attackers know this, so incidents are more likely to begin at these inconvenient times.
-
If incident response is a regular activity in your organization, burnout is a serious concern. It is even more of a concern if you have a largely volunteer team that is attempting to deal with incident response on top of a normal workload. If possible, rotate people in and out so that they have a break from incident response activities.
-
Determine general incident response roles for team members ahead of time and write them down so that during the incident, nobody is confused over who is responsible for what.
-
Have the team meet at least quarterly to make sure everyone is still on board with the plans.
Once you have an incident response team, you need some plans for the team to follow.
Plans
Most of the team composition advice in the previous section is not cloud-specific, but your incident response plans will be. You need to come up with some likely scenarios in your cloud environment and have some plans to cover those scenarios.
As part of your planning, you need to understand what your cloud provider is committed to doing in the event of a security incident. Will they provide additional logs or take forensic images? Do they provide contact information for security incidents? You don’t want to be in the middle of an incident trying to read the terms of service to figure out your provider’s responsibility.
In many cases, the cloud provider will be responsible for responding to incidents involving breaches to its cloud services, but not to incidents that only involve your application. However, there are some exceptions, such as DDoS attacks, where the cloud provider may work with you to help mitigate the attack—or may turn off all outside network access to your application to prevent the attack from impacting its other customers! It’s important to know what your provider can do for you ahead of time.
You also need at least a small, preapproved budget for dealing with security incidents. This doesn’t mean the team has a blank check to purchase anything they want, but the allocation should be enough to cover reasonable items without going through a potentially lengthy procurement and approval process. For example, if part of the incident response plan is to contact an incident response firm, at least initial consulting charges should be preapproved. If part of the plan is to put people on planes right away, airfare should be preapproved. Try to budget for and preapprove items that are likely to be needed in the first few hours of an incident.
Prioritization is also an important part of incident response planning. You don’t want to respond to an attempted attack in the same way that you respond to someone actively stealing your data. Create at least a few severity levels for security incidents, with some guidelines on what to do in each case. For example, you might list categories for “confirmed unsuccessful attack,” “confirmed successful attack without data loss,” and “confirmed successful attack with data loss.” As incidents move up the scale, the response might change.
You should also have some organization-wide guidance for reporting suspected security incidents and not interfering with investigations. This can be as simple as an item in the employee handbook that says something like, “If you suspect that an unauthorized user is accessing our information systems, please call the following number to report a suspected security incident. You are permitted to shut down affected nonessential systems, but do not delete any systems or destroy any data, and do not attempt to retaliate.”
If you haven’t had a chance to test your incident response plans yet, consider performing a tabletop exercise. You can do this in-house, by inventing a plausible scenario and playing it out in a test environment. There are also firms that make this easier by providing scenarios, fake news bulletins, and other props, and that will critique how the plan was executed to help address weaknesses. For example, a likely scenario might be that there’s an attack in progress and you need to go into lockdown mode. In a cloud environment, this might involve one or more of the following:
-
A plan to disable all cloud portal and API access other than the minimum required during the incident. For example, you could decide that only four individuals need access in the short term and run scripts to disable all other users’ access.
-
A plan to disable all network access to your cloud environment, or some subset of it. This might disable the application completely, or temporarily disable some functionality.
-
A plan to shut down the entire environment, lock the secrets server, and re-create a new environment.
Warning
Part of your incident response plan should involve having backups that you can use to restore data and functionality. Make sure your backups are in a separate cloud account, with separate administrative credentials from the production data. There have been documented cases of attackers wiping not only the production data, but also all of the backups that were accessible from the production account.
It’s important to understand how long restores will take, too. Sometimes you have a perfectly reasonable recovery strategy, except that it requires the entire world to stop turning for a week. You don’t have to be able to function at 100% while recovery is taking place—delaying sending out bills or jotting down handwritten notes for entry into the IT systems later may be perfectly reasonable—but you do need to be able to carry out core business functions.
Tools
When developing your incident response plans, you’ll realize that your team will need some tools to implement those plans. In a traditional environment, many incident response tools tend to be physical bags carrying laptops, cables, and similar materials (the “jump bags” mentioned earlier). A cloud environment offers virtual cloud equivalents of some of these items.
The tools needed will depend somewhat upon what your environment looks like and what your cloud provider offers, but at a minimum your team should probably have virtual images containing forensic analysis tools and a cloud account to create forensic infrastructure. Cloud accounts typically don’t cost anything to own if nothing is provisioned in them, so you should keep a separate incident response cloud account active that can be connected to your production account. Some cloud providers also offer documentation on performing investigations and digital forensics in their environments that may point to specific tools.
Create detailed, tested procedures for the most common incident response tasks. For example, you may want a procedure for collecting memory and disk forensic information from a compromised Linux virtual machine in a cloud environment. Such a procedure should contain the exact commands to accomplish this, such as running LiME to capture a memory dump, generating a hash of the dump, verifying the dump with Volatility, performing a hard power-off of the compromised machine to prevent any malicious programs from cleaning up prior to reboot, and taking a snapshot of the disks.
Here are some other tools that may be helpful:
-
Cloud-aware forensic analysis tools, such as Cloud Forensic Utils , which can help you understand what happened in a cloud environment during a security incident.
-
Up-to-date diagrams showing network configuration, data locations, and event logging locations.
-
Tested communications systems. Will you be able to respond to a threat if your instant messaging platform, email, or telephone systems are down? In an emergency, perhaps you will permit people to use personal email and cell phones for work activities, even if that’s normally disallowed. It’s better to think about those decisions ahead of time.
-
Contact lists, for both people internal to the organization and external contacts such as cloud providers, incident response firms, or other suppliers that may be involved in incident response.
-
A war room. In cloud environments, you won’t be physically touching the equipment in most cases, but you still need a physical or virtual war room where the team can meet, exchange information, and make decisions. If you may have remote attendees, make sure you have meaningful ways for them to participate, such as screen sharing and a reasonable audio system.
-
Checklists. I’m not a fan of “checklist security” at all, where you tick off that you have a firewall, antivirus software, and similar items without actually verifying that they’re being used effectively. However, incident response can be exhausting and very stressful. In these situations, checklists that help you implement plans are essential to ensure you haven’t forgotten something really important. For example, one online checklist suggests a useful set of logs to review during an incident.
-
Forms for documenting incident response activities. For example, the SANS Institute offers some forms that can be customized for your organization.
-
Incident response software, which has components that can track incidents and built-in playbooks for incident response .
Responding to an Incident
Hopefully, you’re not in the middle of an active security incident when you read this. If you are, and you have no incident response team, plan, tools, or checklists yet, your first priority should be containing the incident as much as possible without destroying evidence. Typically, you do this by some combination of shutting down or quarantining systems, changing passwords, revoking access, and blocking network connections. At the same time, you should probably call an incident response company for help, and take a few seconds here and there to jot down notes on what you need in order to be better prepared next time.
OK, so you’ve found something that looks like a real attack. Now what? Your response will largely be dependent upon what the attacker is doing and what your threat model looks like, but there are a few guidelines that will help.
First, mobilize at least part of your incident response team to do triage. You don’t want to get 30 people out of bed for a malware infection that, after a few minutes’ investigation, appears to be completely contained. It’s easy to both overreact and underreact, so this is where having some predefined severity levels and response guidelines for each level can be helpful.
Then, start executing the plans you’ve implemented, trying to anticipate what the attacker’s objectives are likely to be based on a kill chain or on an attack chain.
Cyber Kill Chains and MITRE ATT&CK
As mentioned in the sidebar at the beginning of this chapter, one of the most popular kill chains today is the Lockheed Martin Cyber Kill Chain. According to this model, threats pass through the following phases:
Reconnaissance
The attacker does research to figure out what to get into and identify vulnerabilities that may help them. This might involve anything from Google searches to dumpster diving to social engineering to network port scans.
Weaponization
The attacker comes up with some malware to exploit the vulnerabilities. More advanced attackers may write something custom, but less advanced attacks may use something already available.
Delivery
The attacker gets the victim to execute that malware, either by a network attack, by emailing it, or by some other means.
Exploitation
The malware runs and gains unauthorized access.
Installation
The malware gains persistence, or staying power, by installing itself in some way that the attacker hopes makes it difficult to find and remove. Often the first piece of malware downloads and installs a second piece for this part. In some cases this persistent malware is better supported and updated than your legitimate programs!
Command and control
The malware creates some sort of communication channel so that the attacker can remotely control it—a remote shell, an outbound web connection, or even reading commands from a legitimate cloud file storage service. At this point, access to your systems might be sold on the black market at a good price to someone who really wants it.
Actions on objective
An attacker (who may not even be the original attacker) does whatever they want—steals your data, defaces your website, attacks your customers, extorts money, etc.
Other popular resources, such as MITRE ATT&CK, view attacker actions as falling into distinct tactics used to accomplish their goals:
Initial access
The attacker gains initial access, often through stolen credentials or exploiting an unpatched vulnerability.
Execution
The attacker runs malicious code on your systems.
Persistence
The attacker installs code or similar functionality to allow access in the future.
Privilege escalation
The attacker uses existing access to get more access.
Defense evasion
The attacker hides from the defenders.
Credential access
The attacker uses techniques to gain passwords or API keys.
Discovery
The attacker pokes around, looking for vulnerabilities or paths to the objective.
Lateral movement
The attacker moves from one part of the environment to another.
Collection
The attacker finds information in your environment.
Exfiltration
The attacker steals data from your environment.
Impact
The attacker does damage to your systems.
The MITRE ATT&CK tactics tend to be both less linear and more detailed than the Lockheed Martin Cyber Kill Chain phases, and the framework lists specific techniques that may be used to accomplish those tactical goals. Regardless of which you use, it’s a good idea to be familiar with at least one of them so you have some idea of what the attacker might have already done and might do next.
The OODA Loop
You have your plans, and you may have some idea of the progress and objectives of your attacker. It’s time to respond. A popular concept in incident response is the OODA loop —observe, orient, decide, and act:
-
In the observe phase, gather information from your systems, such as your cloud provider logs, firewalls, operating system logs, metrics, and other locations, to find odd behavior that may indicate an attacker is doing something.
-
In the orient phase, try to understand what is going on and what might happen next. This might involve both internal knowledge of where your most important assets are and external threat intelligence about who may be behind the attack and why. Not all threat intelligence costs money. For example, the US Cybersecurity and Infrastructure Security Agency (CISA) regularly releases alerts on malicious activities. If you’re seeing suspicious behavior and CISA has released an alert indicating that your industry is being targeted by particular threat actors using particular tactics, techniques, and procedures, that may help you orient yourself.
-
In the decide phase, choose the next tactics you’ll use for minimizing damage or enabling recovery. For example, you may decide to take certain systems offline, revoke access, quarantine systems, or build a new environment.
-
In the act phase, actually execute those tactics. This is where using cloud infrastructure can really be helpful, particularly if you have invested in repeatable methods to build your cloud environments rather than having them grow organically over time. Here are some examples:
-
Most cloud environments have a stronger division between the compute infrastructure and storage than traditional environments. It’s much harder—but not impossible—for attackers to persist (retain unauthorized access) just by modifying content in your data stores. Every instance of compute infrastructure contains thousands of executables and configuration entries, but these can typically be rebuilt much more easily than the data can. Given this division, you may be able to apply fixes to your images to close the vulnerability that allowed the attacker in, shut down all compute instances, replace them with fixed instances, and connect the new instances to your data stores with minimal downtime.
-
You may also be able to easily quarantine systems, using scripts to invoke APIs that lock down security groups or network ACLs. In a traditional environment, you might have to manually log in to many different routers or firewalls, or start unplugging cables, to get the same effect.
-
After you act, the loop begins again—observe to see what the attacker is doing in response to what you’ve done, orient, decide, and act again. These loops should be relatively quick and should continue until your observations indicate that the incident is resolved.
You will almost never be prepared enough. Each incident will be messy in its own way, even if you’re really well prepared. Take 15 seconds to jot down reminders of lessons learned while you’re going along, because it can be difficult to remember afterward.
Note
Don’t be afraid to call an incident response firm if things seem to be getting out of hand or if you can’t make progress. Most attackers have a lot more experience attacking than defenders have defending!
Cloud Forensics
Cloud forensics might inspire images of the CSI television show, but unfortunately the reality is a little less exciting. Essentially, you just want to make a forensic copy of anything that might be important, and then use tools to analyze it.
It’s important to make the copies in a documented, repeatable fashion so that you can always demonstrate that you have a good copy of the original data that hasn’t been altered. This usually involves generating a verification string (cryptographic hash) that can be used to show that you have a copy of the uncorrupted data. A cryptographic hash, such as SHA-256, is designed to be fast to calculate but nearly impossible to use to create another piece of data that has the same hash. With a copy of the data and a cryptographic hash, anyone can quickly generate a hash and compare it against the original to ensure that their copy is the same as what the initial investigator collected. In addition, nobody can change the data (intentionally or accidentally) without the change being easily discoverable. You could also write the original copy to some read-only media and do a bit-for-bit comparison of the copies every time, but that would take a lot longer!
The sample procedure in “Tools” showed one way to obtain forensic images for virtual machine memory and disk images, but you may need other forensic artifacts during an investigation. For example, you may want to take snapshots or backups of databases, to compare to see whether the attacker made any database changes. You may also want to look at network packet or flow captures to see what an attacker or malware was doing on the network.
Blocking Unauthorized Access
This may seem like a no-brainer, but it’s often harder than it looks, particularly if an attacker has been in the system for a while and has gotten administrative access. Hopefully you’ve followed the instructions in Chapter 6 and have some internal segmentation so that the attack may be contained to a particular part of the network.
A common response here is to reset everyone’s passwords and API keys (including automation), which can be disruptive to normal operations, as well as blocking inbound and outbound network access.
You should have pre-created tools and processes for blocking access quickly and all at once.
Stopping Data Exfiltration and Command and Control
If you didn’t shut down network communications as part of blocking unauthorized access, you may still need to shut down outbound communications in order to stop connections attackers make to command-and-control servers, or to stop ongoing data loss.
Recovery
You’ve found the attack and you think you’ve stopped it, so now it’s time to clean up and make sure that there are no leftover ways for the attackers to get back into your systems.
Redeploying IT Systems
By far, the simplest and most effective way to recover from an IT standpoint is to redeploy all affected systems. Again, this is a little easier in the cloud, because you don’t have to purchase new physical hardware; your cloud provider will have capacity. Any compromised cloud systems should be re-created, and the production traffic should be switched over to the new systems. Any affected workstations should be wiped and re-created from known good images. In the immortal words of Ellen Ripley in Alien , “Nuke the entire site from orbit. It’s the only way to be sure.”
If that’s not possible, you need to have executive acknowledgment that you’re accepting a substantial risk in continuing to operate systems that an attacker had control of for a time. You can run malware scanners, keep extra tabs on the network and processes for indicators of compromise, and enact some other security measures, but a single altered registry entry may be enough to let an attacker get back into your system, and a single piece of missed malware may be able to call out and provide an easy way back in.
Notifications
You may have regulatory or contractual obligations to notify your customers or report the breach to law enforcement authorities.
Even if you aren’t required to notify the world, you may want to do so anyway to avoid a PR nightmare if word eventually gets out. For obvious reasons, we don’t have good metrics on how many successful cover-ups there are, but there are some well-known examples of unsuccessful cover-ups by Yahoo!, Cathay Pacific, Uber, and others.
Lessons Learned
As soon as possible, after everyone’s had a good night of sleep, you should look at lessons learned and make any updates to your team composition, plans, procedures, tools, and checklists that will help next time. Hopefully, during the incident you took the opportunity to jot down some quick notes and reminders that can be used.
Building an entire incident response team and process is a large topic. While I’ve covered the high points for cloud environments here, for further reading I recommend AT&T’s Insider’s Guide to Incident Response and NIST SP 800-61 .
Example Metrics
As with other business processes, if you can’t provide some measurements on your detection, response, and recovery activities, it’s difficult to know whether you’re improving.
Here are a few example metrics that you may want to consider collecting:
Detection
Number of events collected per month, number of alerts triggered per month, percentage of alerts that are confirmed incidents, percentage of alerts that are false positives
Response
Time from when an alert was triggered to a review of the alert, time from a confirmed incident to closure of that incident
Recovery
Time required to redeploy affected systems
Overall
Estimated cost of each incident, including time, expenses, and damage to reputation
Example Tools for Detection, Response, and Recovery
The following is a listing of some representative solutions in the cloud detection, response, and recovery space. Just as in Chapter 5 , I’m not endorsing any of these tools by including them, or snubbing other tools by excluding them. These are just examples of different tools that are popular as of this writing:
-
Amazon GuardDuty can look for unusual or suspicious activity in your AWS account or systems.
-
Amazon CloudWatch Logs, Azure Monitor, Google Cloud’s operations suite logging, and IBM Log Analysis all allow you to store and search through your logs.
-
Amazon CloudWatch, Azure Monitor, Google Cloud’s operations suite, and IBM Cloud Monitoring provide performance metrics.
-
AWS CloudTrail, Azure Monitor, and IBM Cloud Activity Tracker can monitor privileged user activity in cloud accounts.
-
Azure Security Center can collect security data into a central location, as well as performing file integrity monitoring and other security functions.
-
Cisco, McAfee, and Snort are popular network intrusion detection service providers that have cloud-based appliances available.
-
Cloudflare, Akamai, and Signal Sciences provide cloud-based web application firewall solutions.
-
OSSEC, Tripwire, AIDE, Netwrix Change Tracker, Fidelis CloudPassage Halo, Qualys, and many other products and services provide traditional or cloud-based file integrity monitoring solutions.
-
CyberArk and Delinea are typically considered privileged identity management or privileged access management solutions, and can perform session recording and alert when privileged credentials are checked out.
-
IBM QRadar, ArcSight Enterprise Security Manager, Splunk Enterprise Security, LogRhythm, and other SIEM providers collect log events, analyze them, and raise alerts.
-
EnCase, FTK, Sleuth Kit and Autopsy, and Cloud Forensics Utils are forensic tools that have cloud capabilities.
Detection and Response in a Sample Application
Let’s take one last look at our sample application, this time from the point of view of detection and response. Our threat model in this case involves large amounts of data about our customers in our database, and a likely attacker who will attempt to steal this data and sell it on the dark web. Note that our focus would be somewhat different if we were primarily concerned about our brand image, and we thought it was most likely that someone would try to deface our web pages to make us look bad.
Figure 7-2 shows sensitive systems that log security-related events, and how the security team handles them. The blue items (white text on a dark gray background if you’re seeing this in black and white) run the functional parts of the application, the orange items (dashed borders) are cloud provider or orchestration systems used to create the application infrastructure, and the green items (black text on a light gray background) run our auditing framework. As a reminder, these are our detection and response security goals for the application:
-
Collect logs and metrics that will be useful both for operational troubleshooting and for detecting and responding to security incidents. The IDS/IPS, WAF, firewall, servers, database, and consoles/APIs are all configured to record security-relevant events and metrics.
-
Store those logs and metrics securely, where they can’t be erased by an attacker. In practice, this means getting them off of the system quickly, to a system that’s under separate administrative control. In this case, the logs are shown as going through log and metrics aggregator systems, which are under separate administrative control, but they might also go directly to a SIEM.
-
Analyze the collected data. This will let us see whether items require further investigation. In this case, the analysis is performed by a combination of the SIEM (using log parsing, correlation rules, machine learning, and other features mentioned in most SIEM marketing brochures) and the security operator’s brain.
-
Automatically alert on items that require a human to investigate. In this example, the SIEM is configured to send alerts to people with the security operator role. These alerts might be false positives—there should be a separate feedback loop (not pictured in the diagram) for the security operators to tune out false positives where possible when they get a false alert, without masking any true positives.
-
Run through the incident response and recovery plans if an actual security incident is suspected.
Figure 7-2. Sample application with detection capabilities
Monitoring the Protective Systems
First, let’s look at the logs created by our protective systems during normal use of the system. In this picture, the IDS/IPS, WAF, and firewall systems generate logs, alerts, and metrics as the system is used or abused. Here are some examples:
-
The IDS/IPS may log that someone appears to be port scanning or when it sees a known malicious signature.
-
The WAF may log that someone is attempting a SQL injection attack or a deserialization attack.
-
The firewall (or a component of the IaaS performing firewall duties) routinely logs accepted/denied connections, as well as tracking metrics indicating how much data is entering and leaving the network per minute.
Monitoring the Application
Next, let’s look at the logs created by our application and infrastructure during normal use of the system. These logs will depend highly on what the application does and what components are used to create it. For illustrative purposes, I’ll assume we’ve used many different technologies, although this may or may not be a good design for a real application. Here are some examples:
-
The web servers will log each request, including the source IP address and the URL requested. In this case, the web servers are simply object storage instances presenting objects in response to web requests. We configure the object storage service to send its access logs (including when an object is modified) to the log aggregation service and to send metrics on how many requests are serviced to the metrics service. With an object storage service, we don’t need to worry about any lower-level items such as operating system logs, because that’s the cloud provider’s job.
-
The application servers in this example are pods hosted on a Kubernetes cluster. The application running in the pods logs each request to standard output (stdout) or standard error (stderr), with the URL of the component being invoked and what the response is. In this case, the application also allows file uploads, so one component of the application is an antivirus client that scans each upload, quarantines any uploads that contain malware, and sends an alert. A logging agent on the worker node will send the log information from each pod, as well as for the worker node itself, to the log aggregator. We’ll also enable audit logging on the Kubernetes master itself so that it will tell us when someone authenticates to it or creates pods.
-
The database is an as-a-service offering that will log any denied access attempts to the database or particular tables within the database, as well as any changes to the access settings for the database. It will also record metrics about how much data it’s sending out at any given time. Given that we’re most concerned about the theft of data from the database, we really need to pay attention to these items!
-
The virtual private cloud networking infrastructure (not shown in Figure 7-2 ) is configured to send network metrics to the metrics aggregator, which can send an alert to the SIEM when network usage is high.
Monitoring the Administrators
We also need to monitor the administrators as they work. As I said before, this doesn’t necessarily mean that we don’t trust our system administrators! It means that we recognize that an attacker might have obtained valid administrative credentials via some nefarious means, and we have to detect and respond to any such attack.
For educational purposes, we’ll assume the following:
-
The admins are dealing with a combination of virtual machines and containers in this environment.
-
The admins will use the cloud provider and container orchestration capabilities to run specific commands on VMs and containers where possible, but in emergencies may need to open an interactive session directly on the system.
-
The admins go through a session recording service in order to reach the virtual machines.
In Figure 7-2 , toxic session recording logs (which may contain secret information) and the normal sanitized logs are shown stored on separate systems. This is so that we can limit access to the toxic logs to as few administrators as possible. If you store both types of logs on the same system, ensure that all administrators of that system are authorized to see the toxic logs and that access to them is controlled carefully.
Understanding the Auditing Infrastructure
Now let’s look at our auditing infrastructure. In this example application, the log aggregator, metrics aggregator, and SIEM are all shown as separate systems, but many products and services overlap in some or even all of these areas.
You may also have additional products or services sending alerts to the SIEM or directly to security personnel. For example, you may use a network traffic analysis system that watches for unusual network traffic patterns, or endpoint detection and response agents that collect information on what your servers or workstations are doing.
Let’s take a closer look at these systems:
-
The log aggregator may either be a cloud service (like Amazon CloudWatch Logs, Azure Monitor, Google Cloud’s operations suite, IBM Log Analysis, or Splunk Cloud) or a separate installed product like Splunk or Logstash.
The log aggregator should be under separate administrative control from the systems being monitored so that an attacker with access to one of the monitored systems can’t also access the aggregator and erase the logs using the same credentials. I recommend putting the audit and logging components in a separate auditing cloud account for increased separation.
The logs might contain both non-security-relevant information and security-relevant information, but in general only security-relevant logs should flow to the SIEM.
-
The metrics aggregator may be a cloud service such as Amazon CloudWatch, Azure Monitor, Google Cloud’s operations suite, or IBM Cloud Monitoring, or a separately installed tool.
-
Both the log and metrics aggregators feed security-relevant items into the SIEM. For example, the log aggregator might feed in all authentication events, and the metric aggregator might push an event any time a metric such as the transfer rate exceeds a threshold for a specific amount of time.
-
The SIEM has parsers to understand the different types of logs coming in, and it has rules to decide when something is worth telling a human about. In this case, the SIEM rules may alert when there are login failures for multiple accounts in quick succession (password spraying), or when the database and network metrics both show unusual activity, or when many other combinations of suspicious or alarming events happen.
In this sample application, we’re now looking at anything our protective tools are flagging as an issue, monitoring for unusual traffic or activity in the application components, watching what our administrators (or attackers impersonating our administrators) are doing, and collecting evidence for forensic analysis and audits. With these tools and processes in place, we now have a good chance of detecting an attack.
Conclusion
Even after you have put reasonable protections in place, your security isn’t complete until you have confidence that you can detect attacks, respond to them promptly and effectively, and recover.
Detection isn’t just about logging; you can’t just vacuum up every log source available and hope that it’s useful for security. You need to figure out what is important to watch given your environment and your threat model. In almost all environments, you will have some privileged users, and it’s almost always important to watch their activity. Ask yourself, “If some likely bad thing happened, would I see it?” If not, you may need to collect additional information, or make sure the information you’re already collecting gets to the right place to be visible. One excellent indication that your detection abilities need to improve is if you perform a pentest and you don’t detect the pentesters attacking your systems.
Once you have figured out what it’s important to watch, make sure that you’re effectively collecting those logs and metrics and looking through them. In larger environments, that often means using a SIEM to help go through the large amounts of data. Make sure you have synced your time across systems, and perform some simulated attacks to make sure that you would notice the real thing.
Finally, you need to be prepared to deal with a successful attack when it happens. That means putting together a team, some plans, and some tools ahead of time. When an attack happens, your team needs to understand how attacks often unfold and how to lock down the environment and clean up—and when it’s time to call for additional help.
When you’re performing recovery actions, it’s very risky to attempt to clean your systems. Once someone has obtained administrative access, you really have no way of knowing you’ve gotten everything out, because there are so many places for malware to hide. The safest option by far is to wipe and restore each compromised system, or delete it and provision a new one. Fortunately, that’s easy to do in the cloud! Don’t underestimate the risk of trying to clean up in-place; a single access control permission, a single registry entry on Windows, or some other hard-to-find backdoor can allow an attacker to walk right back in easily.
Cloud computing is a wonderful, innovative model that has enabled lots of people with great ideas to get started quickly and scale up with very little capital investment. We started this book by exploring some security concepts, and from there worked through ways to protect data and assets in the cloud and how to implement controls such as good access management, vulnerability management, and network controls. Finally, we finished by examining ways to detect security issues and respond to them effectively.
This is an incredibly deep and fast-moving field. My goal was to provide enough useful information, in an accessible form, so that readers can get started and also know the right questions to ask to learn more. I hope you’ve enjoyed reading Practical Cloud Security , and that you’ll find the information here both practical and useful for enhancing the security of your cloud environments. Good luck!
Exercises
-
Which of the following statements about logs, alerts, and metrics are true? Select all that apply.
-
A log is a record of something that happened.
-
An alert is when the system notifies someone that something has happened.
-
Metrics refer to how many logs are generated per unit of time.
-
Most logs contain sensitive information such as personally identifiable information.
-
-
Which of the following types of logs should you monitor? Select all that apply.
-
Logs of privileged user activity
-
Logs from detection and response tools
-
Logs from cloud services
-
Logs from operating systems
-
-
True or false: You must use the same tool for log aggregation and analysis.
-
What are some functions usually provided by a security information and event manager (SIEM)? Select all that apply.
-
Parsing logs
-
Correlating events between different systems
-
Alerting humans when an event reaches a particular threshold
-
Automatic cleanup of affected systems
-
-
According to the MITRE ATT&CK framework and the Lockheed Martin Cyber Kill Chain, what are some common attacker actions? Select all that apply.
-
Installation of malware, or persistence
-
Exploitation, or execution of code to make use of a vulnerability
-
Actions on objectives, or impact to the affected organization
-
-
What are some steps you can take to recover from an attack after it’s over? Select all that apply.
-
Run antivirus software to clean up systems that have been controlled by attackers.
-
Provide any notifications required by contractual obligations or regulations.
-
Review lessons learned.
-
1 This is sometimes also called the “four eyes principle,” the “two-person rule,” or the “two-man rule.”
2 The term “syslog” can be confusing because it is often used to refer to a program to accept syslog messages, a network protocol (usually running over udp/514 or tcp/514), and a format for lines in a log file.
3 In many organizations, this is called the Computer Security Incident Response Team (CSIRT), to distinguish it from other incident response teams.