Commit Graph
96 Commits
Author SHA1 Message Date
Josh Patterson 72f60fcaa9 FIX: remove the docker socket from so-telegraf
so-telegraf mounted /var/run/docker.sock and joined the host docker group on
every node type. The :ro flag blocks write() to the inode, not connect() plus
HTTP over the socket, so any code execution inside the container could reach
POST /containers/create with Privileged:true and become root on the host.

No telegraf script used the socket; the only consumer was the native
[[inputs.docker]] plugin, and group_add 920 existed solely to feed it.
Container metrics now come from so-container-stats, a collector that runs on
the host from cron and writes influx line protocol to a file telegraf already
had mounted. This is the pattern so-status, so-raid-status and
so-elasticagent-status already use, so the privileged docker access stays on
the host side where root cron already ran it.

The collector runs as somon, a service account in the docker group with no
login shell and a locked password, rather than root. Docker group membership
is still root-equivalent on the host, so this is defense in depth rather than
a privilege boundary.

The telegraf scripts were root:939 mode 770, letting socore rewrite them for
code execution inside the container; they are now 750, which still allows the
read and execute telegraf needs. The container also ran with no group, giving
it gid 0, and now runs as 939:939. That alone would have broken
lasthighstate.sh, which reached /opt/so/log/salt only via the root group and
could not tell an unreadable file from a missing one, so it silently reported
a 56 year highstate age. Only the lasthighstate file is bind mounted now, and
the script tests readability instead of existence.

Everything inputs.docker collected beyond the five fields the shipped
dashboards query is available per stat under telegraf:container_stats,
annotated for SOC so an operator can enable it without editing files. Defaults
reproduce the previous output exactly. With every stat enabled the emitted
field set matches what inputs.docker wrote, verified by running the plugin
against the live socket and diffing: 53 fields, no type mismatches, no field
present on one side only.

Two deliberate differences: max_usage carries the real cgroup peak where the
daemon reports 0 on cgroup v2, and host-network containers emit no
docker_container_net row, matching inputs.docker. Docker label tags are not
restored, since nothing queries them and they cost significant cardinality.

so-status, the influxdb size cron, so-elasticagent-status, so-raid-status and
so-common-status-check truncated their output in place while telegraf read it,
so telegraf periodically saw an empty file and logged a parse error or emitted
empty values. They now write aside and rename. Measured on a live manager, the
old so-status cron left status.log empty for 215 of 10997 reads.

Tested on a fresh install, a converted grid and a 3.0 upgrade.
2026-09-24 14:30:25 -04:00
Josh Patterson 1f1d3ded41 FIX: root-own the Salt default tree so a SOC file-write cannot reach root code
/opt/so/saltstack/default holds the source for every root-executed script --
/usr/sbin, the reactors, _runners/_modules/_beacons, the master engines and
salt-relay.sh -- plus every state the root master renders. SOC mounts
/opt/so/saltstack rw as uid 939, so root-owning /usr/sbin alone was not
enough: the next highstate would copy attacker-controlled bytes out of the
tree into the root-owned destination and run them.

SOC never writes under default/, it only reads it. Every SOC write targets
local/, which stays socore-owned, as does /opt/so/state. No mode is enforced
on default/ -- SOC reads that tree, and 750/640 would break its config load.

Also stops copy_new_files(), so-saltstack-update and setup from chowning the
tree back to socore, and replaces preserve: True in soup_scripts.sls, which
carried uid/gid in from the /tmp staging tree and would have undone the
ownership before the first post-soup highstate.
2026-09-16 10:34:21 -04:00
Josh Patterson 1e86be11b2 FIX: install /usr/sbin management scripts as root
Salt installed the so-* scripts into /usr/sbin owned by unprivileged service
UIDs (939/socore, plus 930-960 per service) at mode 755, while root executes
those same files from cron, systemd and state cmd.run. Any file-write
primitive as one of those UIDs was therefore root.

