start	end	text
0	2120	Hello everyone, and thanks for joining this talk.
2140	4360	Today, we're going to talk about Kubernetes,
4360	8480	and specifically, how you can run successful attack simulation exercises.
8780	11460	First of all, a few words about myself. My name is Leo.
11460	15140	I'm a Senior Security Consultant at WithSecure, based in Manchester, UK.
15240	19340	I'm focusing mostly on threat simulation and, generally speaking,
19340	21100	collaborative security assessments.
21100	25980	So, one challenge that our clients at WithSecure typically come to us with is
25980	30420	how can we measure our capability to detect attacks in X environment?
30620	32980	And the environments we typically see are of all sorts,
32980	36680	Windows, Linux, mobile, macOS, on-prem cloud,
36680	39640	and even container orchestration environments like Kubernetes.
39880	43600	So, when a while ago, one of our more mature clients
43600	47000	were looking to assess and improve their blue team capability
47000	49920	against attacks in a Kubernetes environment,
49920	51840	we approached this as we usually do,
51840	53880	with a three-fold adversary simulation assessment.
53880	56320	So, first, we did some threat modeling,
56320	59380	just to better understand the risks to this novel platform.
59500	64160	Then, we wrote some tooling in order to simulate some attacks at scale.
64160	67260	And finally, we executed the test cases we designed,
67260	70480	side-by-side with the blue team,
70480	73980	researching along the way for means to improve visibility and alerting
73980	76360	within the Kubernetes ecosystem.
76520	78900	But this research didn't really stop there.
78900	80380	It didn't stop after that project.
80380	82740	We kept working on it in the background,
82740	84420	and this is what we're talking about today.
84460	87100	We'll start with a very gentle introduction to Kubernetes.
87100	89480	I know this is Adversary Village. It's not a cloud conference.
89480	92180	So, if you're not familiar with Kubernetes, fear not.
92560	95440	We'll talk about the threats posed to a Kubernetes cluster,
95440	99160	and why threat modeling is essential for the success of any security exercise.
99620	103040	And then we'll dive headfirst into Kubernetes attack simulation topics.
103040	106000	And we're going to look at tools, operational, planning,
106000	107440	and eventually execution.
108060	111000	And this talk isn't only for offensive security practitioners.
111000	114720	So, we'll cover some basic Kubernetes detection concepts as well,
114720	117200	to see things from the perspective of the SOC.
117260	121040	We'll look at things like log sources, detection engineering, and so on.
121400	124960	And finally, we'll demonstrate everything in an end-to-end simulation
124960	127040	of an attack against the cluster,
127040	129980	using the tool we will be releasing shortly after this talk.
131300	135180	Okay, as promised, let's start with some introductions.
135420	139080	We do that in order to introduce all the things that will come into play later,
139080	141060	both in the slides and in the demo.
141960	145160	But the thing is, if you're even remotely familiar with Kubernetes,
145160	147040	you will know that it's complicated.
147260	148980	So, just a word of caution.
149020	150980	This is not going to be an in-depth analysis.
151040	152640	It will be deliberately incomplete.
153060	156760	In fact, it's probably going to be the fastest introduction to Kubernetes ever given,
156760	158100	so please bear with me.
158760	162000	So, our system in question, the Kubernetes cluster,
162000	163760	consists of a set of worker machines.
163760	165280	We call them nodes, right?
165480	167780	And these nodes run containerized applications.
167780	171660	They are managed by the control plane, over there on the left of the slide.
171680	175720	And in order to run workloads, they need to have a container runtime installed,
175720	179040	such as container D, or in older versions, Docker,
179040	181540	as well as an agent called the kubelet,
181540	184600	which communicates with the control plane and specifically the API server
184600	186220	to receive instructions.
186420	189080	Now, this component that I mentioned, the API server,
189080	190260	is in the heart of the cluster.
190260	194100	It's the front end that all internal and external parties communicate with.
194100	196780	It exposes a REST API, which clients can talk to
196780	198700	if they want to interact with Kubernetes.
198700	203140	And I'm talking about clients like users or services, like CICD pipelines.
203440	206980	But it's important to remember that humans most commonly use kubectl
206980	209700	instead of just sending raw HTTP requests.
210240	212160	Now, when it comes to running applications,
212160	215000	the basic building block in Kubernetes is a pod.
215000	217560	A pod can consist of one or more containers
217560	220200	whose images are pulled from registries,
220200	222580	as well as volumes, storage resources.
222600	224420	What usually happens in the real world
224420	228620	is that workloads aren't actually deployed as individual pods,
228620	232740	but as managed collections of pods, like daemon certs or deployments.
233560	235220	But beyond pods and deployments,
235220	238520	there's a few more types of objects that Kubernetes understands,
238520	241540	or resources, such as secrets or services.
241540	244500	And all these resources can then be logically grouped
244500	247140	into different namespaces for each different project,
247140	250100	which you can think of like tenants in the cloud world.
250460	252780	And finally, there's a third layer besides the physical
252780	255540	and the logical, that of authorization,
255540	257860	with the most common authorization model being RBAC,
257860	259560	role-based access control.
259820	261360	RBAC defines the potential entities
261360	263960	and allows you to write policies for the permissions
263960	266960	that these entities will have against resources.
266960	269020	So in the context of RBAC,
269020	271500	humans are represented as user objects
271500	274040	that can authenticate using various mechanisms
274040	278760	like MTLS client certificates, Active Directory, IAM roles, and so on.
278760	281120	And you also get pods or external services
281120	283360	that are associated with service accounts.
283360	285440	And service accounts authenticate using tokens,
285440	287540	JSON web tokens, JWTs.
288560	292080	Okay, that was easy, right?
292340	294760	One thing to remember, though, is that in Kubernetes,
294760	297480	everything can be replaced. It's built to be extensible.
297480	300780	So it is 100% certain that your mileage will vary
300780	303020	and you will have numerous third-party technologies
303020	304600	running in your cluster.
304620	307520	Technologies like the ones tracked in the CNCF landscape,
307520	309200	which introduce their own set of risks
309200	310980	when deployed inside your cluster.
310980	313840	So in order to tailor any security exercise
313840	316360	to your environment with its own intricacies,
316360	319020	it's essential you perform some threat modeling first.
319020	320560	And that means answering a few questions
320560	322900	like, what are the assets I must protect?
322900	324820	And where would attacks come from?
324900	327500	And why would attackers target Kubernetes in the first place?
327880	330400	Let's start with an enumeration of the attack surfaces.
330400	331820	This will also help us understand
331820	333800	which levels we must execute in
333800	336280	if we're looking to simulate these attacks.
336840	338660	In the most typical scenario,
338660	341040	attacks will originate from the container level,
341040	342500	the code running within the pod.
342500	344940	For example, think of a compromised web service
345580	346660	or a backdoored image
346660	349180	that found its way into your cluster somehow.
349460	351780	And if that pod is assigned a service account,
351780	353200	the attacker can talk to the control plane
353200	356280	in a limited security context, hopefully,
356280	358280	unless they manage to break out of the container.
358700	361500	That way, they're on the node, the underlying host,
361500	363740	with potential access to other Kubernetes resources
363740	364760	from other namespaces
364760	366940	and with even higher security privileges
366940	369660	as they will most likely impersonate the kubelet.
370180	372400	And of course, there's always a threat of attacks
372400	373960	from the outside world.
374080	377000	Think of scenarios like leaked or stolen credentials,
377020	378840	a compromised service, a malicious user,
378920	380880	a coerced user, and so on and so on.
381380	383200	So once they're inside your cluster,
383200	384260	what will they move towards?
384260	385880	What's the final objective there?
386660	389180	An obvious answer to this one is, of course, the workloads.
389660	391900	If Kubernetes is the underlying platform
391900	394460	that your critical workloads are running in,
394460	396420	then it's a way into them.
396420	398600	It's a way into the workload.
398600	401080	So compromising Kubernetes could result
401080	403480	in unauthorized access to the data.
403480	405120	And we're talking about potentially sensitive data
405120	408160	that the apps may be handling, like proprietary software,
408160	409360	as you can see on this slide,
409360	411040	that can be stolen or even backdoored
411040	413300	to achieve a supply chain compromise.
414140	416780	But actually, that's not the most common incentive.
417200	418740	In the age of cryptocurrency,
418740	421120	every compute resource makes for an attractive target
421120	424880	for its immediate potential for financial returns.
424880	428400	A compute, in and of itself, is therefore worth protecting.
428640	429900	And you'll see that various instances
429900	432240	have been recorded with this particular objective.
433380	435260	Kubernetes clusters are usually also deployed
435260	437120	as managed cloud services,
437120	439920	or broadly speaking, in cloud infrastructure.
439920	442160	So instead of going for the applications,
442260	444040	a Kubernetes attacker might actually be looking
444040	445720	for a way into the cloud infrastructure,
445720	448600	into the underlying infrastructure.
448600	450960	But we've also seen Kubernetes attack techniques
450960	453280	across all phases of the intrusion lifecycle,
453280	454580	including persistence methods
454580	456980	that could enable APT-like surveillance
456980	459400	through a long-term infection,
459400	461200	and even for defense evasion purposes,
461200	464260	as, after all, Kubernetes is yet another platform
464260	466220	where an intruder can dwell in.
466480	468840	And usually, it's a less monitored platform,
468840	470240	which makes it a great place to hide
470240	472280	if you want to evade containment measures.
473220	476580	All right, so we know what adversaries are looking for.
476580	478080	We know where they'll come from.
478140	479660	Let's go ahead and simulate them.
479660	482620	Now, there's a few different approaches to go about this.
482620	485840	And instead of a stealthy, objective-based exercise,
485840	488220	we chose to adopt more of a Purple Team methodology.
488560	490600	And I know different people define Purple Teams differently,
490600	493660	so let me use the definition given by the guys over at SpectreOps.
493720	496020	It talks about collaboration between offense and defense
496020	499220	with the aim to increase familiarity with TDPs.
499360	501640	And for a novel environment like Kubernetes,
501640	503540	we similarly decided it's more valuable
503540	505240	to opt for a collaborative engagement
505240	507520	and try to help the blue team understand
507520	509800	attacker behaviors instead of vulnerabilities.
509800	512460	And at WithSecure, we focus a bit more on detection.
512460	514500	So when we're planning a Purple Team exercise,
514500	517380	we do it in one of two ways, depending on what we want to achieve.
517380	520700	So we could either aim to cover as many TDPs as possible,
520700	522960	executing them one after the other in isolation,
522960	525300	or we could chain a few attacks,
525300	527360	similar to how a threat actor would move,
527360	529180	to make it as realistic as possible.
529520	532620	And even mimic a specific campaign from the ones we saw before.
533200	536520	Okay, let's look at these two options in a bit more detail
536520	538540	in the context of a Kubernetes exercise.
539600	541440	So for Kubernetes specifically,
541440	543940	we found that there aren't as many campaigns documented
543940	546340	as there are for on-prem infrastructure.
546460	549180	And as a result, there's not a lot of threat intelligence available.
549380	552780	So when incidents do happen in other organizations,
552780	555160	they make for a good opportunity for your organization
555160	558160	to perform an emulation cycle, to perform a campaign.
558260	560400	In that case, you probably know already
560400	562620	which threat actor you want to emulate.
562620	565000	But if not, the security researchers over at Wiz
565000	567640	maintain this great matrix of cloud threats.
567640	569880	And that also covers Kubernetes incidents.
570300	573400	So it aggregates threat intelligence from various blog posts,
573400	575880	like Unit 42, Aqua, Sysdig, CrowdStrike,
575880	577300	all the ones we saw before.
577580	580820	And you can collect all this threat intelligence,
580820	583600	analyze it, and finally recreate an attack chain
583600	586060	and execute this inside your cluster.
586180	589420	Now, a nice way of documenting these different emulation plans
589420	591140	is Jupyter Notebooks.
591140	592780	And we've seen a bit in the demo
592780	595200	how Jupyter Notebooks can also streamline execution
595200	596940	of the attack simulation.
596940	599580	But for more of a one-off assessment,
599580	601140	or if you're looking to build a baseline
601140	605080	of your detection capability against all the possible TDPs,
605080	607300	then you first need a list of all the different TDPs
607300	608920	for the platform in question.
609100	612840	In 2020, Microsoft released the third matrix for Kubernetes,
612840	614900	which was the first systematic categorization
614900	617640	of Kubernetes techniques observed until then.
617640	619500	And it seems to be actively maintained.
619800	622680	There's also a Mitre ATT&CK matrix for containers,
622680	625460	but it doesn't really care about the orchestration platform.
625460	627700	And I actually got some very good ideas for attacks
627700	629320	by looking at KubeHunter.
629680	631320	Although it's a vulnerability scanner,
631320	633120	it just had a long list of checks supported,
633120	634920	so it gave me some very good ideas.
635380	639300	But for more technical instructions on how to execute each TDP,
639300	641180	I found the KubeNomicon to be a good source,
641180	644160	so shout out to Graham Helton from Google for his project.
644780	646780	And once you've designed these test cases,
646780	650080	one good way of describing them is via a code format,
650080	653620	allowing them to be maintained in a version control system like Git.
653620	656000	And this is a well-known practice in DevSecOps.
656000	658580	You know, attack definitions as code, detections as code,
658580	660260	we can apply it here as well.
660640	663440	This way, as your Kubernetes environment evolves,
663440	666460	so does your repository of attacker test cases.
667300	670080	Fantastic. So, we have planned everything.
670080	671620	We are ready to get our hands dirty.
671620	673660	Let's start bashing kubectl commands.
674480	676180	No, that wouldn't scale very easily,
676180	678520	but thankfully there are a few simulation frameworks out there
678520	680680	to make our lives a bit easier.
680680	684280	Starting with the familiar ART, Atomic Red Team by Red Canary.
684440	686700	This is out of Citi Village, I'm sure you're all aware of it.
686700	690360	Although it does support a few test cases on the container level,
690360	692680	it's not really built for cloud environments,
692680	696320	so it doesn't really support attacks against the Kubernetes control plane.
696420	700120	On the other hand, Stratus Red Team was specifically made for the cloud
700120	702040	and for attack simulations,
702040	705360	so it even supports eight pure Kubernetes test cases.
705360	708820	So it's actually a good choice for this particular purpose.
708820	712560	However, you will find it's not very easy to write new test cases,
712560	714320	and the fact that it runs outside of your cluster
714320	717880	kind of restricts the number of different levels that it can execute in.
718480	721280	One tool that can, in fact, run from within the cluster
721280	723380	is Pirates by InGuardians.
723460	724800	It's also widely known.
724800	727920	Various talks, blog posts, webinars out there talking about it.
727920	730820	It's so well known that it's actually been used by threat actors.
731240	734760	But once again, the attacks it supports are hard-coded,
734760	737700	and the tool itself doesn't really allow for customization.
738840	741720	So overall, when we were doing this research,
741720	744800	we realized that none of these tools performed exactly what we wanted.
744800	747420	These options all had some limitations.
747420	750620	So we decided to extend our own existing tool, Leonidas,
750620	752120	to add Kubernetes support.
752320	755320	And if you're not familiar with it, no, I did not write the original version.
755380	757640	It's not named after me. That would be a little bit lame.
758440	760420	I don't want to talk too much about Leonidas.
760420	762060	It's an open-source tool.
762200	765600	My colleague Nick Jones originally wrote the AWS version.
765600	768540	And again, various presentations out there talking about it.
768540	769940	What made Leonidas attractive
770380	772360	for the challenge of Kubernetes attack simulations
772360	774500	was some of its core principles,
774500	777180	like the fact that it was built with extensibility in mind,
777180	779900	and how friendly it was to write new disk cases
779900	781340	without having to be a developer,
781340	783920	as well as the ability to run within your environment
783920	785880	and manage its own resources.
786340	788300	And these were the concepts that we applied
788300	790440	when building Kubernetes support for it.
790440	792800	We wanted something running within the cluster,
792800	794680	distributed as a disposable image,
794680	796080	as an ephemeral image.
796080	798080	We wanted something that analysts or threat hunters
798080	800780	could trivially write new TDPs for.
801460	803040	But we also wanted purple teams
803640	805680	to have an easy way to execute them
805680	807820	by just interacting with an API,
807820	810300	as well as a way for operators and defenders
810300	813520	to track execution of each action.
813520	814960	And we can do that through the logs
814960	817520	that are stored and shipped to the scene,
817520	820700	along with all the other telemetry that the cluster generates.
821060	823000	Now, alongside this new version of Leonidas,
823000	825480	we are also releasing a set of Kubernetes test cases,
825480	828140	17 in total, not only to help you get started
828140	829760	writing attack definitions,
829760	831720	but also to showcase the tool's capabilities,
831720	834400	like running kubectl commands, running OS level commands,
834400	836500	and even applying custom YAML manifests.
836740	837940	A lot of different options.
838500	841280	Okay, lastly, I want to talk about operations teams
841280	844060	and how they can apply the security monitoring concepts
844060	845620	of the traditional SOC
845620	847660	into container orchestration environment.
847980	849460	You know, after all, the goal of any exercise
849460	851620	is to upskill defenders and build the capability.
852860	855580	The most important building block of security monitoring
855580	857660	is arguably logs, all right?
857700	860840	If you look at the official Kubernetes documentation, however,
860840	863660	you'll find there are plenty of log sources available,
863660	864960	but no standard architecture
864960	867120	for what we call cluster-level logging.
867120	869320	This is left to the users to implement.
869860	872280	Roughly speaking, from all the different types,
872280	874360	let's say we can categorize all of them
874360	876180	into three different types of log sources.
876180	878820	So first, we have logs from your application,
878820	879780	logs from the code,
879780	882840	which are exposed to container logs and pod logs.
882840	885660	You can collect them with the kubectl logs commands,
885660	886820	but they are ephemeral,
886820	888760	which means that if the pod terminates,
888760	890080	the logs are gone.
890680	893040	We also have logs from Kubernetes components,
893040	895920	like the API server, the kubelet, the container runtime.
895920	897520	Just like container logs,
897520	900140	these ones are also stored on the nodes,
900140	903760	which means that, actually, in a production cluster,
903760	905760	nodes will be disposable.
906280	908840	If the VM is replaced, these logs are also gone.
908840	911540	So you need to take them out of the host while you can.
911540	913480	And thankfully, there's lots of solutions out there,
913480	915980	agent-based solutions like Fluentd that can do that.
916420	920480	And finally, we have logs that aren't particularly native to Kubernetes,
920480	923740	but are still of interest for the security of the overall ecosystem.
923860	927420	If your cluster is a managed service from a public cloud provider,
927420	929880	then that cloud provider's logging and monitoring solutions
930800	932340	are also crucial to monitor,
932340	934760	like IAM logs or GuardDuty and stuff like that.
934760	938120	And similarly, if you host your own internal image repositories,
938120	941200	we found that logs from these image repositories
941200	944540	could allow the correlation of certain attacker actions,
944540	946660	and that's not even half of it.
946660	950380	There's just a ridiculous amount of logs flowing throughout your cluster,
950660	953560	but not all of them are useful for detecting attacks.
953560	956180	The ones that are, are those selected here.
956180	959060	It's those that answer not so much why something happened,
959060	962480	but rather who, did what, when, and where from.
962960	967100	And these security-relevant log sources map to the execution levels.
967100	968600	If you remember from the previous slide,
968600	971260	which provides us visibility on the container level,
971260	973700	on the node level, and the control plane level.
974300	977220	And alongside those, I've also highlighted the cloud IAM logs,
977220	978520	because if you're running a managed cluster,
978520	981140	identity is always of security interest.
981800	984760	I want to take a couple of slides to zoom in on the most important log source,
984760	988480	the true MVP of Kubernetes attack detection, the audit log.
988560	992480	You can consider the audit log as the access logs of the API server,
992480	995040	which simply means that if you're interacting with a control plane,
995040	997800	you're getting recorded, with some exceptions.
997980	1000720	The resulting events can be formatted in JSON,
1000720	1003900	and they answer the security investigation questions that we raised before.
1004140	1007540	Important to mention, though, these are not enabled by default.
1007680	1012060	To enable them, you need to define a node policy and reconfigure the API server,
1012060	1014840	but you can't always do that, for example, in managed clusters.
1014900	1017780	Some events will be very noisy, others will be more important,
1017780	1019480	so you want to have more detail.
1019600	1021720	And that's why there's a few different verbosity levels
1021720	1026140	that you can set for each different type, each different event type.
1026160	1029320	You can easily find a sample policy to get started with,
1029320	1031580	like the one I'm linking in the bottom of the slide,
1031580	1035440	but it's going to take some tuning to find the perfect mix.
1036100	1039500	The API server can also be configured to store audit logs locally
1039500	1044120	or send them to a hook, and both of these ways allow for wording to a scene.
1044620	1049000	Once you do that, you now have the ability to write alert queries upon these logs,
1049000	1051580	which brings us to the topic of detection engineering.
1052040	1055340	In its simplest form, an alert for suspicious control plane activity
1055340	1059860	could be captured by the verb and the resource, such as list, secrets.
1060380	1062860	And this behavior can then be defined in a SIGMA rule
1062860	1064940	for easier management and distribution.
1065460	1068000	We found that there weren't many SIGMA rules out there available.
1068000	1070720	In fact, there weren't any SIGMA rules out there available
1070720	1075060	that operated on Kubernetes audit logs, so we published a few.
1075060	1078980	And since this log source didn't really exist, we also introduced it
1078980	1082300	by contributing a backend pipeline to the SIGMA ecosystem
1082300	1085660	in order to convert rules to actual alerts that a scene can understand.
1086140	1089000	But attacks could not only target the control plane,
1089000	1090080	if you remember from the previous slide,
1090080	1092440	they could originate from within the container.
1092460	1094940	But luckily, there's a lot of research in this area,
1094940	1097820	many solutions available, like Falco or Tetragon,
1097820	1101060	that monitor containers by tapping into the kernel of the underlying node
1101060	1102660	using eBPF.
1102960	1106140	And this enables EDR-style analysis of the syscalls,
1106140	1109220	which then allows the authoring of rules in an easy format
1109220	1114760	for suspicious process command lines, for suspicious network activity,
1114760	1116800	and other system-level events.
1117780	1119980	All right, now it is time for the demo.
1119980	1122500	So in the upcoming video, we'll see how we can simulate
1122700	1124660	a fictitious threat actor who gets access to a cluster
1124660	1125800	and performs some attacks.
1125800	1128200	We'll do that using Leonidas for Kubernetes.
1128260	1130820	And after we run the attack chain, we'll put our blue hats on,
1130820	1133820	we'll put our defender hats on, the Viking hat,
1133820	1138060	and look at Elastic and Falco, which we have set up,
1138060	1139960	just to see what alerts have been raised.
1140040	1142820	All right, let me switch to the demo video.
1147250	1148910	Can you all see the video?
1149510	1150390	No?
1151830	1153230	Good thing I asked.
1156390	1157970	Is it this way?
1160090	1162070	Now I can't see how to maximize it all.
1162070	1163870	Can I have some tech support here?
1169570	1171990	Yeah, but I can't see the pointer, so I can maximize it.
1172890	1173850	You reckon?
1175750	1176470	Nice.
1176990	1178750	The problem is that I can't see it.
1179290	1180670	All right, let's do it.
1181730	1182450	I won't...
1183670	1185430	Yeah, but I want to talk over it.
1197950	1201510	You can switch your display settings, so it's, yeah, duplicated.
1204030	1204930	See it now?
1205670	1206910	Awesome, fixed.
1207470	1211270	All right, so first thing we're going to do
1211270	1213210	is confirm connectivity to the Kubernetes cluster.
1213210	1215290	We'll do that using a cluster info command.
1215450	1218190	We see that, indeed, the Kubernetes cluster is up and running.
1218190	1219890	We also have the dashboard up and running,
1219890	1224430	and you can see we have a couple of namespaces already there,
1224430	1226210	including one called DharmaProds,
1226210	1228470	which has just one deployment in there.
1228470	1230470	It's called HVACController, and once we click it,
1230470	1232550	we'll see that it includes a couple of pods,
1232550	1234210	one looking like a database, and the other one
1234210	1236910	potentially doing something sensitive, HVACController.
1237430	1239410	And now we're going to go ahead and deploy Leonidas
1239410	1240790	into that cluster.
1240790	1243190	To do that, we'll run a couple of generator commands.
1243190	1245650	Generator is an accompanying tool
1245650	1248610	that allows deployment of Leonidas.
1248650	1250770	First, we're going to generate the Python code
1250770	1253330	from the attack definitions that we have previously defined,
1253330	1256010	and then we're going to generate the Kubernetes resources
1256010	1258730	in the standard YAML manifest.
1258730	1260850	These resources will then go ahead
1260850	1264010	and kubectl apply into our cluster
1264010	1266610	so that we can create the Leonidas deployment
1266610	1269030	into our namespace, into DharmaProds.
1269030	1270790	And you'll see that it started running.
1270790	1273810	Once it's completed, once deployment is completed,
1273810	1276630	we'll then expose the port.
1276630	1278890	We're using a kubectl port forward command.
1278970	1281130	KL, by the way, is an alias for kubectl.
1281130	1283250	And we bring it locally to port 5000
1283250	1285030	so we can interact with it.
1285310	1286810	And once this is done,
1286810	1289370	indeed, we can access the API.
1289370	1292710	It's the familiar API, if you looked at Leonidas before.
1292710	1294750	There are two ways to interact with Leonidas.
1294770	1297730	One of them is via this very simple client,
1297730	1299750	providing the values in all these fields
1299750	1301310	and then hitting execute.
1302030	1305270	But instead, we're going to do it through a Jupyter notebook.
1306510	1307990	And in order to do that,
1307990	1310710	we first need to start the Jupyter service.
1310710	1314310	This is going to open the port 8.8.8.8.
1314310	1317790	Once we click it, we'll see the web UI of Jupyter,
1317790	1320810	navigate to the right directory of the threat actors notebooks,
1320810	1323110	and open our own notebook for OFA-8.15.
1323110	1325970	Now, OFA-8.15 is our fictitious threat actor.
1327310	1328370	Like we said before,
1328370	1330230	execute some attacks against the Kubernetes cluster
1330230	1331830	and first get some access to it.
1331830	1334170	We've got a nice little visualization of it right here.
1334650	1337150	First step for it is to simulate the initial access.
1337150	1340130	Now, the typical scenario would be a leaked kubeconfig file.
1340470	1342070	Actually, before we get to these attacks,
1342070	1343410	let's look at the Defender tech,
1343410	1345590	the Defender solutions we have up there, up and running.
1345590	1351190	We do have Elastic, where we're forwarding audit logs from our cluster.
1352670	1355490	Nicely visualized with the verb resource, like we said before.
1355490	1358510	And we also have some alert rules configured.
1358890	1361550	You can see on the right-hand side that these are all enabled.
1362570	1364610	And just to make sure that nothing has fired just yet,
1364610	1367570	we're going to refresh that page, see no hits, and we're ready to go.
1367570	1370250	But before we start executing, let's also look at Falco.
1370250	1374090	We've configured this on the nodes of the cluster to monitor the containers,
1374090	1375150	like we said before.
1375650	1378530	Cool. All right, let's start running the attack step-by-step then.
1378530	1381650	So if we navigate back to the Jupyter Notebook,
1381650	1384450	we start hitting run through every different cell.
1384450	1386610	And the first step is to simulate the initial access.
1386810	1388890	So the typical scenario is a leaked kubeconfig file.
1388890	1392630	In that kubeconfig file, there might be a service account token, a JWT.
1392630	1396350	And this token is what we're going to instantiate a client with,
1396530	1397930	a client to Leonidas.
1397930	1401490	So behind the scenes, this Jupyter Notebook is running some Python,
1401490	1402470	bare-bones Python.
1402470	1404250	We'll publish all of that, by the way, very soon.
1404250	1407450	And this interacts with the Leonidas service running within the cluster.
1407510	1410530	So the first thing, once the attacker has obtained access,
1410530	1413410	would be to list their own permissions, just to see what they can do.
1413710	1416670	You can do that using the self-subject review API.
1416830	1420450	So we just run that cell then and look at the results.
1420830	1424250	We observe in the results that we have some permissions on the pods.
1424250	1428230	Cool permissions, create, read, update, delete on the right-hand side of the slide.
1428350	1432470	And we also have some permissions on the secrets, which is already a problem.
1432630	1435810	So using these permissions, we're going to go ahead and enumerate the pods.
1436270	1441170	You'll see, like we saw before, patient DB, Leonidas deployment, and the HVAC controller.
1441170	1445230	And using the permissions we have over the secrets, obviously, we're going to list the secrets.
1445570	1448430	With some processing, with some post-processing,
1448430	1452550	we'll see that one of them looks like a password, but we don't know yet.
1452550	1457350	But putting the pieces together, we have the database pod, we have something that looks like a password.
1457350	1461550	So why not run a MySQL dump command to get a dump and prepare it for exfiltration?
1461610	1467970	Sure enough, we provide the password on the command line, the dump is being generated, and we're ready to send that back.
1468030	1475930	Now, before we finish up with this attack, the attacker also tries to perform some destructive activity just to delete a deployment.
1475930	1480330	But this activity will fail because, as we saw before, they do not have the permission to do so.
1480330	1487210	And finally, just to wrap it up, just to wrap up the threat, the Jupyter Notebook will print the table of all the test cases that we executed
1487210	1492410	for good bookkeeping, timestamps, success status, and the name of the test case.
1492790	1502010	Cool. So, we'll now, as promised, return back to the detection capabilities, Blue Team Solutions,
1502010	1505010	and we'll see that two alerts have actually fired, as promised.
1505010	1512150	And the same thing stands for Falco, since it detected the MySQL dump command.
1512610	1517010	Don't worry about the too many lines, it's just a misconfigured rule.
1517010	1522350	Important thing to notice is that it did capture the MySQL dump command executing within the container.
1523290	1526130	And that wraps up the demo. I do have one more slide.
1537900	1538860	Awesome.
1551480	1556020	All right, that one last slide. Hopefully you can see just the slide, not the speaking notes.
1556020	1560060	Cool. All right. I want to close with just a few key takeaways.
1560280	1568120	Now, building Kubernetes' detective capability is a journey, and the first step towards it is to understand the threats posed to your environment.
1568620	1575300	Once this is done, we saw how the concepts and the methods of collaborative attack simulation can be applied to this world as well,
1575300	1577560	in order to build defenses proactively.
1577980	1583860	To this end, we're giving the world a Kubernetes native attack simulation framework, Leonidas for Kubernetes,
1583980	1589500	a set of test cases to get started, along with their corresponding Sigma rules as a building block for detections.
1590040	1592380	And that's all from me. Thank you very much for your time.
1592380	1596680	You can find the links mentioned in this QR code, and you can find me on Twitter if you want to discuss further.
1596680	1598440	Thanks to Adversary Village for having me.
