<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>ahmets.io Blog</title><link>https://ahmets.io/blog/</link><description>Articles on cloud security, container security, and DevSecOps by Ahmet Kulekci.</description><generator>Hugo</generator><language>en</language><lastBuildDate>Sun, 22 Nov 2026 18:10:36 +0300</lastBuildDate><atom:link href="https://ahmets.io/blog/index.xml" rel="self" type="application/rss+xml"/><item><title>Container Security Red Team Notes - II</title><link>https://ahmets.io/blog/container-security-red-team-notes-2/</link><pubDate>Wed, 19 Nov 2025 01:00:00 +0300</pubDate><guid>https://ahmets.io/blog/container-security-red-team-notes-2/</guid><description>&lt;p>This is the second part of the Container Security Red Team Notes series. In this post, we will focus on privilege escalation, lateral movement, and persistence within a Kubernetes cluster.&lt;/p>
&lt;h2 id="3-privilege-escalation--lateral-movement" tabindex="-1">3. Privilege Escalation &amp;amp; Lateral Movement&lt;a class="heading-anchor" href="#3-privilege-escalation--lateral-movement" aria-label="Permalink to 3. Privilege Escalation &amp;amp; Lateral Movement">#&lt;/a>&lt;/h2>
&lt;h3 id="service-accounts" tabindex="-1">Service Accounts&lt;a class="heading-anchor" href="#service-accounts" aria-label="Permalink to Service Accounts">#&lt;/a>&lt;/h3>
&lt;p>Kubernetes mounts a service account token at &lt;code>/var/run/secrets/kubernetes.io/serviceaccount/token&lt;/code>. If this account has excessive permissions (like &lt;code>cluster-admin&lt;/code>), it can be used to take over the cluster.&lt;/p>
&lt;figure class="code-block">
 &lt;figcaption class="code-lang">bash&lt;/figcaption>
 &lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-bash" data-lang="bash">&lt;span class="line">&lt;span class="cl">&lt;span class="c1"># Check permissions with kubectl (if installed)&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">kubectl auth can-i --list&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>
&lt;/figure>
&lt;h3 id="cloud-metadata-services" tabindex="-1">Cloud Metadata Services&lt;a class="heading-anchor" href="#cloud-metadata-services" aria-label="Permalink to Cloud Metadata Services">#&lt;/a>&lt;/h3>
&lt;p>If the cluster is running on a cloud provider (AWS, Azure, GCP), the instance metadata service might be accessible from the pod.&lt;/p>
&lt;figure class="code-block">
 &lt;figcaption class="code-lang">bash&lt;/figcaption>
 &lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-bash" data-lang="bash">&lt;span class="line">&lt;span class="cl">&lt;span class="c1"># AWS Metadata&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">curl http://169.254.169.254/latest/meta-data/iam/security-credentials/&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>