Two mechanisms behind this are not visible in the diff:

file.recurse also manages the destination directory, so /usr/sbin itself was
chowned to whichever service UID ran last. A directory's owner may always
chmod it, so that UID could replace even the scripts already declared
user: root -- so-config-backup, so-suricata-eve-clean, so-nsm-mount-nvme.
usr_sbin_perms now pins the directory to root:root 555, the mode the
filesystem RPM ships.

Omitting user:/group: is a no-op on files that already exist, because
check_perms only chowns when a user is named. Explicit user: root is what
lets upgraded grids self-heal on the next highstate, and what makes a
revert chown back rather than silently do nothing.
2026-09-16 10:34:20 -04:00
Josh Patterson 33c24cd136 Merge remote-tracking branch 'origin/3/dev' into saltthangs 2026-06-26 15:42:56 -04:00
Mike Reeves b0b022c3ad Seed an empty /nsm/kernelrepo so the manager repo is always valid
so-repo-sync only populates /nsm/kernelrepo after the highstate, so on a
manager the file:///nsm/kernelrepo repo could be assigned before any
repodata exists, failing every dnf op. Run createrepo on the dir when
repodata/repomd.xml is missing, leaving a synced repo untouched.
2026-06-24 13:23:25 -04:00
Mike Reeves 698a746d6d Add UEK8 kernel repo support across install and grid
Mirror the kernel repo to full parity with the main package repo so the
grid can pull the Oracle UEK8 kernel:

