From 784454f20c2ecc6e27e62ea0a7d9412ad03f96d6 Mon Sep 17 00:00:00 2001 From: Jaime Soriano Pastor Date: Thu, 2 Apr 2020 12:09:17 +0200 Subject: [PATCH 1/2] Add auditd example with Auditbeat in kubernetes manifests Add an example configuration of the auditd module in the Auditbeat reference manifest, including the processors needed for enrichement of events. --- deploy/kubernetes/auditbeat-kubernetes.yaml | 30 +++++++++++++++++++ .../auditbeat/auditbeat-configmap.yaml | 19 ++++++++++++ .../auditbeat/auditbeat-daemonset.yaml | 11 +++++++ 3 files changed, 60 insertions(+) diff --git a/deploy/kubernetes/auditbeat-kubernetes.yaml b/deploy/kubernetes/auditbeat-kubernetes.yaml index ff4836f6914..45c1d2a5319 100644 --- a/deploy/kubernetes/auditbeat-kubernetes.yaml +++ b/deploy/kubernetes/auditbeat-kubernetes.yaml @@ -16,6 +16,17 @@ data: processors: - add_cloud_metadata: + - add_process_metadata: + match_pids: ['process.pid'] + include_fields: ['container.id'] + - add_kubernetes_metadata: + host: ${NODE_NAME} + default_indexers.enabled: false + default_matchers.enabled: false + indexers: + - container: + matchers: + - fields.lookup_fields: ['container.id'] cloud.id: ${ELASTIC_CLOUD_ID} cloud.auth: ${ELASTIC_CLOUD_AUTH} @@ -50,6 +61,14 @@ data: max_file_size: 100 MiB hash_types: [sha1] recursive: true + - module: auditd + audit_rules: | + # Executions + -a always,exit -F arch=b64 -S execve,execveat -k exec + + # Unauthorized access attempts + -a always,exit -F arch=b64 -S open,creat,truncate,ftruncate,openat,open_by_handle_at -F exit=-EACCES -k access + -a always,exit -F arch=b64 -S open,creat,truncate,ftruncate,openat,open_by_handle_at -F exit=-EPERM -k access --- # Deploy a auditbeat instance per node for node metrics retrieval apiVersion: apps/v1 @@ -71,6 +90,7 @@ spec: serviceAccountName: auditbeat terminationGracePeriodSeconds: 30 hostNetwork: true + hostPID: true # Required by auditd module dnsPolicy: ClusterFirstWithHostNet containers: - name: auditbeat @@ -91,8 +111,18 @@ spec: value: - name: ELASTIC_CLOUD_AUTH value: + - name: NODE_NAME + valueFrom: + fieldRef: + fieldPath: spec.nodeName securityContext: runAsUser: 0 + capabilities: + add: + # Capabilities needed for auditd module + - 'AUDIT_READ' + - 'AUDIT_WRITE' + - 'AUDIT_CONTROL' resources: limits: memory: 200Mi diff --git a/deploy/kubernetes/auditbeat/auditbeat-configmap.yaml b/deploy/kubernetes/auditbeat/auditbeat-configmap.yaml index d5589df00bf..7a17c80e5a7 100644 --- a/deploy/kubernetes/auditbeat/auditbeat-configmap.yaml +++ b/deploy/kubernetes/auditbeat/auditbeat-configmap.yaml @@ -16,6 +16,17 @@ data: processors: - add_cloud_metadata: + - add_process_metadata: + match_pids: ['process.pid'] + include_fields: ['container.id'] + - add_kubernetes_metadata: + host: ${NODE_NAME} + default_indexers.enabled: false + default_matchers.enabled: false + indexers: + - container: + matchers: + - fields.lookup_fields: ['container.id'] cloud.id: ${ELASTIC_CLOUD_ID} cloud.auth: ${ELASTIC_CLOUD_AUTH} @@ -50,3 +61,11 @@ data: max_file_size: 100 MiB hash_types: [sha1] recursive: true + - module: auditd + audit_rules: | + # Executions + -a always,exit -F arch=b64 -S execve,execveat -k exec + + # Unauthorized access attempts + -a always,exit -F arch=b64 -S open,creat,truncate,ftruncate,openat,open_by_handle_at -F exit=-EACCES -k access + -a always,exit -F arch=b64 -S open,creat,truncate,ftruncate,openat,open_by_handle_at -F exit=-EPERM -k access diff --git a/deploy/kubernetes/auditbeat/auditbeat-daemonset.yaml b/deploy/kubernetes/auditbeat/auditbeat-daemonset.yaml index bdd38cd3919..58a5d6de11b 100644 --- a/deploy/kubernetes/auditbeat/auditbeat-daemonset.yaml +++ b/deploy/kubernetes/auditbeat/auditbeat-daemonset.yaml @@ -18,6 +18,7 @@ spec: serviceAccountName: auditbeat terminationGracePeriodSeconds: 30 hostNetwork: true + hostPID: true # Required by auditd module dnsPolicy: ClusterFirstWithHostNet containers: - name: auditbeat @@ -38,8 +39,18 @@ spec: value: - name: ELASTIC_CLOUD_AUTH value: + - name: NODE_NAME + valueFrom: + fieldRef: + fieldPath: spec.nodeName securityContext: runAsUser: 0 + capabilities: + add: + # Capabilities needed for auditd module + - 'AUDIT_READ' + - 'AUDIT_WRITE' + - 'AUDIT_CONTROL' resources: limits: memory: 200Mi From 0a22bd7a978522d0dabcdd1b3c8108ccd285e58d Mon Sep 17 00:00:00 2001 From: Jaime Soriano Pastor Date: Fri, 3 Apr 2020 14:00:25 +0200 Subject: [PATCH 2/2] Add changelog entry --- CHANGELOG.next.asciidoc | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.next.asciidoc b/CHANGELOG.next.asciidoc index 91798059ffb..3bc4fbe853d 100644 --- a/CHANGELOG.next.asciidoc +++ b/CHANGELOG.next.asciidoc @@ -178,6 +178,7 @@ https://github.com/elastic/beats/compare/v7.0.0-alpha2...master[Check the HEAD d *Auditbeat* +- Reference kubernetes manifests include configuration for auditd and enrichment with kubernetes metadata. {pull}17431[17431] *Filebeat*