An AppSec-led Linux fleet investigation: legitimate-looking persistence, DFIR evidence, scalable hunts, business impact, and rebuild-or-reuse decisions
Expanded field notes · November 2026 · An AppSec-led Linux fleet investigation: from an uncomfortable handover to an evidence-backed business decision.
There is a special kind of silence in an engineering meeting when somebody asks a perfectly reasonable question:
“The DevOps engineer is gone. He built most of this environment. We didn't exactly part on good terms. OMG! Are we sure the servers are clean?”🤪
And everybody looks at Security. Ahaha.. but seriously.. 🤡
Not at the antivirus dashboard. Not at the person who owns Kubernetes. At Security. Yep, man. More precisely, at the Application Security guy who happens to be in the room. Wow! Congratulations: your job description just got a free expansion. :)
I encountered this category of problem while working on the Product Security / Application Security side. I was not brought in as a full-time forensic investigator. My responsibility was to protect the product, its development environment, and its delivery chain. But the engineer who had been operating much of the Linux infrastructure had left under difficult circumstances, the relevant operational knowledge was concentrated in one person, and there was no other specialist ready to take over the security review. So the task landed on my desk.
The uncomfortable part was not the Linux commands. It was the question behind them:
Can we keep using an environment whose previous privileged operator is no longer trusted — and what evidence would justify that decision?💀
This is an anonymized account of the problem and the approach. The company, architecture, number of hosts, timelines, and actual investigation outcome are not disclosed under NDA. Any hostnames, observations, and report excerpts below are synthetic teaching examples, not claims about the real engagement. The commands and decision model are intended to be practical, not a reconstruction of private evidence.
One more distinction before we start: a difficult departure is not proof of malicious behavior. We investigate access and integrity risks, not a former colleague's personality.
📌Disclaimer
All code samples are for authorized defensive investigation. Validate against your distro, architecture, risk tolerance, and incident-handling requirements before production use.
1. A working product is not necessarily a trusted product
Picture a fairly ordinary software company. Its Linux machines host development environments, self-hosted runners, build agents, staging services, internal tooling, containers, and sometimes the parts of CI/CD that eventually touch production. The applications are running. The pipelines are green. Nobody is reporting an incident.
That does not tell us whether the underlying access paths are legitimate.
A former administrator with sufficient access could have left behind a completely ordinary-looking mechanism:
- a public key in an existing user's
authorized_keys; - a second UID 0 account or an unexpected sudo grant;
- a
systemdservice, user unit, timer, or cron job; - a reverse tunnel or persistent outbound session;
- modified
sshdsettings, firewall or NAT rules; - an additional CI/CD runner, webhook, deploy key, cloud role, or Kubernetes credential;
- a changed startup script or binary outside package management.
Some of these are legitimate administration patterns. That is precisely why finding a file or a port is not the same as finding an attacker.
The goal is not to “find malware.” The goal is to reconstruct the trust boundary and establish whether someone still has a path back into the product.
A quick threat model helps:
Former privileged operator | +--> Identity: SSH, sudo, PAM, cloud IAM, VPN, SSO | +--> Persistence: systemd, cron, startup scripts, containers | +--> Remote control: inbound ports, outbound tunnels, control planes | +--> Supply chain: Git, CI/CD, runners, registries, signing keys | +--> Data / operations: backups, databases, secrets, deployment rights | v Product integrity + business impact MITRE ATT&CK specifically documents SSH authorized-key manipulation (T1098.004), systemd service persistence (T1543.002), and cron abuse (T1053.003). These are not exotic zero-days. They're familiar operating-system features used in an unfamiliar way.
The most convincing backdoor looks like business as usual
Here is the misconception I would challenge first: "We ran antivirus, so there can't be a backdoor." Antivirus is useful for known malware. It is not designed to decide whether a valid SSH key, a legitimate systemd unit, a cloud role, or an approved-looking automation runner should exist. A carefully chosen use of an ordinary administration feature may not require malicious code at all. That makes authorization and provenance, not merely signatures, central to the investigation.
| Legitimate-looking mechanism | Why a scanner may miss the risk | What I would verify |
|---|---|---|
| Existing user + extra SSH key | A public key is not malware; service accounts often have multiple keys | Key fingerprint → owner → change approval → login history → alternate key sources |
| Service/timer named like monitoring | systemd is supposed to start services | Unit contents, drop-ins, ExecStart, author, package ownership, destination, change history |
| Automation token or deploy key | CI/CD credentials are normal business objects | Issuer, privileges, last use, expiry, where stored, who can rotate it |
| Self-hosted CI runner | Runners legitimately execute arbitrary builds | Registration provenance, runner labels, job history, secret scope, egress |
| IAM trust policy / Kubernetes role | Nothing suspicious needs to be on the Linux disk | Control-plane audit log, role bindings, assumable identities, privilege scope |
| Remote management tunnel | Bastions and troubleshooting tools do this all the time | Business justification, process ancestry, relay endpoint, persistent configuration |
This is not a claim that an unhappy former employee must have planted something. It is a threat model for validating what a once-authorized privileged identity could have done. MITRE ATT&CK covers SSH authorized-key manipulation, systemd timers, and additional Kubernetes roles. The common theme is the abuse of normal features.
From a shell on a build runner to a business incident
The business impact is not limited to someone reading /etc/passwd. Depending on that machine's privileges, an unauthorized operator could potentially:
| Access available | Plausible consequence | Business exposure |
|---|---|---|
| Production database or snapshot credentials | Extract customer records or trade secrets | Privacy obligations, notification costs, legal/reputational damage |
| CI/CD runner with deployment secrets | Replace a build artifact, inject altered code, abuse release credentials | Supply-chain compromise, poisoned releases, loss of product integrity |
| Cloud admin or powerful service account | Change IAM, disable logging, manipulate resources | Broad loss of control, unexpected cloud costs, recovery delays |
| Backups and disaster-recovery permissions | Delete, encrypt, or invalidate restore points | Longer outage and potentially catastrophic recovery cost |
| DNS, ingress, registry or signing permissions | Redirect traffic or ship untrusted binaries | Customer impact, credential theft, brand damage |
| Monitoring / alerting control | Suppress alerts and conceal later activity | Greater dwell time and an unreliable incident timeline |
These are hypothetical blast-radius paths, not allegations or findings from the NDA case. They explain why the risk owner cares about a tiny configuration change on a very ordinary Linux host.
One real-world lesson from GitHub's self-hosted runner guidance: a persistent runner does not provide the isolation guarantees of a clean ephemeral VM. From Product Security's point of view, the runner may be part of the product's trust root, not merely "some box DevOps manages."
2. The first mistake would be to scan first and think later
I know the temptation: download five scanners, launch a fleet-wide scan, get a CSV, turn everything green, go home. But we need to answer three questions before touching the first host:
- What are we actually covering? An incomplete asset inventory makes a clean scan meaningless.
- Do we have trustworthy access? If the person we are investigating controlled our jump host, SSH keys, or automation account, the inspection channel may be compromised as well.
- What evidence can we afford to alter? Logging in, installing packages, restarting services, or replacing keys changes the system. Sometimes containment must happen immediately; sometimes forensic preservation comes first. Coordinate that trade-off with incident command, legal, and infrastructure owners.
I start with a temporary investigation boundary: a separate operator workstation or clean management host, newly authorized credentials, protected evidence storage, and an agreed change freeze for high-value infrastructure. Use out-of-band cloud or hypervisor snapshots where available and appropriate. Record the time, asset ID, account used, and collection method. Confirm time synchronization; timestamps without a known clock offset are a trap.
If there is active unauthorized access, prioritize containment; do not wait for an elegant forensic workflow while the attacker is moving. Otherwise, capture volatile process and network evidence before rebooting or reinstalling anything. This is a risk-based response, consistent with NIST SP 800-61 Rev. 3.
My first 60 minutes: stop the easy re-entry paths
With the relevant owners and an emergency-change procedure, I would:
- disable the departed person's IdP, VPN, bastion, Git, CI/CD, cloud, and remote-support identities;
- invalidate active sessions, refresh tokens, PATs, deploy keys, and credentials that person could have copied;
- check shared accounts and service identities rather than assuming disabling a named user is enough;
- remove or restrict external exposure of administrative interfaces; review inbound and outbound access;
- protect audit logs and backups with permissions outside the former operator's control;
- verify a clean break-glass path before touching the existing admin account.
Important: blindly rotating a production secret can break the application. Inventory dependencies, plan rotations, and distinguish an emergency revocation from a controlled migration. Credential rotation is part of containment and recovery — not an excuse to skip evidence collection.
Preserve the story before the story changes
For a real investigation, I maintain a short evidence and decision log from minute one. Not glamorous; absolutely necessary. At minimum:
- Incident or assessment ID, authorized scope, assigned owner, and whether this is preventive offboarding review or confirmed incident response.
- UTC acquisition time and source clock/time offset, collector version/hash, operator identity, access path, host/cloud resource ID.
- Whether evidence was collected live, from a snapshot, from existing EDR, or from independently retained cloud/audit logs; record collection failures as first-class results.
- Original data location, acquisition digest, restricted storage destination, subsequent handling and access history. A SHA-256 hash detects later changes only if the starting point and collection path are trustworthy.
- Decisions taken before collecting evidence (revoke a token, quarantine network, stop a workload), with rationale and approval.
A host with potential root compromise can lie through ps, ss, find, package tools, or even an installed sensor. Live SSH output is a triage signal, not independent proof of absence. Independent cloud control-plane logs, historical EDR telemetry, trusted snapshots, golden images, and artifact signing are complementary sources. For particularly sensitive cases, bring in experienced DFIR/legal personnel to preserve evidence with suitable procedures; I am describing an AppSec-led first response, not a substitute for a forensic laboratory.
Also avoid relying on a magical “last 30 days” cutoff: the suspected change may predate offboarding, and timestamps can be manipulated. Build a timeline around last independently trusted state, last known authorized admin activity, actual departure, credential revocation, and present.
This aligns with the risk-management framing of NIST SP 800-61 Rev. 3 (April 2025): prepare, detect, respond, recover, and explicitly manage remaining uncertainty.
3. Define coverage. Otherwise “all clear” means “all reachable”
The fleet is rarely just /etc/hosts on a laptop. I would join several inventories: cloud instances, virtualization inventory, Terraform state and IaC, CMDB, SSH/Ansible inventories, Kubernetes nodes, CI runners, and DNS. Then I would reconcile them.
For every asset, I want at least: asset_id, hostname, environment, role, owner, criticality, public_exposure, collection_status, and last_seen.
The resulting buckets matter:
| Bucket | Meaning | Action |
|---|---|---|
| In scope, collected | We have recent evidence | Analyze and assign confidence |
| In scope, unreachable | Host exists but did not respond | Unknown, escalate and collect by alternate path |
| Discovered, not in inventory | Shadow asset | Identify owner; prioritize |
| Ephemeral / terminated | Host may have disappeared | Preserve cloud, orchestration, and historical logs |
| Out of scope by design | Explicitly excluded | Document why and who approved it |
I measure coverage, not just detections: collected / in-scope, with an explicit unknown count. If 18 of 100 machines never responded, “82 clean” does not turn into “100 secure” because PowerPoint looks nicer that way.
4. The tools: no silver bullet, just complementary evidence
My practical stack is intentionally layered. If the environment already has a capable EDR or osquery deployment, use it. A crisis is a poor moment to install random security agents on every production machine.
| Tool | Model / cost | What I use it for | Important limitation |
|---|---|---|---|
| OpenSSH + supplied read-only collector | Built-in / free | Fast first-pass collection, parallelized from a clean workstation | Depends on reachable hosts and integrity of host tools |
| Velociraptor | Open source; server + clients, with additional collection modes | Targeted DFIR artifacts and fleet-wide hunts | New deployment requires care; collection changes endpoints and consumes resources |
| osquery + Fleet | Open-source query engine; Fleet has free and commercial capabilities | Cross-host SQL inventory and drift detection | Queries see only what the OS and enabled telemetry expose |
| Wazuh | Open source, generally agent-based | FIM, configuration monitoring, alerting over time | A baseline established after a compromise is not a trusted historical baseline |
| YARA | Open source | Match curated rules against selected files or acquired samples | Signature/heuristic matches are leads, not proof; absence is not exoneration |
| Lynis / chkrootkit / rkhunter | Free/open source | Supplementary hardening and known-artifact checks | Not a substitute for DFIR; false positives and blind spots |
| Sandfly Security | Commercial, agentless SSH-based Linux investigation | Fast Linux-specific triage without persistent agents | Licensed product; SSH access and server-side visibility still matter |
| CrowdStrike / SentinelOne / Elastic Security | Commercial or mixed licensing | Existing EDR telemetry, response, historical hunting | Value depends on deployment coverage and retention |
If I could pick one fast route without a purchase order, it would be: parallel SSH triage → anomaly comparison → targeted Velociraptor collection → package integrity / YARA where indicated → control-plane review → risk disposition.
The Velociraptor Hunting documentation explains fleet collections and explicitly warns about data volumes; deployment options include clients, agentless collection, and offline collectors. Fleet/osquery offers live queries, while Wazuh FIM works by comparing observed files against an established baseline. Sandfly describes its agentless IR workflow directly.
What I would add to the shortlist — and what I would not expect from it
AIDE (with a baseline established before the concern, protected outside the host) can provide useful file-integrity drift. Falco or Tracee can add Linux runtime behavioral telemetry to an already supported and approved monitoring architecture. They observe events after deployment; they cannot reconstruct yesterday's unlogged process. A brand-new detection baseline created today may simply describe today's compromised state. Tracee uses eBPF and can be powerful, but deploying privileged kernel instrumentation during evidence preservation is a conscious trade-off, not a casual first step.
A commercial Linux-focused agentless option such as Sandfly is particularly relevant here. Its current documentation covers automated compromise checks and forensic collection via SSH; its June 2026 product update also describes optional response actions, which I would keep disabled until authorized during evidence-only triage. Agentless does not mean "no endpoint interaction" or "immune to compromised-host deception." It means no persistent agent needs to be installed on those targets.
Tool selection by question, not brand:
| Question | First choice | Escalation |
|---|---|---|
| Which hosts, accounts and services exist? | SSH collector or existing osquery | Velociraptor artifacts, alternative collection path |
| What differs from a trusted state? | Change approvals, IaC and previous inventories | Protected AIDE/FIM history, independent images |
| Is suspicious activity ongoing? | Existing EDR, process/network telemetry, cloud logs | Controlled runtime sensor / focused IR acquisition |
| Does a specific file match known indicators? | YARA against acquired/selected files | Forensic analysis and validated threat intelligence |
| Could someone deploy untrusted code tomorrow? | Git/CI/CD/IAM/registry audit | New runners, credential revocation, signed build path |
And one careful correction to the usual advice: chkrootkit, rkhunter, or Lynis do not assert that an OS is clean. Even the Debian debsums manual describes its security value as limited.
Installation and first-run order (without destroying evidence)
For the initial pass, nothing needs to be installed on the suspicious servers: Python 3 and OpenSSH run on a clean operator machine, and the Bash collector is streamed over an approved SSH session. Test it against one non-critical, representative Linux machine before expanding the concurrency.
For targeted second-pass checks, prepare a separate, trusted Ubuntu/Debian analysis VM. A minimal optional toolkit can be installed there:
# On the clean ANALYSIS VM — not on unpreserved suspect hosts: sudo apt-get update sudo apt-get install --no-install-recommends yara lynis yara --version lynis --version debsums is available as a distribution package for Debian/Ubuntu, but running it against a live suspect system after installation changes evidence; prefer pre-existing tooling or an approved acquisition workflow. To run YARA against a selected acquired file, first review the rules and then use the targeted example below. To assess Linux hardening in a separate lab or after evidence preservation, use sudo lynis audit system; its audit is broader than a backdoor search and produces logs, so it is not part of our initial read-only collector.
For Velociraptor, follow the official deployment quickstart: download the appropriate release to a separate server, verify the release artifacts, generate server configuration, restrict the GUI, and provision authorized Linux client collection. An isolated loopback test lab can use ./velociraptor gui; this convenient demo mode is not a production deployment. For real use, configure authentication/TLS and privileges appropriately, test Linux artifacts on one endpoint, and only then open a controlled Hunt.
For osquery/Fleet, deploy supported signed packages and enrollment according to Fleet documentation; after enrollment, verify the host appears in the console, check its supported SQL tables, and run a one-host live query before a scheduled fleet query. osqueryi is useful for local, temporary query testing if already installed. For Wazuh, the official Quickstart guides deployment of central components on a separate trusted machine; agents and FIM baseline should be introduced under an approved change, ideally after the acute response. Sandfly requires its licensed management environment and approved SSH access; start with a small scoped Linux group, not every reachable asset simultaneously.
If the company already has an EDR, Fleet, Wazuh, or Velociraptor deployment, use that first. Do not build a parallel monitoring platform in the middle of an active compromise just to satisfy a checklist.
5. First pass: collect, don't “clean”
For repeatable collection, I include a small companion toolkit in the downloadable article archive:
linux_trust_after_devops_v2/ 01_EN_devto.md 02_RU_devto.md tools/ linux_triage_readonly.sh fleet_triage.py review_manifest.py hosts.example.txt examples/ example_findings.csv synthetic_evidence.txt templates/ executive_report_example.md risk_register_template.csv README.md It uses Python on the operator machine to run a Bash collector over SSH on multiple hosts. It does not install a package, persist a script, change firewall rules, remove accounts, or reboot anything. Results stay on the operator machine under restrictive permissions, with a per-host SHA-256 digest and a collection manifest.
Prerequisites: Linux/macOS investigator machine with Python 3 and OpenSSH; trusted host keys in known_hosts; SSH access to targets; sudo -n permission to run read-only commands; explicit approval from the system owner. Never disable host-key verification to “make the scan work.”
Create an inventory based on the provided example:
# tools/hosts.txt (illustrative, replace with real authorized targets) ir-audit@build-01.example.internal ir-audit@app-stg-02.example.internal ir-audit@runner-03.example.internal Then run from the extracted archive root:
python3 tools/fleet_triage.py \ --hosts tools/hosts.txt \ --out ./evidence-2026-11-13 \ --workers 6 \ --timeout 120 The script writes manifest.csv, manifest.sha256, and raw/<host>.txt collection files; errors are noted in the manifest. Then use python3 tools/review_manifest.py ./evidence-2026-11-13 to generate a separate offline quality-review queue (outside the evidence folder); this checks collection limitations, not threats. It is a triage collector, not a forensic imaging system or compromise detector. Review the README before using it against production.
For a single host, these are the kinds of questions the collector answers:
⚠️Identity and access
awk -F: '$3 == 0 {print $1 ":" $3}' /etc/passwd getent passwd find /etc/sudoers.d -maxdepth 1 -type f -print 2>/dev/null sshd -T 2>/dev/null | grep -E '^(permitrootlogin|authorizedkeysfile|passwordauthentication|pubkeyauthentication) ' Review authorized_keys across actual home directories from the account database, not only /home/*. Compare SSH-key fingerprints with a known-good source. Include SSH certificates/authorized principals and AuthorizedKeysCommand when configured. Do not upload raw credentials or private keys into a public ticket.
⚠️Scheduled persistence and startup
systemctl list-unit-files --type=service,timer --state=enabled --no-pager systemctl list-timers --all --no-pager find /etc/systemd/system /usr/local/lib/systemd/system \ -type f -mtime -30 -print 2>/dev/null find /etc/cron.d /etc/cron.daily /etc/cron.hourly \ -maxdepth 2 -type f -print 2>/dev/null Also inspect per-user cron, at jobs, systemd --user units, drop-in overrides, PAM hooks, /etc/profile.d, shell startup files, and container restart policies. A -mtime -30 filter is a prioritization hint, not a complete threat-hunting method: timestamps can be changed, and a malicious artifact may be years old.
⚠️Runtime and network
ss -lntup ss -tanp ip route show nft list ruleset 2>/dev/null iptables-save 2>/dev/null A listening socket or an unfamiliar outbound IP is a candidate finding. Correlate it with the owning process, executable path, systemd unit, deployment, logs, and expected service architecture. If a reverse tunnel is suspected, collect evidence before killing it where incident safety allows. Also remember: a periodic callback may not be active at the instant you run ss.
⚠️Integrity and package ownership
# Debian / Ubuntu: if debsums is already installed debsums -c 2>/dev/null # RHEL-like distributions rpm -Va # Investigate individual suspicious paths stat /path/to/suspect sha256sum /path/to/suspect A changed package file is not automatically a backdoor. Configuration updates, vendor behavior, and legitimate administration can explain differences. More importantly, package databases on a potentially compromised host are not independent sources of trust. Debian's own debsums manual says it has limited use as a security tool. Use signed reference images, known-good artifacts, package provenance, or trusted external snapshots for stronger comparisons. rpm -Va checks recorded attributes; it cannot verify arbitrary files outside its package database.
Do not run a blind find / plus a recursive YARA scan across production databases, object mounts, and virtual filesystems. Target suspected paths and acquired samples, and cap resource use:
# Only after reviewing the rules and selecting an approved target: yara --timeout=30 /opt/ir/rules/reviewed_rules.yar /opt/ir/samples/suspect_file The YARA CLI reference documents this syntax. Rules need provenance and testing; an IoC may become stale, and a false positive may look surprisingly convincing.
What a useful sanitized finding looks like
The hardest part isn't spotting an odd name. It's joining artifacts across independent sources. Here is a fully synthetic sequence that illustrates the logic; the addresses are documentation-only TEST-NET ranges, not real infrastructure.
🚨Signal A — a normal-looking service, unexpected provenance.
$ systemctl list-unit-files --type=service | grep telemetry telemetry-bridge.service enabled enabled $ systemctl show telemetry-bridge.service \ -p FragmentPath -p DropInPaths -p User -p ExecStart FragmentPath=/etc/systemd/system/telemetry-bridge.service DropInPaths= User=svc-ci ExecStart={ path=/usr/local/bin/telemetry-bridge ; ... } $ systemctl cat telemetry-bridge.service # /etc/systemd/system/telemetry-bridge.service [Unit] Description=Telemetry bridge for build fleet [Service] User=svc-ci ExecStart=/usr/local/bin/telemetry-bridge --config /etc/telemetry/bridge.yaml Restart=always [Install] WantedBy=multi-user.target Nothing there proves malicious behavior. It could be an entirely legitimate internal tool. But package inventory, IaC, and the approved service catalog have no owner for it. The binary's origin is not yet established. That is an unexplained deviation, not a confirmed implant.
🚨Signal B — a network relationship to explain.
$ ss -tnp | grep 203.0.113.42 ESTAB 0 0 10.10.4.23:51862 203.0.113.42:443 users:(("telemetry-bridge",pid=2147,fd=11)) A TCP session to port 443 may be expected telemetry traffic. Now I want the process owner, command-line metadata, service logs, endpoint ownership, and the documented reason the CI runner contacts it. Do not equate an external IP with a command-and-control server.
🚨Signal C — SSH access that survives account offboarding.
$ ssh-keygen -lf /home/svc-ci/.ssh/authorized_keys -E sha256 256 SHA256:7aQ2EXAMPLEsyntheticFingerprintNOTREAL ci-deploy (ED25519) The fingerprint in this sample is illustrative text, not a real key-derived digest. A reviewer would compare actual fingerprints to the organization's approved key registry and look for SSH login events. One missing ticket is insufficient evidence of malicious intent; an unowned key plus unexplained external connectivity plus high-value runner privileges does justify urgent investigation.
Safe follow-up commands on an authorized host, with triage impact assessed:
# Service implementation and effective properties (no restart/reload) systemctl show telemetry-bridge.service \ -p FragmentPath -p DropInPaths -p User -p ExecStart systemctl cat telemetry-bridge.service # Narrow time window; journal access and retention vary by distro journalctl --utc --no-pager -u telemetry-bridge.service \ --since '2026-11-01 00:00:00' --until '2026-11-13 23:59:59' # Example: inspect the actual account-dependent effective SSH policy sshd -T -C user=svc-ci,host=reviewer.example.internal,addr=192.0.2.44 \ | grep -E '^(authorizedkeysfile|authorizedkeyscommand|permitrootlogin|pubkeyauthentication) ' # On the clean evidence workstation, verify files against saved manifest (cd ./evidence-2026-11-13 && sha256sum -c manifest.sha256) sshd -T without -C may omit the effect of Match rules, so I pass a hypothetical client connection context (host/addr refer to the connecting client, not the server) when checking an account. The OpenSSH manual documents the parameter behavior. Journal data is not inherently tamper-proof; corroborate it with forwarded logs.
One more item for the investigator's notebook: a real-time snapshot can miss an intermittently running timer, an inactive user systemd service, a socket-activated unit, a container-level configuration, or a credential that only lives in an API. This is why I need several passes and honest collection coverage.
6. Second pass: hunt across the fleet, not just inside one box
This is where the real leverage begins. I do not want to read 200 nearly identical text files. I want to know which hosts deviate from their peer group.
I build logical cohorts: build agents vs application servers vs database nodes; production vs staging; Linux distribution; cloud account; image version. Comparing a build runner with a PostgreSQL host is a reliable way to produce impressive but useless anomalies.
With osquery, some quick starting points are:
SELECT username, uid, gid, directory, shell FROM users WHERE uid = 0; SELECT pid, port, protocol, address FROM listening_ports; SELECT pid, name, path, cmdline FROM processes; Run them through an already deployed osquery/Fleet environment or test locally with osqueryi. Exact tables and columns are version/platform-dependent; check the installed schema before creating a global scheduled query. Fleet's REST API documentation covers live reports and their offline/timeout behavior.
With Velociraptor, use the GUI to select narrowly scoped Linux-appropriate artifacts, test on one or two representatives, then launch a Hunt against a labeled cohort. Collect only what is required: users, SSH configuration/keys, scheduled tasks, service definitions, process/network metadata, and selected files. When an interesting outlier appears, pivot to deeper acquisition and event timelines.
The heuristic is not “one weird file = rootkit.” It is independent signals converging on the same asset:
Unexpected account or SSH key + newly introduced service/timer + suspicious outbound activity + no change ticket / no IaC explanation + sensitive CI/CD or cloud privileges | v High-priority investigation Practical fleet SQL: spot the outliers, then prove their meaning
If osquery is already deployed, I would use a small set of schema-checked queries; these examples correspond to published osquery tables, but verify fields against your installed version with .schema in osqueryi before rolling out a query pack.
-- An account with UID 0 deserves verification, not instant condemnation SELECT username, uid, directory, shell FROM users WHERE uid = 0; -- Linux systemd units: compare cohorts, not random hosts SELECT id, unit_file_state, active_state, fragment_path, user FROM systemd_units WHERE unit_file_state = 'enabled'; -- Cron: inspect actual execution commands and file origins SELECT path, command, minute, hour, day_of_week FROM crontab; -- Join network listeners with process metadata (snapshot only) SELECT l.address, l.port, l.protocol, p.pid, p.name, p.path, p.cmdline FROM listening_ports AS l LEFT JOIN processes AS p ON l.pid = p.pid; Source: upstream schema for systemd_units, crontab, and listening_ports. Not all tables are available on all systems, and a scheduled query is not continuous historical telemetry.
What I would actually compare: the same application role, OS image, environment and release. For example, five CI runners expected to have three custom systemd units, and one runner with a fourth. That fourth unit goes to a human review queue. It does not go straight to a list titled "attackers found."
7. The biggest trap: your servers are only half the story
Suppose the Linux host review looks fine, but the departing engineer controlled the deployment pipeline. Would I sign off on the product? Absolutely not.
Think about a hidden GitHub/GitLab deploy key, an unowned runner, a scheduled pipeline, a registry write credential, an unsigned container image, a Terraform backend, a Kubernetes ClusterRoleBinding, or a cloud IAM trust policy...





