Exec Into Container (kubernetes)
Platform | Author | Last Update |
---|---|---|
kubernetes | Leo Tsaousis | 2024-12-02 |
Execute into a Pod’s container
Attackers who have permissions, can run malicious commands in a Pod’s container within the cluster using “kubectl exec” command
MITRE IDs
Scope
This test case does not need Cluster-wide permissions
Required Permissions
- apiGroups: - '' namespaced: true resources: - pods/exec verbs: - create- apiGroups: - '' namespaced: true resources: - pods verbs: - get
Required Parameters
Name | Type | Description | Example Value |
---|---|---|---|
podname | str | Name of the pod to exec into | vulnerable-pod |
command | str | The command to execute within the pod. | whoami |
Attacker Action
kubectl exec vulnerable-pod -- sh -c whoami
Detection Case
ELK query
When logs are ingested into ELK, the following query can be used to identify relevant events.
verb:create AND resource:pods AND subresource:exec
Sigma Definition
---title: Exec into Containerid: a1b0ca4e-7835-413e-8471-3ff2b8a66be6status: experimentalauthor: Leo Tsaousisdate: 2024-12-02description: | Execute into a Pod's container
Attackers who have permissions, can run malicious commands in a Pod's container within the cluster using "kubectl exec" commandlogsource: product: kubernetes service: auditdetection: selection: verb: create
resource: pods subresource: exec condition: selectionlevel: lowtags:- attack.T1609references:- https://microsoft.github.io/Threat-Matrix-for-Kubernetes/techniques/Exec%20into%20container/falsepositives:- Legitimate debugging activity, investigate the identity performing the requests and their authorization