&lt;/figure>
&lt;h2 id="4-persistence" tabindex="-1">4. Persistence&lt;a class="heading-anchor" href="#4-persistence" aria-label="Permalink to 4. Persistence">#&lt;/a>&lt;/h2>
&lt;p>Persistence can be achieved by deploying malicious pods, creating backdoored images, or modifying cluster configurations (e.g., ValidatingAdmissionWebhooks).&lt;/p>
&lt;h3 id="malicious-admission-controllers" tabindex="-1">Malicious Admission Controllers&lt;a class="heading-anchor" href="#malicious-admission-controllers" aria-label="Permalink to Malicious Admission Controllers">#&lt;/a>&lt;/h3>
&lt;p>An attacker with sufficient privileges can deploy a MutatingAdmissionWebhook that injects a sidecar container into every new pod, allowing them to intercept traffic or execute commands.&lt;/p>
&lt;h3 id="shadow-api-server" tabindex="-1">Shadow API Server&lt;a class="heading-anchor" href="#shadow-api-server" aria-label="Permalink to Shadow API Server">#&lt;/a>&lt;/h3>
&lt;p>Creating a static pod manifest on a control plane node can launch a rogue API server or a privileged pod that persists even after the original entry point is closed.&lt;/p>
&lt;h2 id="conclusion" tabindex="-1">Conclusion&lt;a class="heading-anchor" href="#conclusion" aria-label="Permalink to Conclusion">#&lt;/a>&lt;/h2>
&lt;p>Container security requires a defense-in-depth approach. Securing the supply chain, hardening the runtime environment, and monitoring for anomalous behavior are key to preventing these attacks.&lt;/p></description></item><item><title>Container Security Red Team Notes - I</title><link>https://ahmets.io/blog/container-security-red-team-notes/</link><pubDate>Wed, 19 Nov 2025 00:00:00 +0300</pubDate><guid>https://ahmets.io/blog/container-security-red-team-notes/</guid><description>&lt;p>Container security is a critical aspect of modern cloud-native environments. As a Red Teamer, understanding how to exploit containerized applications and the underlying orchestration platforms (like Kubernetes) is essential for identifying vulnerabilities and improving security posture.&lt;/p>
&lt;p>This post serves as the first part of a collection of notes and techniques for assessing container security, focusing on initial access and container breakout.&lt;/p>
&lt;h2 id="1-initial-access" tabindex="-1">1. Initial Access&lt;a class="heading-anchor" href="#1-initial-access" aria-label="Permalink to 1. Initial Access">#&lt;/a>&lt;/h2>
&lt;p>Initial access to a containerized environment often starts with compromising a running container or gaining access to the cluster API.&lt;/p>
&lt;h3 id="vulnerable-applications" tabindex="-1">Vulnerable Applications&lt;a class="heading-anchor" href="#vulnerable-applications" aria-label="Permalink to Vulnerable Applications">#&lt;/a>&lt;/h3>
&lt;p>Web applications running inside containers are susceptible to the same vulnerabilities as traditional applications (SQLi, RCE, SSRF). However, successful exploitation lands the attacker inside a container, which is a restricted environment.&lt;/p>
&lt;h3 id="misconfigured-kubelet" tabindex="-1">Misconfigured Kubelet&lt;a class="heading-anchor" href="#misconfigured-kubelet" aria-label="Permalink to Misconfigured Kubelet">#&lt;/a>&lt;/h3>
&lt;p>If the Kubelet API is exposed (port 10250) and allows anonymous access, an attacker can run commands inside containers.&lt;/p>
&lt;figure class="code-block">
 &lt;figcaption class="code-lang">bash&lt;/figcaption>
 &lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-bash" data-lang="bash">&lt;span class="line">&lt;span class="cl">&lt;span class="c1"># Check if Kubelet allows anonymous access&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">curl -k https://&amp;lt;node-ip&amp;gt;:10250/pods&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>
&lt;/figure>
&lt;h2 id="2-container-breakout" tabindex="-1">2. Container Breakout&lt;a class="heading-anchor" href="#2-container-breakout" aria-label="Permalink to 2. Container Breakout">#&lt;/a>&lt;/h2>
&lt;p>Once inside a container, the goal is often to escape to the host node.&lt;/p>
&lt;h3 id="privileged-containers" tabindex="-1">Privileged Containers&lt;a class="heading-anchor" href="#privileged-containers" aria-label="Permalink to Privileged Containers">#&lt;/a>&lt;/h3>
&lt;p>Privileged containers have access to all devices on the host and bypass many security restrictions.&lt;/p>
&lt;figure class="code-block">
 &lt;figcaption class="code-lang">bash&lt;/figcaption>
 &lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-bash" data-lang="bash">&lt;span class="line">&lt;span class="cl">&lt;span class="c1"># Check if running as privileged&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">capsh --print&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>
&lt;/figure>
&lt;p>If you see &lt;code>cap_sys_admin&lt;/code>, you are likely in a privileged container. You can mount the host filesystem and access sensitive files.&lt;/p>
&lt;figure class="code-block">
 &lt;figcaption class="code-lang">bash&lt;/figcaption>
 &lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-bash" data-lang="bash">&lt;span class="line">&lt;span class="cl">&lt;span class="c1"># Mount host root filesystem&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">mkdir /host
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">mount /dev/sda1 /host
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">chroot /host&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>
&lt;/figure>
&lt;h3 id="docker-socket-mounting" tabindex="-1">Docker Socket Mounting&lt;a class="heading-anchor" href="#docker-socket-mounting" aria-label="Permalink to Docker Socket Mounting">#&lt;/a>&lt;/h3>
&lt;p>If the Docker socket (&lt;code>/var/run/docker.sock&lt;/code>) is mounted inside the container, you can communicate with the Docker daemon to create new privileged containers or execute commands on the host.&lt;/p>
&lt;figure class="code-block">
 &lt;figcaption class="code-lang">bash&lt;/figcaption>
 &lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-bash" data-lang="bash">&lt;span class="line">&lt;span class="cl">&lt;span class="c1"># List containers using the mounted socket&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">curl --unix-socket /var/run/docker.sock http://localhost/containers/json&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>
&lt;/figure></description></item></channel></rss>