Operator On The Wire
Join
← Back to Knowledge Base
BLUE TEAM / THREAT HUNT / LINUX / CONTAINERS

Kubernetes

This note documents detection patterns related to Kubernetes Abuse, Malicious Pods, Service Exposure, Secret Theft, and Cluster Reconnaissance.


Direct Indicators

SourceGrep Pattern / ArtifactMeaningForensic ValueNotes
Pod specimage: alpine, busybox, ubuntuGeneric attacker imageHighCommon attacker staging image.
Pod speccommand: + /bin/shInteractive execution logicCriticalOften indicates custom attacker pod.
Pod speccurl https://10.x.x.x:8443API abuseCriticalStrong cluster enumeration indicator.
Pod spec/run/secrets/kubernetes.io/serviceaccount/tokenToken theftCriticalCredential access against cluster.
Pod specnc, wget, sleep 100000Beacon / persistence logicCriticalVery common malicious pod tradecraft.
Pod metadataFake infra naming (metrics-server, coredns)CamouflageCriticalTrusted-name impersonation is common.
Service spectype: NodePortExternal exposureCriticalHigh-value ingress path.
Service specnodePort: unusual valuesSuspicious service exposureHighEspecially if nonstandard high ports.
Service specclusterIP:Internal service targetHighNeeded for API abuse reconstruction.
Deployment specsecretRef, configMapRefSecret/config linkageCriticalShows credential injection path.
SecretsBase64 encoded credentialsEmbedded secretsCriticalOften plaintext after decode.
ConfigMapsFlags / SSH configs / payload configOperational attacker dataHighOften challenge answer source.
ServiceAccountunexpected token usagePrivilege abuseCriticalIndicates API-authenticated activity.

Indirect Indicators

IndicatorWhat To Look ForForensic ValueNotes
Generic image inside infra namespacealpine inside kube-systemCriticalStrong anomaly.
Pod differs from deployment intentRuntime mismatchCriticalSuggests attacker injection.
Service exposes SSH internallyNodePort + sshHighOften persistence foothold.
Secret mounted into suspicious podCredential theft pathCriticalHigh-confidence hostile action.
Long sleep commandsleep 100000HighKeeps pod alive after execution.
Curl against API serverCluster discoveryCriticalCommon recon phase.
Netcat inside podExfiltration / callbackCriticalStrong malicious indicator.
Trusted object name + wrong imageName camouflageCriticalVery realistic attacker pattern.
Secret decoded to passwordCredential stagingCriticalLateral movement potential.
Namespace mismatchSuspicious object locationHighAttackers often abuse kube-system.

Common Tools

ToolUsage
kubectl get pods -AEnumerate pods across namespaces.
kubectl describe pod <pod>Full pod inspection.
kubectl get svc -AEnumerate services.
kubectl get secrets -A -o yamlSecret review.
kubectl get configmaps -A -o yamlConfig review.
kubectl get deployments -A -o yamlIntended workload review.
yqOffline YAML triage.

Relevant Artifacts

ArtifactPath / CommandForensic ValueNotes
Podspods.yamlCriticalRuntime truth.
Deploymentsdeployment.yamlCriticalIntended state.
Servicesservice.yamlCriticalExposure mapping.
Secretssecrets.yamlCriticalCredential source.
ConfigMapsconfigmaps.yamlHighOperational configs / flags.
ServiceAccountsserviceaccount.yamlCriticalIdentity mapping.
DaemonSetsdaemonset.yamlHighPersistence path.
Jobsjob.yamlHighOne-shot attacker execution.

MITRE ATT&CK References

  • T1610 Deploy Container
  • T1552 Unsecured Credentials
  • T1526 Cloud Service Discovery
  • T1078 Valid Accounts
  • T1046 Network Service Discovery

Decision Tree

  1. What is externally exposed?

    • Read service.yaml
    • Identify NodePort, ClusterIP
  2. What object owns the service?

    • Follow selectors → labels → pod/deployment
  3. Are secrets linked?

    • Check secretRef, env, mounted volumes
  4. Does runtime match expected infra?

    • Compare deployment vs pod
  5. Any suspicious image?

    • Generic images in infra namespace = anomaly
  6. Any API abuse?

    • Search curl, token reads, API endpoints
  7. Confirm maliciousness

    • Fake name + generic image + token + curl + sleep = strong attacker pod

Example Detection Templates

Grep

grep -R "image:\|command:\|curl\|nc \|sleep \|serviceaccount/token" *.yaml
grep -R "NodePort\|clusterIP\|secretRef\|configMapRef" *.yaml

yq

yq '.spec.containers[].image' pods.yaml
yq '.items[].spec.containers[].command' pods.yaml

Base64 Decode Secret

echo BASE64_VALUE | base64 -d

Sigma

title: Kubernetes Suspicious Pod Execution
id: kubernetes-suspicious-pod-execution
status: experimental
description: Detects suspicious pod definitions containing shell execution, generic images, or token theft patterns
logsource:
  product: kubernetes
detection:
  selection_keywords:
    message|contains:
      - 'image: alpine'
      - '/run/secrets/kubernetes.io/serviceaccount/token'
      - 'curl https://'
      - 'sleep 100000'
  condition: selection_keywords
fields:
  - pod
  - namespace
falsepositives:
  - Legitimate troubleshooting containers
level: high
tags:
  - attack.t1610
  - attack.t1552

Mitigation & Hardening

Control AreaMitigationEffectivenessNotes
RBACRestrict service account privilegesCriticalLimits token abuse.
Admission policyBlock generic imagesHighStops simple attacker pods.
Namespace controlLock down kube-systemCriticalPrevents infra impersonation.
Secret policyMinimize mounted secretsCriticalReduces credential exposure.
Audit loggingEnable Kubernetes audit logsCriticalBest attribution source.

Fast Triage Checks

QuestionCommand / ArtifactWhy It Matters
Any suspicious image?search image:Fast anomaly detection.
Any fake infra name?inspect pod namesCamouflage clue.
Any API calls?search curlDiscovery / theft evidence.
Any token access?search serviceaccount pathCredential abuse.
Any external exposure?inspect NodePortIngress path.
Any secrets decoded?inspect secrets.yamlCredential extraction.

High Value Grep Strings

PatternWhy It Matters
image:Runtime anomaly source.
NodePortExternal access.
clusterIPInternal target mapping.
serviceaccount/tokenCredential theft.
curl https://API recon.
nc Exfiltration / callback.
sleepPersistence keepalive.

Analyst Notes

ScenarioInterpretation
Generic image in infra namespaceStrong malicious anomaly.
Fake metrics-server podTrusted-name camouflage.
Token + curl to APICredentialed cluster recon.
Secret decoded to plaintext passwordOperational credential exposure.
NodePort exposing SSHRemote foothold likely.
Deployment clean, pod dirtyRuntime compromise possible.