Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add auditd example with Auditbeat in kubernetes manifests #17431

Merged
merged 5 commits into from
Apr 6, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.next.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,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]
- Reference kubernetes manifests mount data directory from the host, so data persist between executions in the same node. {pull}17429[17429]
- Log to stderr when running using reference kubernetes manifests. {pull}17443[174443]

Expand Down
30 changes: 30 additions & 0 deletions deploy/kubernetes/auditbeat-kubernetes.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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']
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could probably make these indexers and matchers the default ones for auditbeat.

Copy link
Contributor

@exekias exekias Apr 2, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

++ on doing this, I think it should also be default in Metricbeat

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Issue created for this: #17432


cloud.id: ${ELASTIC_CLOUD_ID}
cloud.auth: ${ELASTIC_CLOUD_AUTH}
Expand Down Expand Up @@ -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
Expand All @@ -71,6 +90,7 @@ spec:
serviceAccountName: auditbeat
terminationGracePeriodSeconds: 30
hostNetwork: true
hostPID: true # Required by auditd module
dnsPolicy: ClusterFirstWithHostNet
containers:
- name: auditbeat
Expand All @@ -92,8 +112,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
Expand Down
19 changes: 19 additions & 0 deletions deploy/kubernetes/auditbeat/auditbeat-configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down Expand Up @@ -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
11 changes: 11 additions & 0 deletions deploy/kubernetes/auditbeat/auditbeat-daemonset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ spec:
serviceAccountName: auditbeat
terminationGracePeriodSeconds: 30
hostNetwork: true
hostPID: true # Required by auditd module
dnsPolicy: ClusterFirstWithHostNet
containers:
- name: auditbeat
Expand All @@ -39,8 +40,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
Expand Down