Detection rules › Panther
Exec into Pod
Alerts when users exec into pod. Possible to specify specific projects and allowed users.
Rule body yaml
AnalysisType: rule
Filename: gcp_k8s_exec_into_pod.py
RuleID: "GCP.K8s.ExecIntoPod"
DisplayName: "Exec into Pod"
Enabled: false
LogTypes:
- GCP.AuditLog
Tags:
- GCP
- Security Control
- Configuration Required
Severity: Medium
Description: >
Alerts when users exec into pod. Possible to specify specific projects and allowed users.
Runbook: >
Investigate the user and determine why. Advise that it is discouraged practice. Create ticket if appropriate.
Reference: https://cloud.google.com/migrate/containers/docs/troubleshooting/executing-shell-commands
Tests:
- Name: Disallowed User
ExpectedResult: true
Log:
{
"protoPayload":
{
"authenticationInfo":
{ "principalEmail": "disallowed.user@example.com" },
"authorizationInfo":
[
{
"permission": "io.k8s.core.v1.pods.exec.create",
"resource": "core/v1/namespaces/example/pods/example-57998cf7c5-bjkfk/exec",
},
],
"methodName": "io.k8s.core.v1.pods.exec.create",
"requestMetadata":
{
"callerIp": "88.88.88.88",
"callerSuppliedUserAgent": "kubectl/v1.40.8 (darwin/amd64) kubernetes/6575935",
},
"resourceName": "core/v1/namespaces/example/pods/one-off-valerii-tovstyk-1646666967280/exec",
"timestamp": "2022-03-04T16:01:49.978756Z",
},
"resource":
{
"type": "k8s_cluster",
"labels": { "project_id": "rigup-production" },
},
}
- Name: Disallowed User2 - not an allowed namespace
ExpectedResult: true
Log:
{
"protoPayload":
{
"authenticationInfo":
{ "principalEmail": "example-allowed-user@example.com" },
"authorizationInfo":
[
{
"permission": "io.k8s.core.v1.pods.exec.create",
"resource": "core/v1/namespaces/istio-system/pods/opa-57998cf7c5-bjkfk/exec",
},
],
"methodName": "io.k8s.core.v1.pods.exec.create",
"requestMetadata":
{
"callerIp": "88.88.88.88",
"callerSuppliedUserAgent": "kubectl/v1.40.8 (darwin/amd64) kubernetes/6575935",
},
"resourceName": "core/v1/namespaces/istio-system/pods/one-off-valerii-tovstyk-1646666967280/exec",
"timestamp": "2022-03-04T16:01:49.978756Z",
},
"resource":
{
"type": "k8s_cluster",
"labels": { "project_id": "rigup-production" },
},
}
Detection logic
Condition
protoPayload.methodName eq "io.k8s.core.v1.pods.exec.create"
resource.type eq "k8s_cluster"
This rule also runs imperative logic the parser cannot express as a filter; the conditions above are the structured part it could extract.
Indicators
Each row is a field, operator, and value that the rule matches. The corpus column counts how many other rules in the catalog look for the same combination: high numbers point to widely-used, community-vetted indicators. Blank or 1 shows that the indicator is specific to this rule.
| Field | Kind | Values |
|---|---|---|
protoPayload.methodName | eq |
|
resource.type | eq |
|