<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Nico Green on Medium]]></title>
        <description><![CDATA[Stories by Nico Green on Medium]]></description>
        <link>https://medium.com/@mr-intern?source=rss-2c8cbbedc34d------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*J9GoXfZ1oNFtymS-G0dP1Q.jpeg</url>
            <title>Stories by Nico Green on Medium</title>
            <link>https://medium.com/@mr-intern?source=rss-2c8cbbedc34d------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 02 Dec 2026 09:56:53 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@mr-intern/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Improvised Song Writing: A Manifesto (part 1)]]></title>
            <link>https://mr-intern.medium.com/improvised-song-writing-a-manifesto-4a1f798cbd02?source=rss-2c8cbbedc34d------2</link>
            <guid isPermaLink="false">https://medium.com/p/4a1f798cbd02</guid>
            <category><![CDATA[songwriting]]></category>
            <category><![CDATA[music]]></category>
            <category><![CDATA[art]]></category>
            <dc:creator><![CDATA[Nico Green]]></dc:creator>
            <pubDate>Mon, 16 Dec 2024 17:47:49 GMT</pubDate>
            <atom:updated>2024-12-16T22:04:27.183Z</atom:updated>
            <content:encoded><![CDATA[<p>What is improvised song writing?</p><p>It’s when you improvise the lyrics to a song, basically. That, by itself, isn’t new. What is new is the cultural context that improvised song writing exists in. Or, rather, that I would like it to exist in. Right now, improvised song writing is almost exclusively seen in the context of comedy, or freestyle rap, and even within these contexts, it’s seen as impressive but not profound. I believe that improvised song writing, when done by well, can produce great art. In fact, it surely already has. If you read no further and take one thing away from this manifesto it should be<em> </em>this:</p><p><strong><em>Improvised song writing, when done right, is the most authentic way to write lyrics. </em></strong><em>Each word rises straight from the depths of the subconscious mind with no time for filtering. Authenticity is a necessary ingredient in great art. Improvised song writing can, and has, produced great art.</em></p><p>There is this misunderstanding between those who consume art and those who create it, and improvised song writing suffers because of it. People who consume art assume that the greatest art is made from the greatest dedication. They love to hear how many hours, days, years, it may have taken to produce a song, book, or poem. In reality, read any book on creativity written in the last 30 years and you’ll see that creating art is about getting out of your own way. Often, your first idea is your best idea. The longer you sit with a creative work, the further it travels from that original beautiful moment where it was born. Personally, I’ve read two books on creativity: The Artists Way by Julian Cameron and The Creative Act by Rick Rubin — the two most popular books on creativity. They both assert the same conclusion:</p><p>Great art has nothing to do with hard intellectual work.</p><p>It’s not about locking in and focusing, it’s about opening up and listening. Therefore there is nothing that suggests that great art can’t be created improvisationally. In fact, many famous song writers have written their best work in less than 15 minutes. Here are just a few:</p><ul><li>Sweet Child O’ Mine” by Guns N’ Roses was written in five minutes</li><li><a href="https://www.buzzfeed.com/ellendurney/bruno-mars-poked-fun-at-debt-rumor-mgm-casino">Lady Gaga</a> wrote her breakout single “Just Dance” in 10 minutes.</li><li>Freddie Mercury wrote “Crazy Little Thing Called Love” in 10 minutes.</li><li>Kanye West wrote “All Falls Down” in 15 minutes</li><li>Sia wrote “Chandelier” in 15 minutes.</li></ul><p>(<a href="https://www.buzzfeed.com/imaraoshibanjo1/famous-songs-written-quickly">Source</a>)</p><p>SZA was once quoted in an interview saying that she freestyled her entire debut album, CTRL, top to bottom. Improvised song writing isn’t new, but the public understanding of it as a valid art form is.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4a1f798cbd02" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[“Hacking Kubernetes: Threat Driven Analysis and Defense” Chapter 10 Notes: Organizations]]></title>
            <link>https://systemweakness.com/hacking-kubernetes-threat-driven-analysis-and-defense-chapter-10-notes-organizations-b016bae5adef?source=rss-2c8cbbedc34d------2</link>
            <guid isPermaLink="false">https://medium.com/p/b016bae5adef</guid>
            <category><![CDATA[phishing]]></category>
            <category><![CDATA[kubernetes-security]]></category>
            <dc:creator><![CDATA[Nico Green]]></dc:creator>
            <pubDate>Fri, 17 Jun 2022 18:12:36 GMT</pubDate>
            <atom:updated>2022-07-07T08:47:50.790Z</atom:updated>
            <content:encoded><![CDATA[<p><em>Prefer videos over articles? </em><a href="https://youtube.com/playlist?list=PLSGxDsVUZ-zwKQZ6-2dyjjojKADL3j6BE"><em>Check out the video book review here</em></a></p><p><strong>Welcome to the final chapter!</strong> Chapter 10: Organizations. For 9 chapters and nearly<em> 250 densely populated pages</em> we have learned about how to attack and defend Kubernetes clusters. Oddly enough there was an elephant in the room the entire time. An extremely important security flaw that we have been dancing around, <strong>people.</strong></p><p><em>People</em> write code, review code, and push code.</p><p><em>People</em> define roles, assign roles, and enforce policy.</p><p><em>People</em> respond to alerts from automated intrusion detection systems.</p><p><em>People </em>mistakenly enter their AWS credentials into phishing sites when they’re in a rush to get something done.</p><p>In this chapter we are going to talk about organizations and the people working within them. We will also discuss organizational security at a higher level by comparing managed Kubernetes services offered by cloud providers and on-premises Kubernetes deployments.</p><p>Let’s dive in, one last time.</p><h3>Intended Audience</h3><ul><li>Anyone who is reading <a href="https://zillionbooksusa.com/books/hacking-kubernetes-threat-driven-analysis-and-defense/">the book</a></li><li>Anyone interested in reading <a href="https://zillionbooksusa.com/books/hacking-kubernetes-threat-driven-analysis-and-defense/">the book</a></li><li>Programmers, Devops, and Cyber Security people who work with Kubernetes and have security in mind</li></ul><p><em>PS: If you like the book, the download the first half for free </em><a href="https://control-plane.io/hackingkubernetes/"><em>here</em></a></p><h3>Chapter 10 Discusses:</h3><ul><li>The Weakest Link</li><li>Kubernetes in the Cloud</li><li>Kubernetes On Premises</li></ul><h3>The Weakest Link</h3><p>An organization is built on the backs of people, not just technology. This is true even in tech companies. While the company’s product may be <em>enabled</em> by technology, it is still being built, fixed, and audited by people. Even in the case of automation-heavy systems like Kubernetes, the system is configured, inspected, and reconfigured by people.</p><p>For the most part, cybersecurity solutions don’t exist in a vacuum. They are used (or ignored) by people in an organization. If people don’t care for security then they won’t uphold it. For example, take the entry-level software developer (a role I am personally familiar with). They aren’t evaluated based on how securely they handle data or how faithfully they use 2 factor authentication. Usually, security practices are defined by the IT department and rarely (if at all) enforced. In the real world, sometimes people within a company see security measures as needless restrictions which slow down their workflow,</p><blockquote>“Oftentimes, the challenge is that one either has a secure or a usable setup. Using a combination of (forcibly rotating) passwords, Yubikeys, one-time passcodes from OTP devices, and other things to establish you identity can be tiresome. So people come up with shortcuts, trying to outsmart the security controls.”</blockquote><p>To ignore the psychology at play in day-to-day security decisions is to ignore the weakest link in every organizations security: <em>people</em>. If security is not a part of the culture of an organization then it won’t be respected and this is a problem technology can’t fix.</p><p>People are the low-level enablers of security at the base of the organizational pyramid. Technology sits at the top of the organizational pyramid. Now we will move on to higher level organizational security decisions: deciding between hosting Kubernetes in the cloud, or hosting Kubernetes on Premises</p><h3>Kubernetes in the Cloud</h3><p>Kubernetes is an open source technology and you need not pay to use it. Anyone can spin up a Kubernetes cluster with a single bare metal computer, but many organizations choose to pay for a managed Kubernetes cluster from a public cloud provider. Why is that?</p><h4>Benefits of Managed Kubernetes Services</h4><ul><li><strong>Managed control plane. </strong>In GCP, the managed Kubernetes service is called Google Kubernetes Engine (GKE). They manage the control plane for you, alleviating many security concerns.</li><li><strong>Autoscaling. </strong>GCP also handles autoscaling for you which is especially helpful because if you experience unusual amounts of traffic once or twice a year you need not buy more bare-metal machines to compensate. Instead, google provisions you more as you need.</li></ul><p>Of course, these are not free services. In GCP (as well as other cloud providers) you pay fees for the resources you use with options to pay more for additional services like intrusion detection or cloud SQL databases. Which brings us to the downsides of managed Kubernetes services.</p><h4>Downsides of Managed Kubernetes Services</h4><ul><li><strong>Vendor lock-in. </strong>As you build your app, if you base your entire technology stack around a cloud providers services you become increasingly dependent on them. You tie the future of your product to the future of their cloud services. Additionally, the longer you stay with a cloud provider the harder it is to separate from them (if your product is dependent on their services). Legacy code is hard to work on when the people who wrote it have moved on to other companies. Adding in the fact that the code is intertwined with the cloud providers services makes things even more complicated.</li><li><strong>High cloud computing fees</strong></li></ul><h3><strong>Kubernetes On Premises</strong></h3><p><em>Disclaimer: an on-premises Kubernetes cluster is not the only alternative to a managed Kubernetes cluster from a public cloud provider. It’s a spectrum and these are the opposite ends.</em></p><p>On premises Kubernetes clusters save you from high cloud computing costs and vendor lock-in. However, this path has its own unique security challenges. In this section we will discuss those challenges as well as some benefits of on-prem Kubernetes deployments.</p><h4>Benefits of On Premises Kubernetes</h4><ul><li><strong>Access to bleeding edge technologies. </strong>For example, if you want to experiment with new container runtimes and sandboxing techniques you need not wait for google or amazon to implement these as features!</li><li><strong>No vendor lock in</strong></li><li><strong>No high cloud computing fees</strong></li></ul><h4><strong>Downsides of On Premises Kubernetes</strong></h4><ul><li><strong>You are responsible for securing your control plane. </strong>When Kubernetes is managed by a public cloud provider, you don’t need to touch the control plane. All you need to think about is your workloads. When deploying on-prem, control plane security becomes a serious concern.</li><li><strong>You are responsible for physical security. </strong>When your cluster exists in a datacenter owned by your organization it is your responsibility to secure that location from attackers. This is something that you don’t need to think about when renting compute resources from public cloud providers.</li><li><strong>You are responsible for availability.</strong> Public cloud providers can keep your applications up and running regardless of geographical issues. Even if there are hurricanes ravaging power plants in North America, they will just shift your workloads to a different zone. When deploying Kubernetes on-prem, your product is subject to the woes of your geographic area and 100% up-time is harder to guarantee.</li></ul><p>So yeah, while owning your own cluster frees you from the woes of vendor lock-in and cloud computing fees, it certainly comes with its unique set of responsibilities. Organizations should mix and match with on-prem and cloud solutions to find the best fit for their use case.</p><h3>Conclusion</h3><p>Organizational security is an often overlooked topic in the cybersecurity space because as tech people, it’s natural to focus on the technology. However, at the end of the day security is owned and enabled by the people in an organization. Companies with a culture that values security will be better off than those who simply enact policies or implement cybersecurity solutions without checking in with the people responsible for enabling them. If you enjoy these articles, <a href="https://www.youtube.com/playlist?list=PLSGxDsVUZ-zwKQZ6-2dyjjojKADL3j6BE">check out my video series</a> where I discuss each chapter in the book.</p><p><strong>Stay sharp!</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b016bae5adef" width="1" height="1" alt=""><hr><p><a href="https://systemweakness.com/hacking-kubernetes-threat-driven-analysis-and-defense-chapter-10-notes-organizations-b016bae5adef">“Hacking Kubernetes: Threat Driven Analysis and Defense” Chapter 10 Notes: Organizations</a> was originally published in <a href="https://systemweakness.com/">System Weakness</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[“Hacking Kubernetes: Threat Driven Analysis and Defense” Chapter 9 Notes: Intrusion Detection]]></title>
            <link>https://systemweakness.com/hacking-kubernetes-threat-driven-analysis-and-defense-chapter-9-notes-intrusion-detection-609338dcb990?source=rss-2c8cbbedc34d------2</link>
            <guid isPermaLink="false">https://medium.com/p/609338dcb990</guid>
            <category><![CDATA[kubernetes-security]]></category>
            <category><![CDATA[intrusion-detection]]></category>
            <dc:creator><![CDATA[Nico Green]]></dc:creator>
            <pubDate>Fri, 17 Jun 2022 11:08:57 GMT</pubDate>
            <atom:updated>2022-06-24T06:57:53.334Z</atom:updated>
            <content:encoded><![CDATA[<p><em>Prefer videos over articles? </em><a href="https://youtube.com/playlist?list=PLSGxDsVUZ-zwKQZ6-2dyjjojKADL3j6BE"><em>Check out the video book review here</em></a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nxweJ5lqr3jbtBPaPVtQ_w.jpeg" /></figure><p><strong>Welcome to chapter 9! Intrusion Detection</strong>. Intrusion Detection Systems are meant to be a last defense against hackers. They are like the “trip wires” that must be skillfully dodged (or disabled) after the robbers have broken into the bank and are approaching the vault filled with cash. In this chapter we will go over how IDS goes about detecting intruders, a new type of IDS which leverages eBPF, and how to avoid detection from these systems as an attacker.</p><p>Let’s dive in.</p><h3>Intended Audience</h3><ul><li>Anyone who is reading <a href="https://zillionbooksusa.com/books/hacking-kubernetes-threat-driven-analysis-and-defense/">the book</a></li><li>Anyone interested in reading <a href="https://zillionbooksusa.com/books/hacking-kubernetes-threat-driven-analysis-and-defense/">the book</a></li><li>Programmers, Devops, and Cyber Security people who work with Kubernetes and have security in mind</li></ul><p><em>PS: If you like the book, the download the first half for free </em><a href="https://control-plane.io/hackingkubernetes/"><em>here</em></a></p><h3>Chapter 9 Discusses:</h3><ul><li>What is IDS</li><li>The Benefits of eBPF IDS</li><li>Avoiding Detection by IDS (for Attackers)</li></ul><h3>What is IDS</h3><p>IDS stands for Intrusion Detection System. It is tasked with obeserving what is happening in a network or filesystem and determining if the behavior it is observing is normal or is an attacker who shouldn’t be in the system at all. Once the system has detected an attacker it can take defensive actions. These actions range from benign things like dumping process memory for later inspection to more severe actions like shutting down a compromised pod.</p><p>There are two main methods that IDS’s use to determine when an intruder has been detected: Signature Detection and Anomaly Detection.</p><p><strong>Signature Detection </strong>relies on knowledge of past attacks that have occurred. In its most basic form this means checking if a binary matches the hash of known malware, but it can also look at other things like patterns in network traffic, suspicious port scans and suspicious patterns in packets.</p><p><strong>Anomaly Detection </strong>doesn’t need to have seen an attack signature previously in order to detect it. This is good because it can potentially prevent a zero day attack. The downside to anomaly detection is false positives. Unexpected behaviour could just be a developer poking around and testing things out. It could even be the normal behaviour of an application. The annoyance of false positives could cause developers and devops to ignore the alerts completely or disable the system. The probability of false positives depends on the accuracy of the IDS, which varies from provider to provider.</p><h3>The Benefits of eBPF IDS</h3><p>eBPF is <em>“A modern and powerful way to extend the Linux kernel”</em> and with its adoption has come solutions to IDS that haven’t been feasible previously. Ideally, IDS should scan every packet and system call to determine what is normal behaviour and what is potentially malicious. An all knowing, all seeing eye on your system. The problem is this incurs a massive overhead and slows down the system. eBPF runs inside the kernel and provides a solution to the overhead problem. eBPF is very fast and was designed with speedy packet handling in mind so naturally its a great solution for IDS.</p><p>One downside of eBPF IDS however is that because it runs inside that kernel as trusted code, it’s a very high value target. Exploiting IDS means not only container breakout but root access on the worker node (because containers in Kubernetes share the host kernel). Still, the benefits are said to outweigh the costs,</p><blockquote>“running in the kernel poses its own set of possible risks, and the eBPF sub-system and JIT compiler have had a number of breakouts, but these are considered less dangerous than slow, incomplete kernel developer tracing solutions or more fallible IDS.” — Page 226</blockquote><p>Here are two IDS solutions for Kubernetes that support eBPF:</p><ul><li><a href="https://cilium.io/">Cillium</a> — <em>“an open source software for providing, securing and observing network connectivity between container workloads — cloud native, and fueled by the revolutionary Kernel technology eBPF.”</em></li><li><a href="https://falco.org/">Falco</a> — <em>“Falco, the cloud-native runtime security project, is the de facto Kubernetes threat detection engine”</em></li></ul><h3>Avoiding Detection by IDS (for Attackers)</h3><p>IDS is fallible and you should not place all of your trust in it. Hackers know that you use IDS and can test their payloads against Signature detection systems to see if they are detected or not. This is a common practice for red teams.</p><p>In Kubernetes, IDS’s work a little differently. Intrusion Detection Systems designed for Kubernetes tend to look at interactions with the API because that is where all the action happens. Kubernetes generates audit logs for every call made to its API and these logs are what IDS systems inspect. Of course, no system is perfect. In 2020, Brad Geesaman and Ian Coldwater demonstrated that it was possible to avoid detection in the audit logs by overloading the logging systems with overly large requests. API calls that are above a certain size don’t get stored in the audit logs and they exploited this behaviour (<a href="https://darkbit.io/blog/future-kubernetes-attacks-rsa-2020">source</a>). While this demonstration was done in a research context, it is public knowledge now and we can expect advanced attackers to abuse this in the future.</p><h3>Conclusion</h3><p>Intrusion detection systems aren’t installed in Kubernetes by default but they are a great idea for any organization looking to improve their security. Of course, installing an IDS isn’t enough. Your organization needs to have a plan to react when a breach has been detected or else there is little use in installing an IDS. The next chapter will be the final chapter of this book and we will discuss more about organizations in relation to Kubernetes Security. If you enjoy these articles, <a href="https://www.youtube.com/playlist?list=PLSGxDsVUZ-zwKQZ6-2dyjjojKADL3j6BE">check out my video series</a> where I discuss each chapter in the book.</p><p><strong>Stay sharp!</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=609338dcb990" width="1" height="1" alt=""><hr><p><a href="https://systemweakness.com/hacking-kubernetes-threat-driven-analysis-and-defense-chapter-9-notes-intrusion-detection-609338dcb990">“Hacking Kubernetes: Threat Driven Analysis and Defense” Chapter 9 Notes: Intrusion Detection</a> was originally published in <a href="https://systemweakness.com/">System Weakness</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[“Hacking Kubernetes: Threat Driven Analysis and Defense” Chapter 8 Notes: Policy]]></title>
            <link>https://systemweakness.com/hacking-kubernetes-threat-driven-analysis-and-defense-chapter-8-notes-policy-6f00d4dfd2f5?source=rss-2c8cbbedc34d------2</link>
            <guid isPermaLink="false">https://medium.com/p/6f00d4dfd2f5</guid>
            <category><![CDATA[kubernetes-security]]></category>
            <category><![CDATA[rbac]]></category>
            <dc:creator><![CDATA[Nico Green]]></dc:creator>
            <pubDate>Thu, 16 Jun 2022 19:20:02 GMT</pubDate>
            <atom:updated>2022-06-30T04:07:22.468Z</atom:updated>
            <content:encoded><![CDATA[<p><em>Prefer videos over articles? </em><a href="https://youtube.com/playlist?list=PLSGxDsVUZ-zwKQZ6-2dyjjojKADL3j6BE"><em>Check out the video book review here</em></a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DpR0dsTh7utnO6He1bOiQQ.jpeg" /></figure><p><strong>Welcome to chapter 8! Policy</strong>. So, Kubernetes is built to be automated. It is built to run just fine with little human intervention and for the most part, cluster security is no exception. For a Kubernetes cluster to be secure it must be configured with security in mind. Policies that limit resource usage, restrict access according to least privilege, and prevent the creation of privileged pods allow us to make our Kubernetes clusters secure. Here we will go over how to define and enforce those policies, as well as how authentication is handled when an API call is made</p><p>Let’s dive in.</p><h3>Intended Audience</h3><ul><li>Anyone who is reading <a href="https://zillionbooksusa.com/books/hacking-kubernetes-threat-driven-analysis-and-defense/">the book</a></li><li>Anyone interested in reading <a href="https://zillionbooksusa.com/books/hacking-kubernetes-threat-driven-analysis-and-defense/">the book</a></li><li>Programmers, Devops, and Cyber Security people who work with Kubernetes and have security in mind</li></ul><p><em>PS: If you like the book, the download the first half for free </em><a href="https://control-plane.io/hackingkubernetes/"><em>here</em></a></p><h3>Chapter 8 Discusses:</h3><ul><li>Authentication in Kubernetes</li><li>Role Based Access Control (RBAC)</li><li>Generic Policy Engines</li></ul><h3>Authentication in Kubernetes</h3><p>In Kubernetes everything happens through calls to the Kubernetes API on the control plane. Using API calls, secrets are pulled, pods are created, and authentication is handled. For every request received from the worker node, the Kubernetes API goes through a process to determine whether to accept the request or deny it. We are going to dive into what that process looks like here:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*l67laJZ6j_-PUjL2ItyMVw.png" /><figcaption>Source: <a href="https://kubernetes.io/docs/concepts/security/controlling-access/">https://kubernetes.io/docs/concepts/security/controlling-access/</a></figcaption></figure><p><strong>Scenario:</strong> A human user or Service account makes an API call from a worker node. What happens when the API call is received from the Kubernetes API?</p><ol><li><strong>Authentication — </strong>During this step the API looks for valid credentials in your request.</li></ol><blockquote>“the first step in the API server is the authentication of the request via one or more of the configured authentication modules such as client certificates, passwords, or Json Web Tokens (JWT’s)” — Page 200</blockquote><p>2. <strong>Authorization — </strong>If authentication is successful, we begin the authorization step. Put simply, the Kubernetes API determines if the role associated with the API call is authorized to do the thing it’s trying to do. This is determined using RBAC.</p><p>3. <strong>Admission Control —</strong> In this step, if an admission controller is present it will inspect the API call and approve or deny it. Admission controllers also have the ability to edit your API call (for example, by enforcing default values for empty fields).</p><p>By understanding how API calls are approved or denied we can understand the controls offered to us in order to keep a cluster safe. Computers get hacked and so do the kubelets running on them. For that reason it makes sense not to blindly accept whatever API calls are coming from the kubelet.</p><h3>Role Based Access Control</h3><blockquote>“Policy is essential to keeping Kubernetes secure, but by default little is enabled. Configuration mutates with time for most software as new features come out; miconfiguration is a common attack vector, and Kubernetes is no different” — Page 194</blockquote><p>The lack of least privilege in Kubernetes is yet another “dangerous, but default” scenario that practitioners should be aware of. There is some nuance here, however. Public cloud providers like AWS and GCP have robust access control options and many great default roles. They have RBAC built in to their Kubernetes offering. Self hosted Kubernetes is different, however, and if you don’t define roles yourself than the “default” service account becomes overprivileged. This is not an ideal security situation.</p><p>Assuming that you have a self hosted Kubernetes cluster and you already have some roles defined, it’s important to look for blind spots in your security. If you are looking to audit your clusters RBAC, here are some tools that will help you do so:</p><p><a href="https://github.com/appvia/krane"><strong>krane</strong></a> — a simple Kubernetes RBAC static analysis tool. It identifies potential security risks in K8s RBAC design and makes suggestions on how to mitigate them.</p><p><a href="https://github.com/jasonrichardsmith/rbac-view"><strong>rbac-view</strong></a> — a great tool to visualize your RBAC permissions</p><h3>Generic Policy Engines</h3><p>Policy can be defined in Kubernetes using a series a roles and role bindings (RBAC) but naturally, there are also higher level ways to handle policy enforcement in Kubernetes. It’s important to note that the old way to handle pod security was “Pod Security Policies” but those have been deprecated. Generic Policy Engines are a great alternative. Here we will discuss two popular Generic Policy Engines in Kubernetes: <em>Open Policy Agent</em> and <em>Kyverno</em>.</p><h4>Open Policy Agent</h4><p><a href="https://www.openpolicyagent.org/">open policy agent</a> allows you to define policy as code. It is a project from the Cloud Native Computing Foundation (CNCF) that uses a high level declarative language called <a href="https://www.openpolicyagent.org/docs/latest/policy-language/">rego</a> to represent all types of policies. One interesting difference in using OPA versus manually creating roles and role-bindings in Kubernetes is that it allows you to decouple the policy decision making from your code. Changes in policy are instead made via calls to the Open Policy Agent API.</p><h4><strong>Kyverno</strong></h4><p><a href="https://kyverno.io/">Kyverno</a>, which also started as a CNCF project, is another option for defining and enforcing policy in Kubernetes. It runs as a dynamic Admission controller, supporting both validating and mutating admission webhooks</p><p><a href="https://neonmirrors.net/post/2021-02/kubernetes-policy-comparison-opa-gatekeeper-vs-kyverno/">Here</a> is a side by side comparison of Open Policy Agent and Kyverno for security policy enforcement in Kubernetes.</p><h3>Conclusion</h3><p>By default a self hosted Kubernetes cluster has no protection from attackers who have landed in a pod. There is no security policy in place by default so it is your responsibility to build it in. While the manual approach to RBAC works fine, using a Generic Policy Engine such as OPA or Kyverno can simplify the defining and enforcement of policies in your cluster. If you enjoy these articles, <a href="https://www.youtube.com/playlist?list=PLSGxDsVUZ-zwKQZ6-2dyjjojKADL3j6BE">check out my video series</a> where I discuss each chapter in the book.</p><p><strong>Stay sharp!</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6f00d4dfd2f5" width="1" height="1" alt=""><hr><p><a href="https://systemweakness.com/hacking-kubernetes-threat-driven-analysis-and-defense-chapter-8-notes-policy-6f00d4dfd2f5">“Hacking Kubernetes: Threat Driven Analysis and Defense” Chapter 8 Notes: Policy</a> was originally published in <a href="https://systemweakness.com/">System Weakness</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[“Hacking Kubernetes: Threat Driven Analysis and Defense” Chapter 7 Notes: Multitenancy]]></title>
            <link>https://systemweakness.com/hacking-kubernetes-threat-driven-analysis-and-defense-chapter-7-notes-multitenancy-1c7d7b822d09?source=rss-2c8cbbedc34d------2</link>
            <guid isPermaLink="false">https://medium.com/p/1c7d7b822d09</guid>
            <category><![CDATA[kubernetes-security]]></category>
            <category><![CDATA[hacking]]></category>
            <dc:creator><![CDATA[Nico Green]]></dc:creator>
            <pubDate>Wed, 15 Jun 2022 15:01:36 GMT</pubDate>
            <atom:updated>2022-06-20T07:52:58.669Z</atom:updated>
            <content:encoded><![CDATA[<p><em>Prefer videos over articles? </em><a href="https://youtube.com/playlist?list=PLSGxDsVUZ-zwKQZ6-2dyjjojKADL3j6BE"><em>Check out the video book review here</em></a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rKVeIdNoQMgGOLunenniAg.jpeg" /></figure><p><strong>Welcome to chapter 7! </strong>Multitenancy. The term multitenancy refers to having multiple tenants sharing resources in a single system. In Kubernetes the system that tenants are sharing is a cluster. The identity of the tenants themselves varies. Tenants can be customers of a cloud computing service, teams within the same company, or developers within the same team (just to name a few). In a perfect world tenants would be completely segregated in their own namespaces. Unfortunately Kubernetes was not built with multitenancy in mind so security issues arise. In this chapter we define soft multitenancy as well as hard multitenancy. We then move on to talking about attacking etcd and attacking the data plane in Kubernetes.</p><p>Let’s dive in.</p><h3>Intended Audience</h3><ul><li>Anyone who is reading <a href="https://zillionbooksusa.com/books/hacking-kubernetes-threat-driven-analysis-and-defense/">the book</a></li><li>Anyone interested in reading <a href="https://zillionbooksusa.com/books/hacking-kubernetes-threat-driven-analysis-and-defense/">the book</a></li><li>Programmers, Devops, and Cyber Security people who work with Kubernetes and have security in mind</li></ul><p><em>PS: If you like the book, the download the first half for free </em><a href="https://control-plane.io/hackingkubernetes/"><em>here</em></a></p><h3>Chapter 7 Discusses:</h3><ul><li>Soft Multitenancy</li><li>Hard Multitenancy</li><li>Attacking etcd</li><li>Attacking the Data Plane</li></ul><h3>Soft Multitenancy</h3><p>Multitenancy comes in two flavors: <strong>Soft Multitenancy</strong> and <strong>Hard Multitenancy. </strong>Soft multitenancy assumes that the tenant on your cluster is somewhat trusted. This means that security concerns are smaller. We don’t need to lock down individual tenants with restrictive policies or esoteric sandboxing techniques. We set up some guardrails so they don’t accidentally use up computing resources from other tenants but we don’t restrict them with over bearing security measures. Soft multitenancy makes tenants happy because less security measures generally means more developer freedom.</p><blockquote>“You should use a soft multitenancy model to prevent avoidable accidents resulting from overprivileged tenants. It is much easier to build and run than hard multitenancy, which we will come to next, because it’s threat model doesn’t consider motivated threat actors” — Page 177</blockquote><h3>Hard Multitenancy</h3><p>Hard multitenancy assumes the worst. It treats every tenant like a skilled hacker who for some reason has been given a shell within a container. In an ideal hard multitenancy scenario, every security measure that Kubernetes offers is used in order to make sure that two tenants on the same cluster can’t see each others data, use each others resources, or break out of their container. It’s difficult to achieve hard multitenancy but sometimes its necessary,</p><blockquote>“This level of separation is required by sensitive and private workloads across industry and state sectors, public compute services, and regulatory and accrediting bodies”.</blockquote><p>How difficult is hard multitenancy? Well obviously the computing giants like AWS, Microsoft Azure, and GCP have been able to pull it off but smaller companies have tried and failed citing security concerns. At the time of writing, katacoda.com is in the process of closing their platform to the public citing the difficulty of securing their free compute platform from hackers wishing to spread malware and plant cryptominers (<a href="https://www.oreilly.com/online-learning/leveraging-katacoda-technology.html">source</a>).</p><p>Hard multitenancy is difficult because you are giving untrusted users the ability to run code in a container. To help understand what is truly at risk, let’s explore some attack scenarios on two high value targets in Kubernetes: <strong>etcd</strong> and the <strong>Data plane</strong></p><h3>Attacking etcd</h3><p>What is <strong>etcd</strong> you ask? Well, put simply it’s just a key:value store that works with distributed systems:</p><blockquote>“Kubernetes uses etcd to store all its data — its configuration data, its state, and its metadata. Kubernetes is a distributed system, so it needs a distributed data store like etcd” (<a href="https://matthewpalmer.net/kubernetes-app-developer/articles/how-does-kubernetes-use-etcd.html#:~:text=Kubernetes%20uses%20etcd%20to%20store,cluster%20read%20and%20write%20data.">source</a>)</blockquote><p>It is the source of truth in Kubernetes! <strong>It is by far the highest value target for an attacker hoping to pwn your cluster. </strong>Changes in etcd become changes in the API which are then manifest in your cluster. Oh, and did I mention it is where secrets are stored?</p><p>While etcd is awesome at what it does, like everything in the computing world it is not <em>totally secure. </em>Depending on the way etcd is hosted in a cluster it can be harder or easier to spot for attackers.</p><p>etcd can be deployed one of three ways:</p><ol><li>On a dedicated cluster of its own</li><li>As systemd units on a k8s control plane</li><li>As a self hosted pod in the cluster.</li></ol><p>The third option is by far the least secure.</p><blockquote>“Hosting etcd as pods inside a kubernetes cluster is the riskiest deployment option : it offers an attacker direct access to etcd on the CNI (container network interface). An accidental Kubernetes RBAC misconfiguration could expose the whole cluster via etcd tampering” — Page 182”</blockquote><p>Of course if as an attacker you can gain root access to the worker node then it doesn’t matter what method was used to deploy etcd,</p><blockquote>“Containers are just processes but the root user on the host is omniscient. They must be able to see everything in order to debug and maintain the system … dumping the strings in a process’ memory space is trivial. All memory is readable by the root user and so unencrypted values in a containers memory are easy to discover” — Page 184</blockquote><h3>Attacking the Dataplane</h3><p>The Dataplane in Kubernetes refers to a worker node and everything inside of it. Here is a diagram to refresh your memory:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EFVRcDVySGtFj4YjKST19w.png" /><figcaption>As you can see the worker node holds some pods and those pods hold some containers.</figcaption></figure><p>As an attacker gaining root access to the node hosting etcd can be a “check mate” move giving you access to etcd, the kube-api, and therefore the whole cluster. This is only the case for gaining root access to the node hosting etcd, however and this is an unlikely scenario.</p><p>Attacking the data plane is more likely to involve attempting to gain root access to a regular worker node with limited access in the cluster. That means more work is necessary to take over the cluster. Still, compromising a worker node is a good position for an attacker to be in, as described here:</p><blockquote>“Kubernetes trusts a worker once it has joined the cluster. If your worker node is hacked, then the kubelet it hosts is compromised, as well as the pods or data the kubelet was running or has access to. All kubelet and workload credentials fall under the attackers control” — Page 187</blockquote><p>Unfortunately, “<em>all kubelet and workload credentials” </em>may not be all the credentials we would like. A compromised kubelet will only give an attacker access to credentials necessary for the workloads on the node to run (assuming least privilege).</p><p>One workaround for this is using the kubelet to trick the API server into scheduling sensitive pods and secrets on the node via relabelling,</p><blockquote>“A compromised kubelet is able to relabel itself by updating its command-line flags and restarting. This may trick the API server into scheduling sensitive pods and secrets on the node” — Page187</blockquote><p>Labels are used by administrators to assign specific workloads to matching kubelet nodes and namespaces (ex: “highly-sensitive”, “top secret”). If you can relabel your kubelet with these sensitive labels, you can trick the API into putting pods associated with the label on the node where you have gained root access. Hijack the label, hijack the cluster!</p><h3>Conclusion</h3><p>Hard multitenancy is… hard. How can you trust users enough to share a cluster? You can’t. But you can try very hard to secure them within their namespace, pod, or other tenant boundary.</p><p>Multitenancy forces organisations to a take a good look at their cluster and ask the question: whats the worst that could happen? When discussing how to target etcd and the data plane in Kubernetes we begin to answer that question. If you enjoy these articles, <a href="https://www.youtube.com/playlist?list=PLSGxDsVUZ-zwKQZ6-2dyjjojKADL3j6BE">check out my video series</a> where I discuss each chapter in the book.</p><p><strong>Stay sharp!</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1c7d7b822d09" width="1" height="1" alt=""><hr><p><a href="https://systemweakness.com/hacking-kubernetes-threat-driven-analysis-and-defense-chapter-7-notes-multitenancy-1c7d7b822d09">“Hacking Kubernetes: Threat Driven Analysis and Defense” Chapter 7 Notes: Multitenancy</a> was originally published in <a href="https://systemweakness.com/">System Weakness</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[“Hacking Kubernetes: Threat Driven Analysis and Defense” Chapter 6 Notes: Storage]]></title>
            <link>https://systemweakness.com/hacking-kubernetes-threat-driven-analysis-and-defense-chapter-6-notes-storage-41fb0242ce02?source=rss-2c8cbbedc34d------2</link>
            <guid isPermaLink="false">https://medium.com/p/41fb0242ce02</guid>
            <category><![CDATA[security]]></category>
            <category><![CDATA[kubernetes]]></category>
            <dc:creator><![CDATA[Nico Green]]></dc:creator>
            <pubDate>Thu, 09 Jun 2022 15:43:10 GMT</pubDate>
            <atom:updated>2022-06-16T15:38:25.903Z</atom:updated>
            <content:encoded><![CDATA[<p><em>Prefer videos over articles? </em><a href="https://youtube.com/playlist?list=PLSGxDsVUZ-zwKQZ6-2dyjjojKADL3j6BE"><em>Check out the video book review here</em></a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yNmGmcG2sEN1pRWJKUTr0g.jpeg" /></figure><p><strong>Welcome to chapter 6! </strong>Storage. This chapter went into the technical aspects of how things are stored in kubernetes as well as how secrets are stored and the security around that. Here I will focus more on how secrets (passwords, service account tokens) are stored in kubernetes and how to steal them. In adopting an attackers mindset we will be able to understand better how to defend kubernetes clusters, as well as attack them during authorized penetration tests.</p><p>Let’s dive in.</p><h3>Intended Audience</h3><ul><li>Anyone who is reading <a href="https://zillionbooksusa.com/books/hacking-kubernetes-threat-driven-analysis-and-defense/">the book</a></li><li>Anyone interested in reading <a href="https://zillionbooksusa.com/books/hacking-kubernetes-threat-driven-analysis-and-defense/">the book</a></li><li>Programmers, Devops, and Cyber Security people who work with Kubernetes and have security in mind</li></ul><p><em>PS: If you like the book, the download the first half for free </em><a href="https://control-plane.io/hackingkubernetes/"><em>here</em></a></p><h3>Key terms in this chapter</h3><ul><li><strong>K8s-Secrets</strong> — from Kubernetes documentation “an object that contains a small amount of sensitive data such as a password, a token, or a key. Such information might otherwise be put in a <a href="https://kubernetes.io/docs/concepts/workloads/pods/">Pod</a> specification or in a <a href="https://kubernetes.io/docs/reference/glossary/?all=true#term-image">container image</a>. Using a Secret means that you don’t need to include confidential data in your application code.</li><li><strong>Service Account</strong> — A special kind of account used by an application or Virtual Machine rather than a person. Applications in kubernetes use service accounts to make authorized API calls.</li><li><strong>Service Account Token</strong> — the “password” that a service account uses to make authorized API calls.</li></ul><h3>Chapter 6 Discusses:</h3><ul><li>What are the Secrets?</li><li>Where are the Secrets?</li></ul><h3>What are the Secrets?</h3><p>So first off, the term <strong>Secrets </strong>in kubernetes slang refers to something specific. It is a type of object used to store sensitive information (like passwords) and it is defined using yaml, like so:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/485/1*psgr6MycSet5ZygZbxEZgA.png" /><figcaption>Ex: secrets.yaml file</figcaption></figure><p>From here on out, we will refer to these as <strong>K8s-Secrets </strong>to avoid confusion. Generally the term secrets is meant to refer to sensitive information: Passwords, API-keys, Service account tokens. The things that as attackers, we want to steal in order to get further into the system and hopefully establish persistence in the cluster. If we steal a mysql user password, we can impersonate that user. If we can impersonate a user, establishing further persistence becomes more likely.</p><p><strong>Service account tokens</strong> are similar to user passwords but not exactly the same. A user password is associated with a username and allows you to authenticate as that user (ex: MySQL username/password), while a service account token allows you to authenticate to a service account. Service accounts are typically used by applications (or pods) and not associated with any one person. More importantly, Service Account Tokens allow you to make authorized API calls. For an attacker this is great news.</p><h3><strong>Where are the Secrets</strong></h3><h4>mounted inside the pod</h4><p>As attackers we can delight in the fact that by default, the default user’s service account token is mounted into the pod. This means that if you manage to compromise a pod there is a good chance no further privilege escalation is needed in order to make authorized API calls. This is due to the automountServiceAccountToken configuration, which is true by default (<a href="https://kubernetes.io/docs/tasks/configure-pod-container/configure-service-account/#use-the-default-service-account-to-access-the-api-server">source</a>).</p><h4><strong>Inside Environment Variables</strong></h4><p>Much like the service account tokens mounted into the pod, other secrets in kubernetes are sometimes hiding in plain sight. When creating a pod manifest developers looking to get a cluster up and running quickly might include usernames, passwords, and API keys that their application relies on in the pod.yaml as environment variables, like so:</p><pre><strong>apiVersion</strong>: v1<br><strong>kind</strong>: Pod<br><strong>metadata</strong>:<br>  <strong>name</strong>: insecure-pod<br>  <strong>labels</strong>:<br>    <strong>purpose</strong>: demonstrate-bad-security<br><strong>spec</strong>:<br>  <strong>containers</strong>:<br>  - <strong>name</strong>: insecure-pod-container<br>    <strong>image</strong>: gcr.io/google-samples/node-hello:1.0<br>    <strong>env</strong>:<br>    - <strong>name</strong>: MYSQL_USER<br>      <strong>value</strong>: &quot;admin&quot;<br>    - <strong>name</strong>: MYSQL_PASSWORD<br>      <strong>value</strong>: &quot;super_long_password_12345667890&quot;</pre><p>While this is obviously very bad for security it is very convenient for developers looking to get a product up and running quickly. It is also great news for us, the attackers who have landed in the pod.</p><h4>In mounted volumes</h4><p>Containerized applications running on kubernetes sometimes claim to be “stateless”. Of course, this just means that any data that they require to continue running is stored elsewhere so that they can be treated as stateless by developers. So then, the question we must ask ourselves as attackers is where is the data being stored?</p><blockquote>“Remember that ‘stateless containers’ don’t want to persist important data to their local filesystem, but they still need inputs and outputs to be useful. State must exist; it’s safer to store it in a database or external system to achieve cloud native benefits like elastic scaling and resilience to failure” — page 153</blockquote><p>The <em>database or external system </em>referred to above would be mounted as a volume in kubernetes. As an attacker who has landed in a pod, it is wise to check what volumes you have access to and what is stored within them. You can see what volumes are attached to a pod by typing kubectl describe pod and looking for the Mounts section.</p><h3>Conclusion</h3><p>Kubernetes is not secure by default. Hopefully by chapter 6 that is abundantly clear! Still, deciding to have a “secure cluster” is not as simple as making a change in one place. Kubernetes has a lot of moving parts and this makes it hard to understand how a misconfiguration in one piece effects the larger system that is a kubernetes cluster. This article highlights some the ways an attacker can steal credentials after landing in a pod. If you enjoy these articles, <a href="https://www.youtube.com/playlist?list=PLSGxDsVUZ-zwKQZ6-2dyjjojKADL3j6BE">check out my video series</a> where I discuss each chapter in the book.</p><p><strong>Stay sharp!</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=41fb0242ce02" width="1" height="1" alt=""><hr><p><a href="https://systemweakness.com/hacking-kubernetes-threat-driven-analysis-and-defense-chapter-6-notes-storage-41fb0242ce02">“Hacking Kubernetes: Threat Driven Analysis and Defense” Chapter 6 Notes: Storage</a> was originally published in <a href="https://systemweakness.com/">System Weakness</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[“Hacking Kubernetes: Threat Driven Analysis and Defense” Chapter 5 Notes: Networking]]></title>
            <link>https://systemweakness.com/hacking-kubernetes-threat-driven-analysis-and-defense-chapter-5-notes-networking-f4d6ea30e94e?source=rss-2c8cbbedc34d------2</link>
            <guid isPermaLink="false">https://medium.com/p/f4d6ea30e94e</guid>
            <category><![CDATA[hacking]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[kubernetes-security]]></category>
            <dc:creator><![CDATA[Nico Green]]></dc:creator>
            <pubDate>Sat, 04 Jun 2022 16:59:54 GMT</pubDate>
            <atom:updated>2022-06-10T08:10:23.201Z</atom:updated>
            <content:encoded><![CDATA[<p><em>Prefer videos over articles? </em><a href="https://youtube.com/playlist?list=PLSGxDsVUZ-zwKQZ6-2dyjjojKADL3j6BE"><em>Check out the video book review here</em></a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YMS7BltK5IIahPfAX9IimA.jpeg" /></figure><p><strong>Welcome to chapter 5! </strong>Networking. As someone interested in penetration testing Kubernetes clusters this has been one of my favorite chapters. When it comes to security, networking defaults in kubernetes present a big issue because pretty much all traffic is allowed by default and traffic is also unencrypted by default. This combined with a flat topology where all pods in a cluster can talk to each other spells disaster.</p><p>Let’s dive in.</p><h3>Intended Audience</h3><ul><li>Anyone who is reading <a href="https://zillionbooksusa.com/books/hacking-kubernetes-threat-driven-analysis-and-defense/">the book</a></li><li>Anyone interested in reading <a href="https://zillionbooksusa.com/books/hacking-kubernetes-threat-driven-analysis-and-defense/">the book</a></li><li>Programmers, Devops, and Cyber Security people who work with Kubernetes and have security in mind</li></ul><p><em>PS: If you like the book, the download the first half for free </em><a href="https://control-plane.io/hackingkubernetes/"><em>here</em></a></p><h3>Chapter 5 Discusses:</h3><ul><li>Dangerous Networking Defaults</li><li>Attacking Kubernetes Networking Defaults</li><li>Defending Attacks Against Networking Defaults</li></ul><h3>Dangerous Networking Defaults</h3><p>In Kubernetes by default pods in the same cluster can talk to each other. That means that if an attacker gains access to a single pod on the cluster pivoting to other pods (and other nodes) is easy. This open communication is great for easy setup of a kubernetes cluster but bad for security. If every pod can talk to every other pod then it doesn’t matter what pod you have landed on as an attacker. As long as you have access to a single pod you can enumerate issues across the entire cluster and chances are you will find a point of privilege escalation. This makes an attackers job pretty easy.</p><blockquote>“In a Kubernetes cluster, by default every pod can see and talk to every other pod. This default is a nightmare from a security perspective (or a free ride, depending on which side your on) and we cannot emphasize enough how dangerous this fact is” — page 128</blockquote><p>It gets worse though: by default, traffic in kubernetes is not encrypted. This increases the likelihood that an attacker within the network will find something interesting, especially in the case of an <strong>ARP spoofing attack.</strong></p><h3>Attacking Kubernetes Networking Defaults</h3><p>In 2019, Liz Rice highlighted a <a href="https://www.youtube.com/watch?v=f-dN8Osm8z0">dismal attack scenario</a> based on Kubernetes defaults in her KubeCon talk titled<strong> </strong><em>“CAP_NET_RAW And ARP Spoofing in Your Cluster: It’s Going Downhill From Here”</em>. In this talk she walks through how ARP and DNS can be used to fool a victim pod into visiting a fake URL. Keep in mind that in the case of a Kubernetes hosted web server this isn’t just an attack on a single employee at a company. This would be a watering hole attack effecting anyone who visits that site (potentially millions of users!). An attack that devastating simply because someone spun up a cluster with default settings is pretty shocking. Let’s talk about how this specific attack could be defended against.</p><h3>Defending Attacks Against Networking Defaults</h3><p>An ARP spoofing attack can be prevented by taking away the CAP_NET_RAW capability. CAP_NET_RAW has a very innocent definiton in the linux man pages</p><blockquote>CAP_NET_RAW</blockquote><blockquote>use RAW and PACKET sockets;</blockquote><blockquote>bind to any address for transparent proxying.</blockquote><p>But don’t let that fool you. As <a href="https://security.stackexchange.com/questions/128958/security-implications-of-using-setcap-cap-net-raw/">this user</a> on security.stackexchange.com sums up for us CAP_NET_RAW has a very different meaning for an attacker:</p><p><em>“Any kind of packet can be forged, which includes faking senders, sending malformed packets, etc., this also allows to bind to any address (associated to the ability to fake a sender this allows to impersonate a device, legitimately used for “transparent proxying” as per the manpage but from an attacker point-of-view this term is a synonym for Man-in-The-Middle)”</em></p><p>Disabling CAP_NET_RAW can be done either by specifying a Pod Security Policy or by adding a securityContext section to your pod yaml. Also if you wish to limit the communication between pods on the cluster you can do so by specifying a Network Policy.</p><h3><strong>Conclusion</strong></h3><p>I’m in a bit of a rush today (forgive me!) so allow me to leave you with a quote from the book. I think it wraps the section up nicely</p><blockquote>“You should never, ever run a Kubernetes cluster without restricting network traffic in some form or shape” — page 129</blockquote><p>If you enjoy these articles, <a href="https://www.youtube.com/playlist?list=PLSGxDsVUZ-zwKQZ6-2dyjjojKADL3j6BE">check out my video series</a> where I discuss each chapter in the book.</p><p>Stay sharp!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f4d6ea30e94e" width="1" height="1" alt=""><hr><p><a href="https://systemweakness.com/hacking-kubernetes-threat-driven-analysis-and-defense-chapter-5-notes-networking-f4d6ea30e94e">“Hacking Kubernetes: Threat Driven Analysis and Defense” Chapter 5 Notes: Networking</a> was originally published in <a href="https://systemweakness.com/">System Weakness</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[“Hacking Kubernetes: Threat Driven Analysis and Defense” Chapter 4 Notes: Applications and Supply…]]></title>
            <link>https://systemweakness.com/hacking-kubernetes-threat-driven-analysis-and-defense-chapter-4-notes-applications-and-supply-691548a42083?source=rss-2c8cbbedc34d------2</link>
            <guid isPermaLink="false">https://medium.com/p/691548a42083</guid>
            <category><![CDATA[hacking]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[devsecops]]></category>
            <category><![CDATA[kubernetes-security]]></category>
            <category><![CDATA[kubernetes]]></category>
            <dc:creator><![CDATA[Nico Green]]></dc:creator>
            <pubDate>Mon, 30 May 2022 19:11:15 GMT</pubDate>
            <atom:updated>2022-06-03T15:26:59.590Z</atom:updated>
            <content:encoded><![CDATA[<h3>“Hacking Kubernetes: Threat Driven Analysis and Defense” Chapter 4 Notes: Applications and Supply Chain</h3><p><em>Prefer videos over articles? </em><a href="https://youtube.com/playlist?list=PLSGxDsVUZ-zwKQZ6-2dyjjojKADL3j6BE"><em>Check out the video book review here</em></a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ylKki_tUzJ5IN7yu0Whgiw.jpeg" /><figcaption>Chapter 4: Applications and Supply Chain Notes by Mrintern</figcaption></figure><p><strong>Welcome to chapter 4!</strong> Applications and Supply Chain. In this chapter we are going to talk about the supply chain threat to kubernetes clusters. Historically companies have focused on securing their own networks, applications and containers but ignored the supply chain threat. This is no longer acceptable as supply chain attacks are on the rise (see: <a href="https://www.sans.org/blog/what-you-need-to-know-about-the-solarwinds-supply-chain-attack/">Solar Winds supply chain attack</a>). <strong>Securing the kubernetes supply chain is hard </strong>but its necessary, especially if your company supplies code to other companies.</p><p>Let’s dive in.</p><h3>Intended Audience</h3><ul><li>Anyone who is reading <a href="https://zillionbooksusa.com/books/hacking-kubernetes-threat-driven-analysis-and-defense/">the book</a></li><li>Anyone interested in reading <a href="https://zillionbooksusa.com/books/hacking-kubernetes-threat-driven-analysis-and-defense/">the book</a></li><li>Programmers, Devops, and Cyber Security people who work with Kubernetes and have security in mind</li></ul><p><em>PS: If you like the book, the download the first half for free </em><a href="https://control-plane.io/hackingkubernetes/"><em>here</em></a></p><h3>Key terms in this chapter</h3><ul><li><strong>Kubernetes Supply Chain</strong> — All of the code written by other people but used in your cluster. More on this later</li><li><strong>SBOM</strong> — Software bill of materials. A list of all the third party components and open source components present in a codebase</li><li><strong>Typosquatting</strong> — a type of supply chain attack that relies on developers misspelling names of dependencies</li></ul><h3>Chapter 4 Discusses:</h3><ul><li>The SolarWinds Supply Chain Attack</li><li>What’s in the Kubernetes Supply Chain?</li><li>Attacking the Supply Chain</li><li>Defending the Supply Chain</li></ul><h3>The SolarWinds Supply Chain Attack</h3><p>The SolarWinds supply chain attack was one of the most notable cyber attacks in the history of the United States. The US government has one of the largest (if not the largest) national defense budgets in the world yet it wasn’t enough to prevent an intrusion. Malicious hackers will always take the path of least resistance and for the US Government that was their supply chain security.</p><p>The threat of being hacked through the supply chain is a difficult one to cope with because it involves so many different parties. It’s not enough to secure your own systems to prevent a supply chain attack because the attack happens upstream: <em>In the systems of the companies who supply code to you.</em></p><p>The SolarWinds attack which infected the US Government targeted SolarWinds build pipelines. Build pipelines are typically a high value target for attackers because they touch production code but typically aren’t secured like production systems. In other words, they are a security blind spot.</p><blockquote>“The SUNBURST attack infected SolarWinds build pipelines and altered source code immediately before it was built, then hid the evidence of tampering and ensured the binary was signed by the CI/CD system so consumers would trust it” — page 89</blockquote><h3>What’s in the Kubernetes Supply Chain?</h3><p>Any supply chain consists of all the parties necessary to produce your product. In the case of a fast food restaurant the supply chain consists of farmers, transportation, maybe a packaging facility, and fast food workers. All of these parties are necessary for you to receive your food when rolling up into the Drive-Thru.</p><p>The “parties” involved in the production of a Kubernetes cluster consist of:</p><ul><li>The base image(s)</li><li>Installed operating system packages</li><li>Application code and dependencies</li><li>Public Git repositories</li><li>Open source artifacts</li><li>Arbitrary files</li><li>Any other data that may be added</li></ul><p>As you can see, it’s a lot. Given every Kubernetes cluster involves so much of other peoples code there are a lot of potential points of intrusion. For this reason it makes sense think of your pods as “compromised by default” and construct a security strategy from that perspective.</p><blockquote>“Each dependency you use is potentially a malicious implant primed to trigger, awaiting a spark of execution when it’s run in your systems to deploy its payload” — page 91</blockquote><h3>Attacking the Supply Chain</h3><p>From an attackers perspective supply chain attacks have a rather large effect compared to their little effort. Not all supply chain attacks are as sophisticated as the SolarWinds attack. <strong>Typosquatting</strong> for example requires little to no computer knowledge. Typosquatting is when a malicious actor will register a package with a similar name to a popular package and wait for developers to accidentally download the package by misspelling the name. The malicious package that accidentally gets downloaded contains malware such as a cryptominer or a reverse shell that connects to a machine controlled by the attacker. Typosquatting also exists for other dependencies, like container images.</p><p>To understand the full attack surface of a dependency downloaded through a package manager check out the graph below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/599/1*Gz2BkkI8rHphulsawyUSvQ.png" /><figcaption>Figure 4–8. Simplified relationships of stakeholders and threats in the package manager ecosystem (source: “Towards Measuring Supply Chain Attacks on Package Managers for Interpreted Languages”)</figcaption></figure><p>A <a href="https://alrawi.github.io/static/papers/supply-chain-NDSS21.pdf">recent study</a> on measuring supply chain attacks on package managers highlights that typosquatting is easy, common, and not immediately fixed:</p><blockquote>The paper summarises that:</blockquote><blockquote>- Typosquatting and account compromise are low-cost to an attacker, and are the most widely exploited attack vectors.</blockquote><blockquote>- Stealing data and dropping backdoors are the most common malicious post-exploit behaviors, suggesting wide consumer targeting.</blockquote><blockquote>- 20% of identified malwares have persisted in package managers for over 400 days and have more than 1K downloads.</blockquote><blockquote>- New techniques include code obfuscation, multistage payloads, and logic bombs to evade detection. — page 118</blockquote><h3>Defending the Supply Chain</h3><p>Hopefully by now you’re convinced that supply chain threats to kubernetes clusters are real. The good news is you can put processes in place to defend from all but the most skilled attackers (99.9%, not bad). Of course, as an organization you’ll need to decide what your appetite for risk is and strike a balance between freedom and security. Here are some ways to protect from supply chain threats more or less organized from easiest to implement to hardest to implement.</p><ol><li>Scanning container images and Git repositories for CVE’s <em>(every organization should be doing this)</em></li><li>Integrating the results of these scans into the software development life cycle so you can act on them as an organization</li><li>Generate and distribute SBOM’s so consumers of your software can verify your dependency chain for new vulnerabilities</li><li>Sign your build artifacts with cosign, Notary, and in-toto during CI/CD, then validate their signatures whenever they are consumed</li><li>Adopt the <a href="https://slsa.dev/spec/v0.1/levels">SLSA</a> framework for securing the supply chain and reach level 4</li></ol><h3>Conclusion</h3><p>The topic of supply chain security can be frustrating because the threat surface is gigantic and there is no perfect solution. It is debatable whether it is possible to completely secure the supply chain at all. Rather than giving up, take this as an opportunity to realize that the threat of intrusion is real and configure your pods to withstand that threat. Even if your organization isn’t being targeted directly you may be within the blast radius of a supply chain attack. If your company supplies code to others, hopefully this is a wake up call to realize you are a high value target and you should take security very seriously. I leave you with this quote by Liz Rice, author of<em> Container Security</em>:</p><blockquote>“It’s very likely that a deployment of any non trivial software will include some vulnerabilities, and there is a risk that systems will be attacked through them. To manage this risk you need to be able to identify which vulnerabilities are present and assess their severity, prioritize them, and have processes in place to fix or mitigate these issues”</blockquote><p>If you enjoy these articles, <a href="https://www.youtube.com/playlist?list=PLSGxDsVUZ-zwKQZ6-2dyjjojKADL3j6BE">check out my video series</a> where I discuss each chapter in the book.</p><p>Stay sharp!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=691548a42083" width="1" height="1" alt=""><hr><p><a href="https://systemweakness.com/hacking-kubernetes-threat-driven-analysis-and-defense-chapter-4-notes-applications-and-supply-691548a42083">“Hacking Kubernetes: Threat Driven Analysis and Defense” Chapter 4 Notes: Applications and Supply…</a> was originally published in <a href="https://systemweakness.com/">System Weakness</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[“Hacking Kubernetes: Threat Driven Analysis and Defense” Chapter 3 Notes: Container Runtime…]]></title>
            <link>https://systemweakness.com/hacking-kubernetes-threat-driven-analysis-and-defense-chapter-3-notes-container-runtime-49b799cc2b9b?source=rss-2c8cbbedc34d------2</link>
            <guid isPermaLink="false">https://medium.com/p/49b799cc2b9b</guid>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[hacking-kubernetes]]></category>
            <category><![CDATA[kubernetes-security]]></category>
            <category><![CDATA[hacking]]></category>
            <dc:creator><![CDATA[Nico Green]]></dc:creator>
            <pubDate>Wed, 25 May 2022 12:57:45 GMT</pubDate>
            <atom:updated>2022-06-03T15:26:43.532Z</atom:updated>
            <content:encoded><![CDATA[<h3>“Hacking Kubernetes: Threat Driven Analysis and Defense” Chapter 3 Notes: Container Runtime Isolation</h3><p><em>Prefer videos over articles? </em><a href="https://youtube.com/playlist?list=PLSGxDsVUZ-zwKQZ6-2dyjjojKADL3j6BE"><em>Check out the video book review here</em></a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4jl6VxAldj-eZ3IG7XGkyQ.jpeg" /><figcaption>Chapter 3: Container Runtime Isolation Notes by Mrintern</figcaption></figure><p><strong>Welcome to chapter 3!</strong> Container Runtime Isolation. The name of this chapter is a bit misleading as its mostly about host kernel isolation; But I digress. This chapter is not for the faint of heart. It goes deep on a lot of things we usually only think about in passing. Virtual machines, containers, and the Linux Kernel all mix, mingle and intertwine in this chapter. One thing is for sure: we are learning how to attack and defend kubernetes.</p><p>Let’s dive in.</p><h3>Intended Audience</h3><ul><li>Anyone who is reading <a href="https://zillionbooksusa.com/books/hacking-kubernetes-threat-driven-analysis-and-defense/">the book</a></li><li>Anyone interested in reading <a href="https://zillionbooksusa.com/books/hacking-kubernetes-threat-driven-analysis-and-defense/">the book</a></li><li>Programmers, Devops, and Cyber Security people who work with Kubernetes and have security in mind</li></ul><p><em>PS: If you like the book, the download the first half for free </em><a href="https://control-plane.io/hackingkubernetes/"><em>here</em></a></p><h3><strong>Key terms in this chapter</strong></h3><ul><li><strong>Virtual machine</strong> — abbreviated as VM.</li><li><strong>Host </strong>— the bare metal computer. The computer running the VM, micro VM, or container.</li><li><strong>Kernel</strong> — The kernel is “ the core of an operating system and the interface between software and hardware”. For the purposes of this article, whats important is that we want to protect the host kernel.</li><li><strong>Host Kernel</strong> — the Kernel running on the Host. This is the thing we really, really want to protect as it can access anything and alter anything.</li><li><strong>Guest Kernel </strong>— a dedicated kernel running on a VM</li><li><strong>Sandboxing</strong> — general term for approaches to isolating the kernel. Specifically alternative approaches (not containers, not vanilla VM’s)</li><li><strong>MicroVM </strong>— The definition for Micro-VM’s varies widely. One definition is a sandboxing technique much like a VM but without a dedicated operating system. A lightweight VM used solely for the purpose of securing whats inside through isolation.</li></ul><h3><strong>Chapter 3 </strong>Discusses:</h3><ul><li>When to consider isolating your workloads</li><li>The problem with containers</li><li>The sandboxing solutions available</li></ul><h3>The end of container breakout?</h3><p>This chapter goes to the heart of the problem: <strong>how can we run code we don’t trust on hosts we need to protect?</strong> There are solutions in place, but at the moment only the big tech companies are using them in production (public cloud providers). This is bleeding edge stuff for very specific use cases where security is extremely important. Much of the solutions proposed for securing your workloads haven’t been widely adopted but could give a peek into the future of securing containers and computers in general.</p><h3><strong>When to Consider Isolating your Workloads</strong></h3><p>Isolating a workload adds time to the maintenance of that workload. Just like wrapping a knight in metal armor slows themdown, wrapping a container in a microVM (more on this later) slows down the debugging process. Each new piece of technology is a new possible point of failure. Still, sometimes security is much more important than availability or maintenance cost. <strong>It depends on the use case. </strong>So how do you know when its time to look into isolating your container?</p><blockquote>“You have two main reasons for isolating a workload or pod — it may have access to sensitive information and data, or it may be untrusted and potentially hostile to other users of the syste<em>m” Page 60</em></blockquote><p>In the case of<em> sensitive workloads</em> the data or code is too important to permit unauthorized access. Think an app that handles credit card info, social security numbers, or fraud detection systems.</p><p><em>Untrusted workloads </em>don’t contain sensitive information but may contain malware. Think: CI/CD pipelines subject to supply chain attacks at build-time or any other time there is arbitrary code running on servers that you own.</p><h3>The Problem with Containers</h3><p>Kubernetes is not secure by default, that much is clear from the previous chapters. But why is it that the things that happen in containers effect the host that the container is running on? <strong>Because containers share a kernel with the host. </strong>This makes containers fast to deploy. This speed is one of the main reasons they are vastly more popular than using virtual machines for everything. Of course, your application inside the container thinks it has its own operating system, network and kernel, but it doesn’t. This is all virtualized.</p><p>Virtual machines are slower because they virtualize less things. If you run your application in a VM, your app won’t know the difference between the VM and a bare metal computer. But a VM really has its own operating system and kernel, only the hardware in a VM is virtualized. This makes a VM slower than a container but it also makes it much more secure. <strong>Because a VM has its own dedicated kernel, the guest kernel, it protects the host kernel from attack. </strong>Containers don’t offer this protection.</p><blockquote>“Containers talk directly to the host kernel, but the layers of LSM’s, capabilities, and namespaces ensure they do not have full host kernel access. Conversely, instead of sharing one kernel, VM’s use a guest kernel (a dedicated kernel running in a hypervisor). This means if the VM’s guest kernel is compromised, more work is required to break out of the hypervisor and into the host” page 67</blockquote><p>Here is a graph that might help.</p><p>In the example below the virtual machine software being used is the Linux KVM (kernel virtual machine). Notice how the guest kernel never talks directly to the host kernel.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/283/1*bVqqoALOyZHqnSinVRMuNw.png" /></figure><p>So, we know virtual machines are more secure. But they are also really slow, which puts us right back where we started (containers win). However, sandboxing solutions have popped up to deal with this issue, making use of a new class of VM’s called MicroVM’s.</p><h3>The Sandboxing Solutions Available</h3><blockquote>“Sandboxes combine the best of virtualization and containers isolation to optimize for specific use cases”</blockquote><p>Honestly, this section wasn’t my favorite. The internals of each sandboxing solution aren’t my peak interest and I feel like we are delving pretty far away from our original topic: hacking kubernetes; But I digress. The three main sandboxing solutions talked about in the book are <strong>gVisor</strong>, <strong>Firecracker</strong>, and <strong>Kata Containers</strong>. Here I will discuss gVisor in detail:</p><p>gVisor was built by google to allow untrusted customer supplied workloads to run on GCP products (it actually still secures GCP today!). A container with gVisor wrapped around it doesn’t expose the host kernel directly via system calls. It actually interrupts system calls made by the guest and handles them using an internal tool called Sentry. By proxying system calls made by the guest, the host kernel is protected.</p><p><em>But wait! What if someone develops a 0-day exploit for Sentry!</em></p><blockquote>“Sentry… has a SECCOMP profile that limits its possible host system calls. This helps prevent escalation in case a tenant breaks into Sentry and attempts to attack the host kernel” page 79</blockquote><p>So yeah, it’s pretty secure. Unhackable? Well, nothing is really. But when the attack cost is sufficiently high people tend to seek lower hanging fruit.</p><h3><strong>Conclusion</strong></h3><p>Sandboxing technologies are not widely used right now and new technologies usually introduce new classes of bugs, so proceed with caution! Still, knowing about technologies that are on the horizon is a great thing in a field that’s always changing. It puts you ahead of the curve and lets you see current technologies with more perspective. If you enjoy these articles, <a href="https://www.youtube.com/playlist?list=PLSGxDsVUZ-zwKQZ6-2dyjjojKADL3j6BE">check out my video series</a> accompanying these articles where I discuss each chapter in the book</p><p>Stay sharp!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=49b799cc2b9b" width="1" height="1" alt=""><hr><p><a href="https://systemweakness.com/hacking-kubernetes-threat-driven-analysis-and-defense-chapter-3-notes-container-runtime-49b799cc2b9b">“Hacking Kubernetes: Threat Driven Analysis and Defense” Chapter 3 Notes: Container Runtime…</a> was originally published in <a href="https://systemweakness.com/">System Weakness</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[“Hacking Kubernetes: Threat Driven Analysis and Defense” Chapter 2 Notes: Pod Level Resources]]></title>
            <link>https://systemweakness.com/hacking-kubernetes-threat-driven-analysis-and-defense-chapter-2-notes-pod-level-resources-e109eb66de7a?source=rss-2c8cbbedc34d------2</link>
            <guid isPermaLink="false">https://medium.com/p/e109eb66de7a</guid>
            <category><![CDATA[kubernetes-security]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[hacking-kubernetes]]></category>
            <category><![CDATA[hacking]]></category>
            <dc:creator><![CDATA[Nico Green]]></dc:creator>
            <pubDate>Fri, 20 May 2022 22:04:00 GMT</pubDate>
            <atom:updated>2022-06-03T15:26:27.314Z</atom:updated>
            <content:encoded><![CDATA[<p><em>Prefer videos over articles? </em><a href="https://youtube.com/playlist?list=PLSGxDsVUZ-zwKQZ6-2dyjjojKADL3j6BE"><em>Check out the video book review here</em></a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Xx0QHn5G3xuayi9LUCjqdw.jpeg" /><figcaption>Hacking Kubernetes Ch 2 Review (Pod-level Resources)</figcaption></figure><p>Welcome to chapter 2! By far the most important chapter of the book, <strong>pod-level resources</strong>. If you don’t know how to secure or attack a pod this chapter will definitely tell you some ways (all of them, actually). <em>Kubernetes is not secure by default</em> but it does provide some very good configurations for limiting what an attacker can do once a pod is compromised.</p><p>Most attack scenarios in kubernetes start with a compromised pod, but what happens next? What are a blue teams options for damage control? And how may an attacker compromise a pod in the first place?</p><p>Lets dig in.</p><h4>Intended Audience</h4><ul><li>Anyone who is reading <a href="https://zillionbooksusa.com/books/hacking-kubernetes-threat-driven-analysis-and-defense/">the book</a></li><li>Anyone interested in reading <a href="https://zillionbooksusa.com/books/hacking-kubernetes-threat-driven-analysis-and-defense/">the book</a></li><li>Programmers, Devops, and Cyber Security people who work with Kubernetes and have security in mind</li></ul><p><em>PS: If you like the book, the download the first half for free </em><a href="https://control-plane.io/hackingkubernetes/"><em>here</em></a></p><p><strong>Key terms in this chapter</strong></p><ul><li>Pod</li><li>Node</li><li>securityContext</li><li>Pod Configuration (pod.yaml)</li></ul><p><em>PS: If you like the book, buy it </em><a href="https://zillionbooksusa.com/books/hacking-kubernetes-threat-driven-analysis-and-defense/"><em>here</em></a><em> instead of on amazon :)</em></p><p><strong>Chapter 2 </strong>goes into:</p><ul><li>What is a pod?</li><li>Pod-level threats</li><li>Breaking into the pod</li><li>Post-exploitation Damage control</li></ul><blockquote>“This chapter concerns the atomic unit of a Kubernetes deployment: a pod. Pods run apps and an app may be one or more containers working together in one or more pods”</blockquote><blockquote>page 15</blockquote><p>When it comes to kubernetes, diagrams help a lot. So here is a very basic one:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*O-2b2LDbFPjNgwah2d-aPg.png" /></figure><p>The<strong> Node</strong> is a physical (or virtual) computer. Pods run apps (ex: web servers) and each app exists in a single container. Pods each have their own IP address and Network namespace so from the perspective of an attacker who lands in a pod, it may look like you are in a normal Unix workstation but you are not. The goal of an attacker who lands in a pod (or more specifically, a container) is to break out and access the Node.</p><h4>Pod-level threats</h4><p>Wherever there is user supplied input, there is security risk. In the case of attacking or securing kubernetes the “user” is putting things at risk is often developers, and the “input” is container images and pod configuration. Container images (even popular ones!) have historically had vulnerabilities associated with them (<a href="https://snyk.io/blog/top-ten-most-popular-docker-images-each-contain-at-least-30-vulnerabilities/">source</a>) and pod’s that are lazily configured make container breakout scary easy.</p><p>Lets look a little at how attackers go about hacking your pods.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/836/1*EWSafkg-UtNpvff-tkLqIQ.png" /></figure><p>At the risk of throwing too much information at you at once, above you will find the entire <strong>Kubernetes Threat Matrix</strong> (updated March 2021). For this section, pay attention to the first two columns:<strong> Initial Access</strong> and <strong>Execution</strong>. These illuminate the most popular ways attackers are breaking into Pods in Kubernetes environments. Pod-level security can be thought of as making sure they don’t get to the next columns, <strong>Persistence </strong>and<strong> Privilege Escalation</strong></p><h4>Breaking into the Pod</h4><blockquote>“Your first goal of Kubernetes and pod security should be to prevent RCE (remote code execution), which could be as simple as a <strong>kubectl exec </strong>or as complex as a reverse shell”</blockquote><blockquote>page 18</blockquote><p>So, while it would be nice to assume no unauthorized person could ever execute code on a computer that isn’t theirs (RCE), it happens every day. So let’s enumerate some ways that this happens in the context of a Kubernetes Pod and how to defend against them:</p><ul><li><strong>ATTACK:</strong> A Developer is tricked into entering their credentials into a fake login portal, giving an attacker their cloud credentials</li><li><strong>DEFENSE:</strong> tough to defend against, but “phishing awareness” training is a start</li><li><strong>ATTACK:</strong> A developer uses a container image from a public container registry that contains vulnerabilities. The container hosts a webserver and the CVE is immediately noticed by mass vulnerability scanning script kiddies</li><li><strong>DEFENSE:</strong> Static vulnerability analysis of container images used in production. If your container contains vulnerabilities that can be detected by mass scanners make sure you find them before the script kiddies do.</li><li><strong>ATTACK:</strong> a developer includes a typo in the container name they specify, falling prey to a <strong>typo squatting attack</strong>. They never notice because the container image they pull works perfectly fine in production (but also launches a reverse shell to a remote server owned by the attacker)</li><li><strong>DEFENSE: </strong><a href="https://typosquatting.whoisxmlapi.com/">some databases exist</a> to help create a blacklist of resource names to prevent the accidental use of malicious container images. However, statically analyzing your containers for malware as a part of your CI/CD pipeline is another way to prevent a successful typo squatting attack from making its way into production.</li></ul><h4>Post-exploitation Damage control</h4><p>Whether you are on the Red team trying to establish persistence or on the Blue team trying to defend the kubernetes cluster, it is good to know how pod security (or insecurity) works.</p><p>Here we assume the pod is hacked. This is definitely not end game for the Red team or “Game Over” for the Blue team. Actually its just the beginning of the journey.</p><blockquote>“After gaining RCE into a running pod, the securityContext is the first line of defense”</blockquote><blockquote>page 50</blockquote><p>The s<a href="https://kubernetes.io/docs/tasks/configure-pod-container/security-context/">ecurityContext</a> defines the capabilities available to a pod and the containers it holds. It is a really robust tool for defining security boundaries, but only if you use it correctly. Here is an example of a pod configuration file that specifies a securityContext:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/430/1*XJ5oxLJLttgICs2QdI9OWw.png" /></figure><p>Notice the last line, “allowPrivilegeEscalation: false”. Preventing privilege escalation can be that simple if you know how to use the securityContext. This prevents any process from running with root privileges, period, preventing both known and unknown privilege escalation vectors in your pod. It is absolute.</p><p>Now here is another example of a security context, one that is quite scary:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/308/1*3iUR4SOgvoH_ojw4m_FcZA.png" /><figcaption>container running in privileged mode</figcaption></figure><p>What you see above is the most perfect example of a security context being badly configured. While running a container as privileged might make a developers life easier (if the container is privileged, there is no need to worry about what it can or can’t do. It has no privilege restrictions) it has grave security implications.</p><blockquote>“The privileged flag was quoted as being ‘the most dangerous flag in the history of computing’ by Liz Rice, but why are privileged containers so dangerous? Because they leave the process namespace enabled to give the illusion of containerization, but actually disable all security features”</blockquote><blockquote>page 51</blockquote><p>If you want to get a good idea of where your pod security stands, try<strong> </strong><a href="https://kubesec.io/"><strong>kubesec</strong></a><strong>.</strong> It takes your pod.yaml as input and outputs security recommendations related to every field, including your securityContext.</p><p><strong>Conclusion</strong></p><p>We’ve really just scratched the surface when it comes to attacking and securing pods. This chapter goes into much more like AppArmor, Seccomp profiles, Resource limits, individual fields in the securityContext and how they can be abused if misconfigured. Still, hopefully you found this information helpful. If enjoy these articles, <a href="https://www.youtube.com/playlist?list=PLSGxDsVUZ-zwKQZ6-2dyjjojKADL3j6BE">check out my video series</a> accompanying these articles where I talk about each chapter in the book</p><p>Stay sharp!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e109eb66de7a" width="1" height="1" alt=""><hr><p><a href="https://systemweakness.com/hacking-kubernetes-threat-driven-analysis-and-defense-chapter-2-notes-pod-level-resources-e109eb66de7a">“Hacking Kubernetes: Threat Driven Analysis and Defense” Chapter 2 Notes: Pod Level Resources</a> was originally published in <a href="https://systemweakness.com/">System Weakness</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>