Hi everyone, today we're going to talk about purple teaming and adversary emulation in the cloud. We're also going to present an open source tool that I'm the maintainer of called Stratus Red Team. My name is Christophe Tafani de Roper. I work at Datadog and this is my handle on Twitter. If you want to send me a message, feel free to do so. We have a lot of positions open, so if you want to apply, have a look. I think we have over 35 right now across security, operations, supply chain security, product security, etc. Today we're going to start by talking a bit about detection engineering, purple teaming, and how they relate together. We're going to see some pain points of doing purple teaming in the cloud. We're going to introduce Stratus Red Team, an open source project that I've been working on, as well as ways to use it more in an advanced way. And finally, I have two exciting announcements to make just for today for the Cloud Village attendees. Let's talk about detection engineering. Detection engineering is basically a fancy word to say how do we detect bad things and how do we maintain these detections as we go. As an industry, we've been moving from detecting indicators of compromise, like IP addresses, hashes, domain names, to detecting things that look more like behaviors and tools. You maybe have seen this this schema before. It's called the pyramid of pain. And basically, the idea is that as you move up to the pyramid, things are harder to change for an attacker. But they are also harder to detect for a defender. Typically, if you look at a file hash, it's very easy for an attacker to change, very easy for a defender to detect. If you move up and you look at the behavior, it's very hard for an attacker to change that, and it's harder for a defender to detect behavior because it's not well defined. If we start to detect behaviors, we need to have a way to model how attackers behave. And that's what, for instance, Mitre ATT&CK is doing. So they try to understand how attackers behave across the different stages of the attack. Now, they also have a version for cloud. I would argue that it's not great for cloud because they try to not be too specific about a single cloud provider. So you really have the common denominator between all the providers. There is one that is more specific, introduced by Microsoft. It's called the Threat Matrix for Kubernetes. And they use the same ATT&CK stages as Mitre ATT&CK, but they go into very much detail on how this works for Kubernetes. Very recently, there's also the Azure Threat Research Matrix that was released. Similarly, you have different ATT&CK stages and some ATT&CK techniques that are very specific to Azure and how they work. Now, a few words about purple teaming, which is a buzzword. So it's really about having, like, starting from having a blue team and a red team, but don't really work together and communicate, to having something like that, because blue and red makes purple. And the idea is really that your blue team and your red team should work together towards a common goal. For this talk, I'd like to define purple teaming as empowering defenders to understand, to reproduce, and to detect common attacker tactics. So we see here that you have the concept of how do I understand things, how do I reproduce them, and how do I detect them. And this is very much aligned to what an American psychologist named Kolb explained in the 1970s. And the idea is that he tried to describe how people learn. And it starts with an active experimentation. Maybe you are going to touch something very hot. Out of that, you get an experience. So your experience is I touched something very hot. Now you have something that is not only theoretical, but you experienced it in the real world. Then based on that, you're going to make an observation. Oh, I touched it, it was very hot, and now I got burned. And based on that, you are going to update your view, your understanding of the world by conceptualizing that. So you're going to say if I touch something very hot, it's likely I'm going to get burned, hence I'm not going to do it again. And it's really the same for detection engineering in the sense that first you want to reproduce a specific attack. You want to get your concrete experience of doing it. You're going to observe what data you have. What kind of logs do you get? What kind of artifacts? What kind of analytics? And then you're going to try to conceptualize a detection based on that. And today we're going to focus on this part of reproducing an attack. And we're going to see that it's not that easy in the cloud. So let's say that we want to detect when VPC flow logs in AWS are removed. This is a popular thing for attackers because if you remove some logs, then a defender cannot know what you were up to. So let's try to reproduce this attack. So first we need to create a VPC and to enable the VPC flow logs to have the prerequisite infrastructure we need to be able to reproduce that. And then we reproduce the attack. We're going to delete the VPC flow logs. So let's go to the AWS console. We are going to create a VPC, give it a name, an IP range. We are going to create a flow log configuration. So AWS asks us where we want to send the logs. Let's say CloudWatch. It's the default. So we are asked for a destination log group, but we don't have any. Then for an IAM role, we don't have an IAM role either. So we are not sure what to do. So we go to the docs. We see, okay, you need to create a role with this specific IAM policy. Fair enough. Then it says, also you need to add a trust policy to your role so that it allows the VPC flow logs delivery service to assume the role to deliver the logs for you. And at this point, you are already even more confused. And basically what happens is that you spend a lot of time trying to set up the right infrastructure you need to reproduce your attacks, sometimes to complain about the documentation, and very little time testing your threat detection. And that's something that we see when we test threat detection for the cloud and that we wanted to make better. So to sum up, the challenges that we found are really the testing prerequisites in the cloud can be very complex. If you want to test a specific attack and you need some prerequisites, it's not straightforward to set them up. The fact also that cloud security is still a pretty new field. And I think we have to acknowledge as an industry that it's an emerging threat landscape. So it's not very clear what are the threats and how they behave and how they evolve. And finally, and it's related, is that we don't have a lot of data available on what cloud incidents happen in the real world. And that's why we built Stratus Red Team. So Stratus Red Team is an open source project that you can find on GitHub. I like to pitch it as Atomic Red Team for the cloud, and we'll see why in a bit. It's written in Go, so it comes as a single prepackaged binary, which comes with a bunch of attack techniques. It currently supports AWS, Azure, and Kubernetes. So the attack techniques in Stratus Red Team, we try to have high quality attack techniques that follow this philosophy. First, that are threat informed. So we want things that we think defenders should care about, and we tell you why. It should be actionable for defenders. So it's not really useful if we tell you this is a threat, but we don't explain how to defend or how to detect it. It should be granular. So typically, we don't try to have a full attack chain. We only have specific attack techniques, like Atomic Red Team. And finally, safe sufficient. So when you run Stratus Red Team, it should work in any AWS account. You shouldn't have any prerequisites, and Stratus Red Team is going to handle all the prerequisites for you. And we'll see that in a bit as well. So to sum up, Stratus Red Team is going to bring two things. First is a catalog of cloud attack techniques. A bit like MyAzure Attack, but much more specific to AWS, to Kubernetes, to Azure. And secondly, a way to easily reproduce these attack techniques against a live environment. So typically, you're going to take Stratus Red Team, you're going to point it at an existing AWS account, or Kubernetes cluster, or Azure subscription, and you're going to detonate the attack techniques against one of these live environments. Currently, we have 27 AWS attack techniques, 7 for Kubernetes, and 3 for Azure, which is a quite recent platform. You have a full list on the website, and you will see that they are organized by Mitre Attack Tactics. So you have persistent, initial access, exfiltration, privileged escalation, etc. Now let's dive a bit into what specifically an attack technique looks like in Stratus Red Team. So if you use VCLI, you can do a Stratus show, and then the name of the attack technique. It will give you a bit of information. Here we are seeing an attack technique that consists in stopping a CloudTrail trail. And you see that we have two things. We have a warm-up phase and a detonation phase. The warm-up phase is when we are going to create the prerequisites. So here we are going to stop a CloudTrail trail from running. So what are the prerequisites? We need first a CloudTrail trail that logs into an S3 bucket with appropriate roles, etc. And then the detonation is really when we're going to reproduce the attack. Here it's going to be simple, just stop the trail from logging. We have the same thing on the website as well, in addition to the mapping to Mitre Attack, the description that we saw before, and a few ideas on how this can be detected. And the idea here is not to give a very precise rule, it's more to give you an idea of what logs you can use to detect the attack, if there are some guarantee findings for it, and things like that. Now the first piece of code that handles the prerequisite infrastructure is based on Terraform. It's going to be totally transparent for you, so you don't have to install Terraform, you don't have to manage it, but this is how it's done under the hood. So this is going to create the S3 bucket and the CloudTrail trail that we need to be able to reproduce the attack. Again, the Terraform instrumentation here is fully transparent, so typically it doesn't mess with your Terraform version, you don't need to install it, and it uses the official Terraform Go wrapper. Again, you don't need to know it, it's just to understand how it works under the hood. And then the second piece of code is going to be the actual attack written as imperative Go code. So here it's very simple, it's going to be my attack is stopping the CloudTrail from logging. I'm just going to use the AWS SDK to stop this trail from logging. In terms of lifecycle, so initially your attack technique is going to be called. It's going to be the initial state. Then once you create the prerequisite, it's going to be warm. And finally, when you detonate the attack, it's going to be detonated. So here again, warming up our attack means creating the S3 bucket, the CloudTrail trail, and at this point we are ready to reproduce the attack. We can do it right away, or we can maybe wait a few hours, a few days if we want, and it's going to be stopping the CloudTrail trail. Now let's have a very quick demo. So I have Stratus team installed there. I can do Stratus version, I see a version 2.2.2. If I do Stratus list dash dash platform AWS, I can see all the attack techniques for AWS. I can be a bit more specific and look at AWS attack techniques for exfiltration. Now if I copy-paste the name of an attack technique, I can go to the website and I will see the mapping to my attack, the description, you see we have the warm-up and the detonation phase, and the instructions on how to detonate the attack technique with Stratus Red Team. If I go back to the console, I do Stratus warm-up with the name, I see that the warm-up phase is going to create a snapshot and a volume for me. If I go to my console, I see that I now have a volume and a snapshot that was created for me. And this is really the prerequisite infrastructure that I need to reproduce my attack. And I can see that for now, the snapshot hasn't been shared with anything yet. Now if I do Stratus detonate of my attack technique, it's going to share the volume with an external AWS account to simulate this attack. And if I refresh, I will see that the permissions now show that the snapshot has been shared with a specific attacker account. Now one other point of doing that is being able to see what logs I get. So if I go to CloudTrail, I can have a query that says, show me the modify attribute events, and I will see that I have one event that was caused by Stratus Red Team for my specific snapshot, adding the create volume permission, essentially sharing it with an external account. Now we can do the same for Kubernetes. I'm here on a Kubernetes cluster with one node locally. If I do Stratus list for Kubernetes, I will get the list of attack techniques. And if I take this one, so stealing a service account token from a pod, I'm going to copy-paste that, go to the docs, it will show me what it means. So this is going to attempt to steal a service account token from a running pod. The warmup is going to create a namespace, service account, a pod, and the detonation is going to dump the service account token from the running pod. I can just do the detonate directly here. It's going to do the warmup, so spinning of the pod, and then do the detonation right away, showing me that it stole the service account token. Now, if I do Stratus detonate with another one, so privilege escalation, privilege pod, it's going to run a privilege pod. If I look at my pods running, I can now see that I have this malicious pod running. And if I do a Stratus status, I will see that some attack techniques have been detonated, some are still called, and I can do a Stratus cleanup with the name of my attack techniques to clean up everything. Let's have a look at the attack techniques we have in Stratus RATIM for AWS. Let's take this one. We're going to create a threat test scenario in GoCode, saying when we open a port 22 on a security group, and this is when we detonate this Stratus RATIM attack technique, then we expect a specific data log security signal that has this name, and we give it five minutes. Now, we're going to create another one, so we copy-paste this code for another attack technique, and let's take the one about sharing an EBS snapshot. We can just replace the attack technique name. We rename the scenario to exfiltrating an EBS snapshot, and then we expect a different alert. We give it five minutes, and then we're going to run threat test. We expect that it doesn't return any error, and then we go ahead, we go test our source code, and we see it's going to detonate the attack technique using Stratus RATIM, the first one, and the second one, and then it's going to show us that it has created the expected alerts that we thought we would get in data log. So, we see that this was closed also by the automation. This one as well. We are happy we get our alerts. Great, so now that we have seen how we can use Stratus RATIM in practice, let's see how we can use it in a more advanced fashion. And typically, you will see that Stratus RATIM works very well with automation. The first thing that we're going to see is programmatic usage. We're going to see also how we can automatically generate some logs data sets using the API from our CM, and we're going to see a few things about end-to-end testing our threat detection rules. So, the programmatic interface basically means that you can use Stratus RATIM as a Go library, just as you can use it from CLI. So, this is great if you want to automate some things, and you can just do a go get github.com data.stratus.ratim, and then use it from your code. It has an auto-generated documentation on the Go documentation, and basically the way to use it is very similar to how you would do it on the CLI. So, first you're going to instantiate a new Stratus RATIM runner for a specific attack technique. Then you say, at the end, I want to make sure it's cleaned up. Then you're going to warm it up. This is going to do under the hood, the terraform apply, etc. And when it's warm, you're going to detonate it. And that's it. It's great if you want to do some automations. Now, I worked in a SOG before, and one of the things that we like to do is to understand what a specific attack is going to generate in terms of logs. So, really, if I launch this attack, what logs do I get? And this is something that is hard to do manually because you need to go to detonate your attack, to go to see your logs, to understand what logs were created by your specific run, and what is just pollution coming from something else unrelated. So, the way that we can help with Stratus RATIM is, first, you can detonate the attack technique. Once you do the detonation, Stratus RATIM is going to automatically inject a specific unique ID in the user agent of the request that it makes to the AWS API, to the Azure API, or to the Kubernetes API. And based on that, it means that you can go to your SIEM, and you can ask it through the API, give me all the logs where you see this specific user agent. And what you get is, one, automation. And two, you are sure that the logs that you retrieve are caused by your actual detonation of the attack technique, which is a great property. So, we have some sample code for that on GitHub. It was written for Datalog as a SIEM, because that's what we know how to use, but it can be easily adapted to use anything like Splunk or any other SIEM. So, this is the way it works. You would go ahead and write dump logs, the name of your attack techniques, and then the output file in which to store the logs. It will use Stratus Red Team programmatically to detonate the attack technique. It's going to show you the unique ID for the detonation. It's going to search for the logs in your SIEM, here, Datalog. And then it says, okay, I found one log. I'm going to dump... Okay, I found one log. I'm going to dump this log to logs.json, which means that without leaving your terminal, you are able to detonate an attack and see what logs you get for that, which is a very nice property when you do detection engineering, as it makes the feedback loop quite easier and faster. The last use case I want to mention today is about end-to-end testing of threat detection. So, let's have a look at what a typical AWS detection pipeline looks like. First, we have a bunch of AWS accounts that are going to log to a single CloudTrail trail, probably running inside a management account. This is going to be logging to an S3 bucket, and probably you have some kind of forwarder that's going to take these logs and send them to your SIEM. Now, your SIEM is going to ingest these logs, to parse them, to aggregate them, maybe to do some kind of enrichment. And at the end, the detection rules that you have are going to run. And based on that, you get some alerts. Now, a lot of things can go wrong here, maybe your CloudTrail trail is not set up properly, maybe your forwarding is broken, you have a parsing issue, the rule that you expect to work is actually disabled, or you don't have enough license in your SIEM, so the rules are not running. A lot of things can go wrong. So, the idea is really to take this as a black box and to poke at it from one end using Stratus Red Team, and then to see what comes out in terms of alerts. And the workflow is really going to be, first, we detonate Stratus Red Team programmatically. Two, we pull our SIEM to check if we have an alert that we expect to have. If yes, we close the alert. If not, we basically raise an error to say, we detonated this attack, we were expecting this alert to trigger, it didn't trigger, so something is going wrong. And then it's easy to build some automation on top of that, to build some dashboards that say, you know, today we tested automatically these attacks, these are the results, everything looks fine, or you have some issues that you want to fix. So, today I'm very happy to announce that we are releasing Threatest. Threatest is a Go framework for end-to-end testing of threat detection rules. And let's see how it works. The idea is that you basically have detonators that you can use to detonate specific attack techniques, and matchers. Detonators are going to be about, how do I run an attack? And matchers are going to be, I expect a specific alert to have been triggered in a specific platform. For the detonators, we have the ones that are more for the cloud. So there is one using Stratus Red Team, one using the AWS SDK. You have some detonators that you can use to run OS-level commands over SSH or locally. And for the matchers, currently, you can use it to check if a specific alert was created on Datadog. And we are hoping to get some contributions to add support for other platforms such as Greylog as well. So let's see how this works. First, you're going to create a scenario with Threatest. So this is going to be using GoCode. You say, I want a scenario where I do an AWS console login without MFA. The detonation is going to be Stratus Red Team with this specific attack technique. And as expectations, I expect to get a Datadog security alert with this name and this severity. And I give it 15 minutes to be there. So now let's have a demo on how Threatest works in practice. All right, so that's pretty much it for today. So now we're going to wrap up. What's next for Stratus Red Team? First, we want to increase the attack techniques coverage. Typically, we want to add more techniques for Kubernetes for Azure and to have more platforms as well. We are eager to hear from the community. So typically, if you are involved in AWS security, especially incident response, I'm really interested to hear about what you see in the wild and when we have some attack techniques that make sense to help having them inside of Stratus Red Team. So specifically focusing on attacks that we see in the wild or that are used by Red Teams, by pen testers, by tooling. Then I want to say a big thank you to the contributors of Stratus Red Team. So the four first public ones are Ryan Marcotte-Cobb, Marcus Rollwagen, Aydan Alvarez, and Dakota Reilly. So they are the first contributors to Stratus Red Team. I'm very proud of them. And thanks again for all your contributions. Then one more thing that I want to announce today is that just this morning, we have released GCP support for Stratus Red Team. And this is thanks to Dakota Reilly from Acquia, who did the initial contribution. And I'm very excited about this. So we are going to have first three attack techniques. First one is creating an admin GCP service account, creating a GCP service account key, and impersonating GCP service accounts. So this is just fresh out. It was released this morning over breakfast. So go and check it out. I'm very excited about it. Thanks a lot for looking at this presentation. The slides are available here. If you have some questions, you can send them on Twitter or by email. My contact information is on the first slide. I hope you will find Stratus Red Team useful. I'm looking forward to your comments, your ideas, and your contributions. Have a nice day.