- setup/so-functions: securityonion_repo() emits a [securityonionkernel]
  section in every branch (mirrorlist on non-airgap, https://$MSRV/kernelrepo
  for airgap/minion, file:///nsm/kernelrepo/ for manager); repo_sync_local()
  and create_repo() sync and build /nsm/kernelrepo.
- manager/init.sls: create /nsm/kernelrepo and deploy mirror-kernel.txt.
- nginx/enabled.sls: serve /nsm/kernelrepo at https://<repo_host>/kernelrepo.
- repo/client/oracle.sls: add so_kernel_repo, gated by
  onlyif test -e /opt/so/state/nic_names_pinned so the kernel repo is only
  assigned once NICs are pinned by MAC.
- update_packages(): run so-nic-pin before the dnf update that pulls the
  kernel, freezing interface names and dropping the pin marker so the kernel
  isn't downgraded then re-upgraded on the first highstate.
2026-06-23 13:19:56 -04:00
Josh Patterson f7d2994f8b filter temp files 2026-04-30 09:16:22 -04:00
Mike Reeves afc14ec29d Remove non-Oracle Linux 9 support from salt states
Simplifies salt states, map files, and modules to only support
Oracle Linux 9, removing all Debian/Ubuntu/CentOS/Rocky/AlmaLinux/RHEL
conditional branches.
2026-03-16 16:58:39 -04:00
DefensiveDepth 271f545f4f Fixup Airgap 2025-12-06 15:26:44 -05:00
DefensiveDepth 1284150382 Move to manager init 2025-11-27 08:39:19 -05:00
DefensiveDepth ced3af818c Refactor for Airgap 2025-11-25 13:51:50 -05:00
reyesj2 348f9dcaec prevent multiple script instances using file lock 2025-09-05 10:01:24 -05:00
reyesj2 e26310d172 elastic agent offline alerter
Signed-off-by: reyesj2 <94730068+reyesj2@users.noreply.github.com>
2025-09-02 17:00:03 -05:00
Josh Brower b428573a0a Airgap tweaks 2025-06-06 17:48:49 -04:00
Josh Patterson 19514a969b use file.directory 2025-04-23 08:41:53 -04:00
Josh Patterson 77f88371b8 manage default and local in separate states 2025-04-23 08:30:37 -04:00
Jason Ertel 0047246cf2 reduce stdout verbosity 2025-03-04 10:55:12 -05:00
reyesj2 a373d96c3c run managed_soc_annotations.sls from manager state 2025-01-27 13:45:03 -06:00
Josh Patterson b3ce624fff Merge pull request #13921 from Security-Onion-Solutions/reposynccron
only enable repo sync cron if OEL
2024-11-08 16:16:48 -05:00
m0duspwnens ee4405e75e only enable repo sync cron if OEL 2024-11-08 16:13:44 -05:00
defensivedepth c509dab5f1 Use socore user 2024-10-30 11:03:14 -04:00
defensivedepth 5406a263d5 Add local custom template 2024-10-29 19:42:06 -04:00
m0duspwnens 7a0f6d5e93 fix pkg name 2024-10-22 16:42:01 -04:00
m0duspwnens 8d2ae23ae6 install createrepo on airgap and non airgap 2024-10-22 13:56:38 -04:00
reyesj2 680e84851b Re-add manager sbin_jinja file recurse
Signed-off-by: reyesj2 <94730068+reyesj2@users.noreply.github.com>
2024-06-24 12:27:52 -04:00
weslambert 13062099b3 Remove YARA script update and reference to exclusions 2024-05-13 18:04:16 -04:00
Mike Reeves 283939b18a Gather metrics from elastic agent to influx 2024-04-02 15:36:01 -04:00
weslambert f431e9ae08 Remove Strelka config 2024-03-21 10:06:25 -04:00
weslambert 34d5954e16 Fix indent 2024-03-11 09:12:05 -04:00
Josh Brower 4a9e8265ce Merge remote-tracking branch 'origin/2.4/dev' into kilo 2024-03-08 14:48:04 -05:00
Wes 4e32935991 Add Strelka config back 2024-03-08 16:24:37 +00:00
Mike Reeves 1fe8f3d9e4 Merge pull request #12405 from Security-Onion-Solutions/repochange
Manage the repo files
2024-02-29 14:01:48 -05:00
Mike Reeves 9ca0f586ae Manage the repos 2024-02-21 11:45:02 -05:00
Corey Ogburn 858166bcae WIP: Detections Changes
Removed some strelka/yara rules from salt.

Removed yara scripts for downloading and updating rules. This will be managed by SOC.

Added a new compile_yara.py script.

Added the strelka repos folder.
2024-01-30 15:43:51 -07:00
Jason Ertel 9231c8d2f2 replace reset sed with new script 2023-11-08 19:17:32 -05:00
defensivedepth 310a6b4f27 Add kibana curl config 2023-10-24 14:21:01 -04:00
Mike Reeves 95d32cb076 Fix manager cron logic 2023-09-28 12:49:46 -04:00
Mike Reeves 5040df7551 Fix manager cron logic 2023-09-28 12:32:40 -04:00
Mike Reeves 7a21b7903d Fix manager cron logic 2023-09-28 11:46:43 -04:00
Mike Reeves a77a53f20b Update init.sls 2023-09-28 11:10:17 -04:00
m0duspwnens da27fce95f run so-yara-download/update if scripts change 2023-07-11 13:48:26 -04:00
m0duspwnens f8ed2e6e8e make parent dirs 2023-07-10 16:11:45 -04:00
m0duspwnens 1ac72e5b24 ensure /nsm/rules/yara directory exists 2023-07-10 11:10:37 -04:00
m0duspwnens fa933d3f53 use file_mode 2023-07-10 10:26:30 -04:00
m0duspwnens f4dc73a206 yara download and update 2023-07-10 09:42:37 -04:00
m0duspwnens 8be5082b60 yara scripts 2023-07-07 16:43:26 -04:00
m0duspwnens 5b06aa518e makedirs if needed 2023-05-10 15:55:21 -04:00
m0duspwnens 54c9a3ec71 enable/disable each strelka container in ui 2023-05-10 15:50:07 -04:00
Mike Reeves d7972032e4 Update init.sls 2023-05-05 10:33:11 -04:00
Mike Reeves cbd1c05929 Sbin Changes 2023-05-04 10:36:03 -04:00