고급 헌팅의 Kubeaudit 이벤트

Kubernetes Kubeaudit 이벤트(및 Azure Resource Manager 클라우드 감사)는 Microsoft Defender 포털의 고급 헌팅에서 사용할 수 있습니다.

Kubernetes 컨트롤 플레인 공격 표면 및 Azure 리소스 관리에서 발생한 인시던트를 심사 및 조사할 수 있습니다. 고급 헌팅을 사용하여 위협을 사전에 헌팅할 수도 있습니다.

또한 의심스러운 Resource Manager 및 Kubernetes(KubeAudit) 컨트롤 플레인 활동에 대한 사용자 지정 감지를 만들 수 있습니다.

이 기능의 적용 범위는 다음과 같습니다.

  • Azure의 Kubernetes KubeAudit 이벤트(Azure Kubernetes Service), Amazon Web Services(Amazon Elastic Kubernetes Service), Google Cloud Platform(Google Kubernetes Engine) 및 온-프레미스

  • Resource Manager 컨트롤 플레인 이벤트

시작하려면 CloudAuditEvents라는 고급 헌팅에서 스키마 탭에 추가된 새 테이블을 확인하세요.

고급 헌팅의 스키마 탭에 있는 CloudAuditEvents 테이블의 스크린샷.

일반적인 사용 사례 및 시나리오

  • XDR 고급 헌팅에서 의심스러운 Resource Manager 및 Kubernetes(Kubeaudit) 컨트롤 플레인 활동 조사
  • 의심스러운 Resource Manager 및 Kubernetes(Kubeaudit) 컨트롤 플레인 활동에 대한 사용자 지정 감지 만들기

필수 조건

  • Kubernetes 이벤트의 경우: 컨테이너용 Defender 플랜을 사용하는 구독이 하나 이상 필요합니다.
  • Azure Resource Manager 이벤트의 경우: Azure Resource Manager용 Defender 플랜을 사용하는 구독이 하나 이상 필요합니다.

샘플 쿼리

권한 있는 Pod의 배포를 표시하려면 다음 샘플 쿼리를 사용합니다.

CloudAuditEvents
| where Timestamp > ago(1d)
| where DataSource == "Azure Kubernetes Service"
| where OperationName == "create"
| where RawEventData.ObjectRef.resource == "pods" and isnull(RawEventData.ObjectRef.subresource)
| where RawEventData.ResponseStatus.code startswith "20"
| extend PodName = RawEventData.RequestObject.metadata.name
| extend PodNamespace = RawEventData.ObjectRef.namespace
| mv-expand Container = RawEventData.RequestObject.spec.containers
| extend ContainerName = Container.name
| where Container.securityContext.privileged == "true"
| extend Username = RawEventData.User.username
| project Timestamp, AzureResourceId , OperationName, IPAddress, UserAgent, PodName, PodNamespace, ContainerName, Username

kube-system 네임스페이스에서 exec 명령을 표시하려면 다음 샘플 쿼리를 사용합니다.

CloudAuditEvents
| where Timestamp > ago(1d)
| where DataSource == "Azure Kubernetes Service"
| where OperationName == "create"
| where RawEventData.ObjectRef.resource == "pods" and RawEventData.ResponseStatus.code == 101  
| where RawEventData.ObjectRef.namespace == "kube-system"
| where RawEventData.ObjectRef.subresource == "exec"
| where RawEventData.ResponseStatus.code == 101
| extend RequestURI = tostring(RawEventData.RequestURI)
| extend PodName = tostring(RawEventData.ObjectRef.name)
| extend PodNamespace = tostring(RawEventData.ObjectRef.namespace)
| extend Username = tostring(RawEventData.User.username)
| where PodName !startswith "tunnelfront-" and PodName !startswith "konnectivity-" and PodName !startswith "aks-link"
| extend Commands =  extract_all(@"command=([^\&]*)", RequestURI)
| extend ParsedCommand = url_decode(strcat_array(Commands, " "))
| project Timestamp, AzureResourceId , OperationName, IPAddress, UserAgent, PodName, PodNamespace,  Username, ParsedCommand

cluster-admin 역할 바인딩의 생성을 확인하려면 다음 샘플 쿼리를 사용합니다.

CloudAuditEvents
| where Timestamp > ago(1d)
| where OperationName == "create"
| where RawEventData.ObjectRef.resource == "clusterrolebindings"
| where RawEventData.ResponseStatus.code startswith "20"
| where RawEventData.RequestObject.roleRef.name == "cluster-admin"
| mv-expand Subject = RawEventData.RequestObject.subjects
| extend SubjectName = tostring(Subject.name)
| extend SubjectKind = tostring(Subject["kind"]) 
| extend BindingName = tostring(RawEventData.ObjectRef.name)
| extend ActionTakenBy = tostring(RawEventData.User.username)
| where ActionTakenBy != "acsService" //Remove FP
| project Timestamp, AzureResourceId , OperationName, ActionTakenBy, IPAddress, UserAgent, BindingName, SubjectName, SubjectKind