# Check a password login against the account's policy

Start with a real SSH service's accepted-password event, then ask whether that account should have accepted a password on that host at that time. This companion supplies native-source hunt starters and a local policy comparison. A conflict is a reason to investigate an authorized change, bad inventory, a configuration problem, or unauthorized access. It is not proof of SSHOLE exploitation or compromise.

**Research hunt starters.** Native vendor execution, alert creation, and customer-tenant validation have not been performed. [VALIDATION.md](VALIDATION.md) separates the local fixture checks from those pending checks. Nothing here enables a rule or sends data anywhere.

## First use

1. Choose one authorized organization/workspace and the real producing hosts. Exclude decoys, demonstrations, and copied log examples. Confirm the authentication source is arriving for a known host and time window before interpreting a search with no results.
2. Run the relevant candidate query below. Replace its source placeholders and narrow host/time scope. Review the original event, its source, timestamp, account, and authentication method. A routine password login is an expected candidate.
3. Obtain a trusted account-policy history from the asset owner or configuration/change system. Preserve only the intended policy, identity, validity interval, and evidence reference. Do not export shadow contents, password hashes, or passwords. A username or a current configuration snapshot is not historical account policy.
4. Compare the event with exactly one policy interval for the same scope, producing asset, and case-sensitive account. Use the worksheet and local script below, or reproduce the same join in an established inventory system. Missing or conflicting information remains an explicit gap.
5. For unexpected password acceptance, check authorized changes, effective service/account configuration, clock quality, and subsequent activity with the host owner. Preserve source evidence before deciding whether compromise occurred.

## Native sources and prerequisites

| File | Reads | Prerequisites and meaning |
|---|---|---|
| [microsoft-syslog.kql](queries/microsoft-syslog.kql) | Azure Monitor / Sentinel `Syslog`, `ProcessName`, `SyslogMessage`, and native host/time fields | Linux Syslog collection through Azure Monitor Agent and a DCR including the actual authentication facility/severity; authorized Log Analytics query access and retained data. This is not a Defender Advanced Hunting table. |
| [elastic-system-auth.esql](queries/elastic-system-auth.esql) | System integration `logs-system.auth-*`, `system.auth.ssh.event`, and `system.auth.ssh.method` | Auth file/journald data stream enabled and parsed, mapped ECS host/account fields, ES\|QL-capable Elasticsearch and query privileges. The current System integration documentation lists Basic subscription and its own minimum Kibana version; check the installed package. This query is ES\|QL, not Kibana KQL. |
| [splunk-sshd.spl](queries/splunk-sshd.spl) | Real raw Linux authentication logs, `_raw`, `_time`, and source metadata | Splunk Enterprise/Cloud SPL1 search access to an indexed auth source; use the site's actual index and sourcetype. No CIM data model or premium security add-on is assumed. The supplied regex expects a `sshd[pid]:` or `sshd-session[pid]:` program prefix. |
| [sumo-sshd.sumo](queries/sumo-sshd.sumo) | Real raw Linux authentication logs and Sumo's source/time metadata | Installed or hosted collection of the auth logs, a selected `_sourceCategory`, retained Log Search data, and query access. Set a seven-day or incident-specific window in the search UI. This is Log Search, not a Cloud SIEM rule. The same program prefix is required. |

The raw parsers support the ordinary `Accepted password for USER from ADDRESS port PORT ssh2` form, including IPv6 text and optional trailing details. Microsoft also allows its message body without a program prefix because `ProcessName` is separate. They do not parse every localization, syslog envelope, keyboard-interactive/PAM method, or custom gateway format. If a known event is absent, inspect the original source and adjust/test the parser rather than treating the absence as a clean finding.

Source filters, tenancy, time bounds, export caps, and read permissions remain real controls. The seven-day window is a starting point, not a measured attack window. Microsoft uses `TimeGenerated` for search scope but returns `EventTime` too; a relay can change their relationship. Check source clocks and event time before joining policy. Elastic's query has a 10,000-row cap; count candidates separately by replacing `KEEP`/`LIMIT` with `STATS candidate_count = COUNT(*)`, then split smaller windows if needed. For every platform, compare the export count with the search count and check result limits. A truncated export is incomplete.

The [Linux/sshd Sigma selector](sigma/linux-sshd-accepted-password.yml) uses the standard source and a raw-message keyword. It is intentionally broader than the native parsers and has informational severity. A normal accepted-password event matches. Verify your Sigma backend's raw-message mapping and source selection; no backend conversion is claimed here.

## A policy worksheet, not another telemetry table

`policy_join.py` reads two local CSVs and prints JSON. It does not authenticate a collector, ingest raw logs, look up a tenant, or establish whether a policy file is trustworthy. The analyst and asset owner supply verified inputs. The CSV columns below are worksheet columns, not fields claimed to exist in any vendor product.

