<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title>Defend for Containers — CraftedSignal Threat Feed</title><link>https://feed.craftedsignal.io/products/defend-for-containers/</link><description>Trending threats, MITRE ATT&amp;CK coverage, and detection metadata — refreshed continuously.</description><generator>Hugo</generator><language>en</language><managingEditor>hello@craftedsignal.io</managingEditor><webMaster>hello@craftedsignal.io</webMaster><lastBuildDate>Wed, 03 Jan 2024 12:00:00 +0000</lastBuildDate><atom:link href="https://feed.craftedsignal.io/products/defend-for-containers/feed.xml" rel="self" type="application/rss+xml"/><item><title>Potential Direct Kubelet Access via Process Arguments</title><link>https://feed.craftedsignal.io/briefs/2024-01-kubelet-access/</link><pubDate>Wed, 03 Jan 2024 12:00:00 +0000</pubDate><author>hello@craftedsignal.io</author><guid isPermaLink="true">https://feed.craftedsignal.io/briefs/2024-01-kubelet-access/</guid><description>Detection of potential direct Kubelet access via process arguments in Linux containers, which could lead to enumeration, execution, or lateral movement within the Kubernetes cluster.</description><content:encoded><![CDATA[<p>This rule detects potential direct Kubelet access via process arguments within Linux containers. Attackers may target the Kubelet API to gain unauthorized access to the Kubernetes API server or other sensitive resources within the cluster. Observed requests are often used for reconnaissance, such as enumerating pods and cluster resources, or for executing commands directly on the API server. This activity indicates a potential attempt to move laterally within the Kubernetes environment. The activity is detected by monitoring process arguments for HTTP requests directed at the Kubelet API on ports 10250 or 10255. The detection leverages Elastic Defend for Containers, introduced in version 9.3.0.</p>
<h2 id="attack-chain">Attack Chain</h2>
<ol>
<li>An attacker gains initial access to a container within the Kubernetes cluster, potentially through exploiting a vulnerable application.</li>
<li>The attacker opens an interactive shell within the compromised container.</li>
<li>Using command-line tools such as <code>curl</code> or <code>wget</code>, the attacker crafts an HTTP request targeting the Kubelet API, typically on port 10250 or 10255.</li>
<li>The HTTP request is embedded within the process arguments, including specific Kubelet endpoints such as <code>/pods</code>, <code>/exec</code>, <code>/run</code>, or <code>/logs</code>.</li>
<li>The attacker attempts to enumerate pods and other cluster resources by querying the <code>/pods</code> endpoint.</li>
<li>The attacker attempts to execute commands within containers by leveraging the <code>/exec</code> or <code>/run</code> endpoints.</li>
<li>The attacker attempts to retrieve container logs using the <code>/logs</code> endpoint.</li>
<li>Successful exploitation allows the attacker to move laterally within the Kubernetes cluster, potentially gaining access to sensitive data or control over other resources.</li>
</ol>
<h2 id="impact">Impact</h2>
<p>Successful exploitation of direct Kubelet access can lead to significant compromise within a Kubernetes cluster. Attackers can enumerate sensitive information, execute arbitrary commands within containers, and move laterally to other parts of the cluster. This can result in data exfiltration, denial of service, or complete cluster takeover. Due to the high level of access granted by Kubelet, a successful attack allows the attacker to take complete control over the target node.</p>
<h2 id="recommendation">Recommendation</h2>
<ul>
<li>Deploy the provided Sigma rules to your SIEM and tune them for your environment. Enable Elastic Defend for Containers with a minimum version of 9.3.0 to generate the necessary logs for these detections.</li>
<li>Review network policies to restrict pod access to Kubelet ports (10250, 10255) except from approved node-local agents (references: <a href="https://www.cyberark.com/resources/threat-research-blog/using-kubelet-client-to-attack-the-kubernetes-cluster)">https://www.cyberark.com/resources/threat-research-blog/using-kubelet-client-to-attack-the-kubernetes-cluster)</a>.</li>
<li>Harden Kubelet authentication and authorization by disabling anonymous access and requiring webhook authorization (references: <a href="https://www.aquasec.com/blog/kubernetes-exposed-exploiting-the-kubelet-api/)">https://www.aquasec.com/blog/kubernetes-exposed-exploiting-the-kubelet-api/)</a>.</li>
<li>Enforce pod security policies to restrict privileged pods and host networking, reducing the attack surface for node API access.</li>
</ul>
]]></content:encoded><category domain="severity">high</category><category domain="type">advisory</category><category>container</category><category>kubelet</category><category>kubernetes</category><category>lateral-movement</category><category>execution</category></item><item><title>Nsenter Execution with Target Flag Inside Container</title><link>https://feed.craftedsignal.io/briefs/2024-01-nsenter-container-escape/</link><pubDate>Tue, 02 Jan 2024 12:00:00 +0000</pubDate><author>hello@craftedsignal.io</author><guid isPermaLink="true">https://feed.craftedsignal.io/briefs/2024-01-nsenter-container-escape/</guid><description>The rule detects nsenter executions from inside a monitored Linux container that include a namespace target flag (-t or --target), which can be abused to escape container isolation.</description><content:encoded><![CDATA[<p>This detection identifies the execution of <code>nsenter</code> within a Linux container, specifically when the <code>-t</code> or <code>--target</code> flag is used. This flag indicates an attempt to enter another process or namespace context. Attackers can exploit this capability, especially when combined with privileged mounts, exposed PIDs, or shared namespaces, to escape the container and pivot to the host system. This activity can lead to privilege escalation and further compromise of the underlying infrastructure. The detection is relevant for environments using Elastic Defend for Containers.</p>
<h2 id="attack-chain">Attack Chain</h2>
<ol>
<li>An attacker gains initial access to a container, possibly through exploiting a vulnerability in a containerized application.</li>
<li>The attacker identifies a container with weak configurations, such as exposed PIDs, shared namespaces, or privileged mounts.</li>
<li>The attacker executes <code>nsenter</code> with the <code>-t</code> or <code>--target</code> flag, specifying a target PID or namespace.</li>
<li>The <code>nsenter</code> command joins the target namespace (mount, network, PID, user, or IPC) based on specified flags (<code>-m</code>, <code>-n</code>, <code>-p</code>, <code>-U</code>, or <code>-i</code>).</li>
<li>The attacker gains access to the host system&rsquo;s resources or processes due to the namespace sharing or privileged access.</li>
<li>The attacker escalates privileges on the host system, potentially gaining root access.</li>
<li>The attacker pivots to other containers or the host infrastructure, expanding their control.</li>
<li>The attacker achieves their final objective, such as data exfiltration, system disruption, or deploying malware on the host.</li>
</ol>
<h2 id="impact">Impact</h2>
<p>A successful container escape can allow an attacker to compromise the underlying host system. This can lead to the compromise of other containers running on the same host, as well as sensitive data stored on the host system. The impact can range from data breaches to complete infrastructure takeover. If the host is a node in a Kubernetes cluster, the attacker might be able to compromise the entire cluster.</p>
<h2 id="recommendation">Recommendation</h2>
<ul>
<li>Deploy the Sigma rule <code>Detect Nsenter Container Escape</code> to your SIEM and tune for your environment to detect suspicious <code>nsenter</code> executions within containers.</li>
<li>Review container configurations and enforce least privilege to prevent unauthorized namespace sharing and privileged mounts.</li>
<li>Monitor container logs for <code>nsenter</code> executions with target flags, as indicated by the log source <code>logs-cloud_defend.process*</code> and the query in this brief.</li>
<li>Restrict the use of hostPath volumes and other sensitive mounts within container deployments.</li>
<li>Reduce recurrence by avoiding host namespace sharing, restricting hostPath and sensitive mounts, and blocking unnecessary capabilities.</li>
</ul>
]]></content:encoded><category domain="severity">high</category><category domain="type">advisory</category><category>container</category><category>privilege-escalation</category><category>linux</category></item><item><title>Kubeletctl Execution Inside Container Detected</title><link>https://feed.craftedsignal.io/briefs/2024-01-kubeletctl-container-execution/</link><pubDate>Tue, 02 Jan 2024 12:00:00 +0000</pubDate><author>hello@craftedsignal.io</author><guid isPermaLink="true">https://feed.craftedsignal.io/briefs/2024-01-kubeletctl-container-execution/</guid><description>This rule detects the execution of kubeletctl inside a container, which can be used to enumerate the Kubelet API or other resources inside the container, potentially indicating lateral movement attempts within the pod.</description><content:encoded><![CDATA[<p>This rule detects the execution of <code>kubeletctl</code> inside a container. Kubeletctl is a command-line tool that interacts with the Kubelet API directly, making the often undocumented API more accessible. Attackers may use it to enumerate the Kubelet API or other resources within the container, potentially indicating lateral movement within the pod. The detection is based on the &ldquo;Defend for Containers&rdquo; integration (version 9.3.0 and later) within the Elastic stack. This activity is significant because <code>kubeletctl</code> can expose pod and node details, enabling actions that facilitate discovery and lateral movement from a compromised container.</p>
<h2 id="attack-chain">Attack Chain</h2>
<ol>
<li>An attacker gains initial access to a container, possibly through a vulnerability in the containerized application or a misconfigured Kubernetes environment.</li>
<li>The attacker executes <code>kubeletctl</code> inside the compromised container. This could be facilitated by the tool being present in the container image or downloaded post-compromise.</li>
<li>The attacker uses <code>kubeletctl scan</code> to discover Kubelet endpoints within the Kubernetes cluster.</li>
<li>The attacker leverages <code>kubeletctl pods</code> or <code>kubeletctl runningpods</code> to enumerate running pods and their details.</li>
<li>The attacker uses the discovered pod information to identify potential targets for lateral movement.</li>
<li>The attacker attempts to use <code>kubeletctl exec</code> or <code>kubeletctl attach</code> to gain access to other pods within the cluster.</li>
<li>The attacker attempts to port forward using <code>kubeletctl portForward</code> to establish connections to services running in other pods.</li>
<li>Upon successful lateral movement, the attacker performs further reconnaissance or deploys malicious payloads to achieve their objectives, such as data exfiltration or denial-of-service.</li>
</ol>
<h2 id="impact">Impact</h2>
<p>Successful execution of <code>kubeletctl</code> within a container can lead to the exposure of sensitive information about the Kubernetes cluster, including pod details and internal network configurations. This can enable attackers to move laterally within the cluster, potentially compromising other applications and data. The impact could range from data breaches and service disruptions to full cluster compromise depending on the attacker&rsquo;s objectives and the scope of the compromised container&rsquo;s access.</p>
<h2 id="recommendation">Recommendation</h2>
<ul>
<li>Deploy the provided Sigma rule to your SIEM to detect the execution of <code>kubeletctl</code> within containers based on process name and arguments.</li>
<li>Monitor container network activity for connections to node addresses on Kubelet ports (commonly 10250/10255) and investigate any suspicious patterns.</li>
<li>Implement network policies to restrict pod-to-node access to the Kubelet API.</li>
<li>Harden container images by removing unnecessary tools like <code>kubeletctl</code> and enforce least privilege principles.</li>
<li>Enable and review Kubernetes audit logs to identify the source of interactive sessions into containers, correlating with timestamps of <code>kubeletctl</code> execution.</li>
<li>Enforce Pod Security Standards to restrict privileged pods and limit node API exposure.</li>
</ul>
]]></content:encoded><category domain="severity">high</category><category domain="type">advisory</category><category>container</category><category>kubeletctl</category><category>lateral-movement</category><category>execution</category></item></channel></rss>