Files
securityonion/salt/zeek/config.sls
Josh Patterson 21222ff119 FIX: use /sbin/nologin for service accounts
These accounts existed only for container UID mapping and filesystem
ownership, but user.present omitted shell:, so Salt fell through to the
platform useradd default and every one of them got /bin/bash. Pin them to
/sbin/nologin so none can be used as an interactive login or `su -` target.

socore keeps /bin/bash: `su socore -c '/usr/sbin/so-repo-sync'` in soup and
so-kernel-upgrade execs the account's passwd shell, and operator docs tell
users to su to socore. soqemussh keeps /bin/bash as an SSH login account.

elastic-agent, elastic-agent-pr and kafka are included alongside the accounts
named in the issue, being the same class with the same unset shell, so the
default is uniform.

Cron is unaffected: cronie runs jobs via the crontab SHELL (default /bin/sh),
not the passwd shell. suricata is the only account changed here that owns a
crontab, and somon has shipped as nologin with a working cron job already.
The zeek `runuser -l zeek` calls all run inside so-zeek via docker.run/exec,
so they resolve the shell from the image, not the host.

Verified on a 3.4.0 managersearch + sensor grid: highstate converges with the
shell as the only change and no failures, is idempotent on a second run, all
containers stay up, SOC still issues a Kratos login flow, and the suricata
surilogcompress cron job runs post-change ((suricata) CMD/CMDEND in
/var/log/cron) while `su - suricata` is now refused.

Closes #16256
2026-09-25 09:23:09 -04:00

212 lines
4.7 KiB
YAML+Jinja

# Copyright Security Onion Solutions LLC and/or licensed to Security Onion Solutions LLC under one
# or more contributor license agreements. Licensed under the Elastic License 2.0 as shown at
# https://securityonion.net/license; you may not use this file except in compliance with the
# Elastic License 2.0.
{% from 'allowed_states.map.jinja' import allowed_states %}
{% if sls.split('.')[0] in allowed_states %}
{% from 'vars/globals.map.jinja' import GLOBALS %}
{% from "zeek/config.map.jinja" import ZEEKMERGED %}
{% from 'bpf/zeek.map.jinja' import ZEEKBPF, ZEEK_BPF_STATUS, ZEEK_BPF_CALC %}
# Add Zeek group
zeekgroup:
group.present:
- name: zeek
- gid: 937
# Add Zeek User
zeek:
user.present:
- uid: 937
- gid: 937
- home: /opt/so/conf/zeek
- createhome: False
- shell: /sbin/nologin
# Create some directories
zeekpolicydir:
file.directory:
- name: /opt/so/conf/zeek/policy
- user: 937
- group: 939
- makedirs: True
zeekzkgsync:
file.recurse:
- name: /opt/so/conf/zeek/zkg
- source: salt://zeek/zkg
- user: 937
- group: 939
- clean: True
- makedirs: True
- exclude_pat: README
# Zeek Log Directory
zeeklogdir:
file.directory:
- name: /nsm/zeek/logs
- user: 937
- group: 939
- makedirs: True
# Zeek Spool Directory
zeekspooldir:
file.directory:
- name: /nsm/zeek/spool/manager
- user: 937
- makedirs: True
# Zeek extracted
zeekextractdir:
file.directory:
- name: /nsm/zeek/extracted
- user: 937
- group: 939
- mode: 770
- makedirs: True
zeekextractcompletedir:
file.directory:
- name: /nsm/zeek/extracted/complete
- user: 937
- group: 939
- mode: 770
- makedirs: True
# Sync the policies
zeekpolicysync:
file.recurse:
- name: /opt/so/conf/zeek/policy
- source: salt://zeek/policy
- user: 937
- group: 939
- template: jinja
- defaults:
FILE_EXTRACTION: {{ ZEEKMERGED.file_extraction }}
# Ensure the zeek spool tree (and state.db) ownership is correct
zeekspoolownership:
file.directory:
- name: /nsm/zeek/spool
- user: 937
zeekstatedbownership:
file.managed:
- name: /nsm/zeek/spool/state.db
- user: 937
- replace: False
- create: False
zeek_sbin:
file.recurse:
- name: /usr/sbin
- source: salt://zeek/tools/sbin
- user: root
- group: root
- file_mode: 755
#zeek_sbin_jinja:
# file.recurse:
# - name: /usr/sbin
# - source: salt://zeek/tools/sbin_jinja
# - user: 939
# - group: 939
# - file_mode: 755
# - template: jinja
# Sync Intel
zeekintelloadsync:
file.managed:
- name: /opt/so/conf/policy/intel/__load__.zeek
- source: salt://zeek/policy/intel/__load__.zeek
- user: 937
- group: 939
- makedirs: True
zeekctlcfg:
file.managed:
- name: /opt/so/conf/zeek/zeekctl.cfg
- source: salt://zeek/files/zeekctl.cfg.jinja
- user: 937
- group: 939
- template: jinja
- defaults:
ZEEKCTL: {{ ZEEKMERGED.config.zeekctl | tojson }}
# Sync node.cfg
nodecfg:
file.managed:
- name: /opt/so/conf/zeek/node.cfg
- source: salt://zeek/files/node.cfg.jinja
- user: 937
- group: 939
- template: jinja
- defaults:
NODE: {{ ZEEKMERGED.config.node }}
networkscfg:
file.managed:
- name: /opt/so/conf/zeek/networks.cfg
- source: salt://zeek/files/networks.cfg.jinja
- user: 937
- group: 939
- template: jinja
- defaults:
NETWORKS: {{ ZEEKMERGED.config.networks }}
plcronscript:
file.managed:
- name: /usr/local/bin/packetloss.sh
- source: salt://zeek/cron/packetloss.sh
- mode: 755
zeekja4cfg:
file.managed:
- name: /opt/so/conf/zeek/config.zeek
- source: salt://zeek/files/config.zeek.ja4
- user: 937
- group: 939
- template: jinja
- defaults:
JA4PLUS: {{ ZEEKMERGED.ja4plus.enabled }}
# BPF compilation failed
{% if ZEEKBPF and not ZEEK_BPF_STATUS %}
zeekbpfcompilationfailure:
test.configurable_test_state:
- changes: False
- result: False
- comment: "BPF Syntax Error - Discarding Specified BPF. Error: {{ ZEEK_BPF_CALC['stderr'] }}"
{% endif %}
zeekbpf:
file.managed:
- name: /opt/so/conf/zeek/bpf
- user: 940
- group: 940
{% if ZEEK_BPF_STATUS %}
- contents: {{ ZEEKBPF }}
{% else %}
- contents:
- "ip or not ip"
{% endif %}
localzeek:
file.managed:
- name: /opt/so/conf/zeek/local.zeek
- source: salt://zeek/files/local.zeek.jinja
- user: 937
- group: 939
- template: jinja
- defaults:
LOCAL: {{ ZEEKMERGED.config.local | tojson }}
{% else %}
{{sls}}_state_not_allowed:
test.fail_without_changes:
- name: {{sls}}_state_not_allowed
{% endif %}