The event worksheet needs:

```text
scope,event_ref,event_time,asset_key,username,auth_result,auth_method
```

`scope` identifies the authorized organization and collector/workspace namespace. `event_ref` points to one original source event or a retained export row; it must be unique within that scope. Keep the source query, UTC window, original export hash, and a stable row/source locator beside the worksheet. Do not manufacture event identity by hashing only a log message; different events can have identical messages. Resolve duplicate export copies before joining.

Map producing identity and time deliberately:

| Source result | Worksheet mapping to verify |
|---|---|
| Microsoft | `EventTime` with verified timezone/clock behavior becomes `event_time`; map `_ResourceId` and authenticated origin to `asset_key`. For relays, `_ResourceId` or `Computer` may identify the collector rather than the SSH host. `ssh_user` becomes `username`. |
| Elastic | `@timestamp` becomes `event_time`; verified `host.id` becomes `asset_key`; `user.name` becomes `username`. Do not substitute `agent.id` for the producing host. |
| Splunk | `_time`, after verified timezone parsing, becomes `event_time`; authenticated producing `host`/source mapping becomes `asset_key`; `ssh_user` becomes `username`. Check whether `host` was rewritten to a relay. |
| Sumo | `_messageTime` is milliseconds since epoch; convert to timezone-aware UTC. Verify the origin behind `_sourceHost` and `_sourceName` before assigning `asset_key`. `_sourceHost` can reflect reverse DNS or `localhost`; it is not automatically a stable asset ID. `ssh_user` becomes `username`. |

Use `auth_result=accepted` and `auth_method=password` only after verifying the candidate event. Preserve account case and namespace exactly. Host aliases need an approved inventory mapping; do not join a source IP or a globally reused hostname to an account policy by guesswork. Keep unknown identities out of the join and assign collection work.

The policy CSV needs:

```text
scope,asset_key,username,valid_from,valid_until,policy,evidence_ref
```

Allowed policy labels are `key_only`, `password_allowed`, and `unknown`. `key_only` means the owner intended no password login during the interval; record how that was established in `evidence_ref`. It is not a diagnosis of the affected password-checking implementation. Use timezone-aware ISO 8601 timestamps. Intervals include `valid_from` and exclude `valid_until`. A policy change creates a new interval. Do not project today's setting backward without evidence.

Try the synthetic examples with Python 3.10 or newer:

```shell
python policy_join.py --events fixtures/events.csv --policy fixtures/policy.csv
python tests/test_companion.py
```

The example produces one unexpected-password-acceptance outcome, one ordinary password-allowed outcome, and one missing-policy outcome. Missing or overlapping state, invalid intervals, unknown policy, missing identity, and an empty export remain visible. Duplicate event references stop the comparison rather than inflating a count. An invalid policy row for the same scope/asset/account blocks a confident result until repaired. The script does not fill missing state, lowercase account names, or declare the environment healthy.

## Separate endpoint follow-on

After identifying a host and incident window, [crowdstrike-temp-execution.cql](queries/crowdstrike-temp-execution.cql) searches native Linux `ProcessRollup2` records for an executable image under `/tmp`, `/var/tmp`, or `/dev/shm`. Replace `aid` with the affected host's Falcon ID and set the incident window in Advanced Event Search. This requires a supported Linux sensor, retained process events, and entitlement/access to the relevant Falcon CQL event search. Generic LogScale without those sensor records is insufficient.

The image path is a process observation. Inspect the original `CommandLine`, parent basename, file identity/hash where available, authorized software activity, and network/file evidence. Installers and test tools can run from temporary directories. The query does not look for every `curl` invocation, infer SSH origin from a process, or require `sshd` to be its immediate parent. A shell intermediary often breaks that direct-parent assumption. A parent basename is context, not full ancestry or session binding. A script passed as `sh /tmp/a.sh` has a shell image and will not match this executable-path hunt. No native third-party SSH authentication mapping for Falcon is supplied or assumed.

The [separate Linux process Sigma rule](sigma/linux-temp-process.yml) represents the same image-path triage idea with conventional `Image` and `linux/process_creation`; its exact sensor/backend mapping still needs verification. Do not turn either follow-on selector into proof that a downloaded file ran, a successful authentication led to it, or an exploit occurred.

## When password-length telemetry is unavailable

Ordinary sshd authentication logs do not record the attempted password or its length. Encrypted packet size cannot safely replace that field. Use the authentication/policy workflow above and review exposure and fixed packages. Optional auth-boundary or honeypot instrumentation belongs to a separate engineering effort; see [advanced-collection.md](advanced-collection.md). No plaintext credential capture is needed for this companion.

See [SOURCES.md](SOURCES.md) for source and field documentation, and [VALIDATION.md](VALIDATION.md) for exact test scope and receiving-environment checks.
