Skip to content

armgit / AiSOC

Public Imported from GitHub
0

Open-source AI Security Operations Center: alert fusion, LLM-agent triage, MITRE ATT&CK investigation, and a replayable decision ledger for every agent step. Self-hostable, runs with no API keys, MIT licensed. Ships an MCP server for Claude, Cursor and Continue.

feat(detections): add 600 part3 native spec modules across 6 categories

Beenu Arora3db758e6665f
diff --git a/scripts/detection_specs_index.py b/scripts/detection_specs_index.py
index 47ff2fe76..3dbd6152e 100644
--- a/scripts/detection_specs_index.py
+++ b/scripts/detection_specs_index.py
@@ -2,10 +2,18 @@
AiSOC Detection Pack v1 - Combined Specification Index
======================================================
-Imports the rule tables from `detection_specs.py` and `detection_specs_part2.py`
-and exposes a single `ALL_SPECS` list grouped by category.
+Imports the rule tables from `detection_specs.py`, `detection_specs_part2.py`,
+and the `detection_specs_part3_*.py` expansion modules, then exposes a single
+`CATEGORIES` mapping plus an `all_specs()` iterator.
The category names map directly onto subdirectories under `detections/`.
+
+Tier mapping:
+* `detection_specs.py` + `detection_specs_part2.py` — original 200 hand-curated
+ native specs.
+* `detection_specs_part3_*.py` — 600 additional native specs generated through
+ the compact `S()` builder (see `detection_specs_part3_helpers.py`). These
+ follow the same fixture + MITRE quality gate as the originals.
"""
from __future__ import annotations
@@ -20,14 +28,19 @@ from detection_specs_part2 import ( # type: ignore[import-not-found]
ENDPOINT,
NETWORK,
)
+from detection_specs_part3_application import APPLICATION_EXTRA # type: ignore[import-not-found]
+from detection_specs_part3_cloud import CLOUD_EXTRA # type: ignore[import-not-found]
+from detection_specs_part3_endpoint import ENDPOINT_EXTRA # type: ignore[import-not-found]
+from detection_specs_part3_identity import IDENTITY_EXTRA # type: ignore[import-not-found]
+from detection_specs_part3_network import NETWORK_EXTRA # type: ignore[import-not-found]
CATEGORIES: dict[str, list[dict]] = {
- "cloud": CLOUD,
- "identity": IDENTITY,
- "endpoint": ENDPOINT,
- "network": NETWORK,
- "application": APPLICATION,
+ "cloud": [*CLOUD, *CLOUD_EXTRA],
+ "identity": [*IDENTITY, *IDENTITY_EXTRA],
+ "endpoint": [*ENDPOINT, *ENDPOINT_EXTRA],
+ "network": [*NETWORK, *NETWORK_EXTRA],
+ "application": [*APPLICATION, *APPLICATION_EXTRA],
"data-exfil": DATA_EXFIL,
}
diff --git a/scripts/detection_specs_part3_application.py b/scripts/detection_specs_part3_application.py
new file mode 100644
index 000000000..19cb4ee86
--- /dev/null
+++ b/scripts/detection_specs_part3_application.py
@@ -0,0 +1,227 @@
+"""
+Detection Pack v1 - Part 3 / Application (40 new specs)
+=======================================================
+
+Native application-layer detection rules covering web-app attacks, SaaS
+collaboration tools, DevOps/CI pipelines and API misuse. These extend the
+application rules in ``detection_specs.APPLICATION`` (~25 stable rules).
+"""
+
+from __future__ import annotations
+
+from detection_specs_part3_helpers import ( # type: ignore[import-not-found]
+ FP_AUTOMATION,
+ FP_FORENSIC,
+ FP_PATCH,
+ FP_PENTEST,
+ FP_TUNING,
+ S,
+)
+
+
+# ---------------------------------------------------------------------------
+# Web-app attacks (15)
+# ---------------------------------------------------------------------------
+WEB_APP_RULES: list[dict] = [
+ S(slug="app-ssti-pattern", name="Server-Side Template Injection Pattern In Request",
+ severity="high", mitre=["t1190"], product="waf", service="http",
+ when={"event_type": "http_request", "body_contains_any": ["{{7*7}}", "${7*7}", "{%7*7%}", "<%= 7*7 %>"]},
+ fp=[FP_PENTEST], playbook="tpl-initial-access"),
+ S(slug="app-xxe-pattern", name="XML External Entity Reference In Request Body",
+ severity="high", mitre=["t1190"], product="waf", service="http",
+ when={"event_type": "http_request", "body_contains_any": ["<!ENTITY", "SYSTEM \"file://", "SYSTEM \"http://"]},
+ fp=["Approved XML SOAP integration"], playbook="tpl-initial-access"),
+ S(slug="app-nosql-injection", name="NoSQL Injection Operator In Request",
+ severity="high", mitre=["t1190"], product="waf", service="http",
+ when={"event_type": "http_request", "body_contains_any": ["$ne\":", "$gt\":", "$where\":", "$regex\":"]},
+ fp=[FP_PENTEST], playbook="tpl-initial-access"),
+ S(slug="app-graphql-introspection", name="GraphQL Introspection Query Against Production",
+ severity="medium", mitre=["t1213"], product="api-gateway", service="http",
+ when={"event_type": "http_request", "uri": "/graphql", "body_contains": "__schema", "environment": "prod"},
+ fp=["Approved schema documentation generator"], playbook="tpl-discovery"),
+ S(slug="app-graphql-deep-recursion", name="GraphQL Query With Excessive Recursion Depth",
+ severity="medium", mitre=["t1499"], product="api-gateway", service="http",
+ when={"event_type": "http_request", "uri": "/graphql", "query_depth_gt": 10},
+ fp=["Sanctioned bulk export"], playbook="tpl-impact"),
+ S(slug="app-jndi-log4shell", name="JNDI LDAP Lookup Pattern (Log4Shell-Style)",
+ severity="critical", mitre=["t1190"], product="waf", service="http",
+ when={"event_type": "http_request", "any_header_value_contains_any": ["${jndi:ldap://", "${jndi:rmi://", "${jndi:dns://"]},
+ fp=[FP_PENTEST], playbook="tpl-initial-access"),
+ S(slug="app-spring4shell-pattern", name="Spring4Shell Class Loader Manipulation Pattern",
+ severity="critical", mitre=["t1190"], product="waf", service="http",
+ when={"event_type": "http_request", "body_contains_any": ["class.module.classloader", "class.classLoader"]},
+ fp=[FP_PENTEST], playbook="tpl-initial-access"),
+ S(slug="app-deserialization-rce-marker", name="Java/.NET Deserialization Marker In Body",
+ severity="critical", mitre=["t1059"], product="waf", service="http",
+ when={"event_type": "http_request", "body_contains_any": ["rO0AB", "AAEAAAD/////AQAAAAAAAAAM", "TypeObject"]},
+ fp=["Inter-service signed payload (allow-listed)"], playbook="tpl-initial-access"),
+ S(slug="app-cookie-tampered-hmac", name="Session Cookie Failed HMAC Verification",
+ severity="medium", mitre=["t1185"], product="application", service="auth",
+ when={"event_type": "session_validate", "hmac_valid": False},
+ fp=["Stale cookie after key rotation"], playbook="tpl-credential-access"),
+ S(slug="app-account-enum-reset", name="High Volume Of Password Reset Requests From Single IP",
+ severity="medium", mitre=["t1110"], product="application", service="auth",
+ when={"event_type": "password_reset_request", "count_5min_per_ip_gt": 30},
+ fp=["Internal load test"], playbook="tpl-credential-access"),
+ S(slug="app-websocket-origin-bypass", name="WebSocket Upgrade From Cross-Origin Header",
+ severity="medium", mitre=["t1190"], product="application", service="ws",
+ when={"event_type": "ws_upgrade", "origin_matches_allowed_list": False},
+ fp=["Newly added integration partner (update allow-list)"], playbook="tpl-initial-access"),
+ S(slug="app-crlf-header-injection", name="CRLF Sequence In HTTP Header Value",
+ severity="high", mitre=["t1190"], product="waf", service="http",
+ when={"event_type": "http_request", "any_header_value_contains_any": ["%0d%0a", "\\r\\n"]},
+ fp=[FP_PENTEST], playbook="tpl-defense-evasion"),
+ S(slug="app-subdomain-takeover-cname", name="CNAME Pointing To Deleted SaaS Tenant",
+ severity="high", mitre=["t1583.001"], product="dns", service="resolver",
+ when={"event_type": "dns_response", "qtype": "CNAME", "target_endswith_any": [".herokudns.com", ".github.io", ".azurewebsites.net"], "target_resolves": False},
+ fp=["Pending tenant migration (verify ticket)"], playbook="tpl-initial-access"),
+ S(slug="app-cors-wildcard-with-creds", name="CORS Response With Wildcard Origin And Credentials Allowed",
+ severity="medium", mitre=["t1190"], product="application", service="http",
+ when={"event_type": "http_response", "header_access_control_allow_origin": "*", "header_access_control_allow_credentials": "true"},
+ fp=["Public unauthenticated API"], playbook="tpl-defense-evasion"),
+ S(slug="app-csp-disabled", name="Content-Security-Policy Header Removed From Production Response",
+ severity="medium", mitre=["t1190"], product="application", service="http",
+ when={"event_type": "http_response", "csp_header_present": False, "environment": "prod"},
+ fp=["Public marketing pages exempt from CSP"], playbook="tpl-defense-evasion"),
+]
+
+
+# ---------------------------------------------------------------------------
+# DevOps / CI / supply-chain (12)
+# ---------------------------------------------------------------------------
+DEVOPS_RULES: list[dict] = [
+ S(slug="app-ci-workflow-modified-by-non-owner", name="CI Workflow Modified By Account Without CODEOWNER Approval",
+ severity="high", mitre=["t1199"], product="github", service="repo",
+ when={"event_type": "push", "path_contains": ".github/workflows/", "approver_role_neq": "codeowner"},
+ fp=["Bootstrap of new repository"], playbook="tpl-supply-chain"),
+ S(slug="app-self-hosted-runner-external", name="Self-Hosted Runner Registered From External IP",
+ severity="critical", mitre=["t1199"], product="github", service="actions",
+ when={"event_type": "runner_register", "ip_is_internal": False},
+ fp=["Approved partner-hosted runner"], playbook="tpl-supply-chain"),
+ S(slug="app-build-signing-key-rotated", name="Build Artifact Signing Key Rotated Outside Maintenance Window",
+ severity="high", mitre=["t1554"], product="ci", service="signing",
+ when={"event_type": "key_rotation", "in_change_window": False},
+ fp=["Emergency key rotation (must be ticketed)"], playbook="tpl-supply-chain"),
+ S(slug="app-helm-chart-untrusted-repo", name="Helm Install From Unknown Chart Repository",
+ severity="high", mitre=["t1195.002"], product="kubernetes", service="helm",
+ when={"event_type": "helm_install", "repo_url_endswith_in_allow_list": False},
+ fp=["Pilot of new vendor chart"], playbook="tpl-supply-chain"),
+ S(slug="app-terraform-destroy-prod", name="terraform destroy Run Targeting Production Workspace",
+ severity="critical", mitre=["t1485"], product="terraform", service="cli",
+ when={"event_type": "terraform_run", "command": "destroy", "workspace_in": ["prod", "production"]},
+ fp=["Authorised infra teardown"], playbook="tpl-impact"),
+ S(slug="app-secret-published-to-slack", name="Newly Created Secret Has Slack Webhook Pattern",
+ severity="high", mitre=["t1078"], product="vault", service="secrets",
+ when={"event_type": "secret_create", "value_contains": "hooks.slack.com/services/"},
+ fp=["Approved alerting webhook"], playbook="tpl-credential-access"),
+ S(slug="app-deploy-key-added-github", name="SSH Deploy Key Added To GitHub Repository",
+ severity="medium", mitre=["t1098.004"], product="github", service="repo",
+ when={"event_type": "deploy_key.create"},
+ fp=["Sanctioned automation onboarding"], playbook="tpl-persistence"),
+ S(slug="app-npm-package-publish-new-account", name="NPM Package Published From New Account",
+ severity="high", mitre=["t1195.002"], product="npm", service="registry",
+ when={"event_type": "package_publish", "publisher_account_age_days_lt": 14, "package_visibility": "public"},
+ fp=["New maintainer onboarding"], playbook="tpl-supply-chain"),
+ S(slug="app-pypi-package-publish-new-ip", name="PyPI Package Published From New IP",
+ severity="medium", mitre=["t1195.002"], product="pypi", service="registry",
+ when={"event_type": "package_publish", "publisher_ip_seen_before": False},
+ fp=["New maintainer onboarding"], playbook="tpl-supply-chain"),
+ S(slug="app-docker-insecure-registry-flag", name="Docker Daemon Started With --insecure-registry Flag",
+ severity="medium", mitre=["t1195.002"], product="docker", service="dockerd",
+ when={"event_type": "daemon_config", "insecure_registries_count_gt": 0},
+ fp=["Internal mirror without TLS (deprecated, must be ticketed)"], playbook="tpl-supply-chain"),
+ S(slug="app-image-critical-cve-pushed", name="Container Image With Critical CVE Pushed To Prod Registry",
+ severity="high", mitre=["t1525"], product="container-registry", service="scan",
+ when={"event_type": "scan_result", "cvss_max_gte": 9.0, "registry_environment": "prod"},
+ fp=["Approved exception (must be ticketed)"], playbook="tpl-supply-chain"),
+ S(slug="app-protected-branch-disabled", name="Branch Protection Disabled On Protected Branch",
+ severity="high", mitre=["t1098.004"], product="github", service="repo",
+ when={"event_type_in": ["protected_branch.policy_override", "protected_branch.destroy"]},
+ fp=[FP_TUNING], playbook="tpl-supply-chain"),
+]
+
+
+# ---------------------------------------------------------------------------
+# SaaS / collaboration (12)
+# ---------------------------------------------------------------------------
+SAAS_RULES: list[dict] = [
+ S(slug="app-salesforce-mass-export", name="Salesforce Mass Data Export Initiated",
+ severity="high", mitre=["t1530"], product="salesforce", service="audit",
+ when={"event_type": "DataExport", "row_count_gt": 100000},
+ fp=["Approved data migration"], playbook="tpl-exfiltration"),
+ S(slug="app-salesforce-sandbox-refresh-anomaly", name="Salesforce Sandbox Refreshed Outside Change Window",
+ severity="medium", mitre=["t1199"], product="salesforce", service="audit",
+ when={"event_type": "SandboxRefresh", "in_change_window": False},
+ fp=["Emergency sandbox refresh (must be ticketed)"], playbook="tpl-defense-evasion"),
+ S(slug="app-workday-bank-info-changed", name="Workday Banking Info Changed Without HR Ticket",
+ severity="high", mitre=["t1098"], product="workday", service="audit",
+ when={"event_type": "BankAccountChange", "linked_ticket": False},
+ fp=["Self-service change with valid step-up auth"], playbook="tpl-impact"),
+ S(slug="app-zoom-recording-shared-external", name="Zoom Cloud Recording Shared Externally",
+ severity="medium", mitre=["t1530"], product="zoom", service="audit",
+ when={"event_type": "recording_share", "share_type": "external"},
+ fp=["Customer-facing webinar recording"], playbook="tpl-exfiltration"),
+ S(slug="app-box-public-link-mass-create", name="Box Created Many Public Links In Short Window",
+ severity="high", mitre=["t1567.002"], product="box", service="audit",
+ when={"event_type": "shared_link.create", "access": "open", "count_5min_per_user_gt": 20},
+ fp=["Marketing campaign content drop"], playbook="tpl-exfiltration"),
+ S(slug="app-notion-workspace-export", name="Notion Workspace Exported By Non-Admin",
+ severity="high", mitre=["t1530"], product="notion", service="audit",
+ when={"event_type": "workspace.export", "actor_is_admin": False},
+ fp=["Approved knowledge migration"], playbook="tpl-exfiltration"),
+ S(slug="app-confluence-space-export-bulk", name="Confluence Bulk Space Export",
+ severity="medium", mitre=["t1530"], product="confluence", service="audit",
+ when={"event_type": "space.export", "size_bytes_gt": 524288000},
+ fp=["Approved knowledge migration"], playbook="tpl-exfiltration"),
+ S(slug="app-servicenow-record-export-bulk", name="ServiceNow Bulk Record Export",
+ severity="medium", mitre=["t1530"], product="servicenow", service="audit",
+ when={"event_type": "record_export", "row_count_gt": 50000},
+ fp=["Approved reporting workflow"], playbook="tpl-exfiltration"),
+ S(slug="app-slack-file-shared-external", name="Slack File Shared To External Channel",
+ severity="medium", mitre=["t1567.002"], product="slack", service="audit",
+ when={"event_type": "file_shared", "channel_type": "external"},
+ fp=["Approved partner connect channel"], playbook="tpl-exfiltration"),
+ S(slug="app-slack-channel-public-conversion", name="Slack Private Channel Converted To Public",
+ severity="medium", mitre=["t1213"], product="slack", service="audit",
+ when={"event_type": "channel_convert_to_public"},
+ fp=["Approved transparency policy"], playbook="tpl-defense-evasion"),
+ S(slug="app-onedrive-anonymous-link-sensitive", name="OneDrive Anonymous Sharing Link Created For Sensitive File",
+ severity="high", mitre=["t1567.002"], product="m365", service="audit",
+ when={"event_type": "AnonymousLinkCreated", "sensitivity_label_in": ["Confidential", "Highly Confidential"]},
+ fp=["Approved external review"], playbook="tpl-exfiltration"),
+ S(slug="app-sharepoint-guest-tenantwide", name="SharePoint Tenant-Wide Guest Access Enabled",
+ severity="high", mitre=["t1078.004"], product="m365", service="audit",
+ when={"event_type": "TenantSettingChanged", "setting": "SharingCapability", "value": "ExternalUserSharingOnly"},
+ fp=["Approved tenant-level policy update"], playbook="tpl-defense-evasion"),
+]
+
+
+# ---------------------------------------------------------------------------
+# API misuse (1)
+# ---------------------------------------------------------------------------
+API_RULES: list[dict] = [
+ S(slug="app-graphql-mutation-anonymous", name="GraphQL Mutation Executed By Anonymous Caller",
+ severity="high", mitre=["t1190"], product="api-gateway", service="http",
+ when={"event_type": "graphql_op", "op_type": "mutation", "actor_authenticated": False},
+ fp=["Public mutation endpoint (allow-listed: subscribe / contact)"], playbook="tpl-initial-access"),
+]
+
+
+# ---------------------------------------------------------------------------
+# Aggregate
+# ---------------------------------------------------------------------------
+APPLICATION_EXTRA: list[dict] = (
+ WEB_APP_RULES
+ + DEVOPS_RULES
+ + SAAS_RULES
+ + API_RULES
+)
+
+
+__all__ = [
+ "APPLICATION_EXTRA",
+ "WEB_APP_RULES",
+ "DEVOPS_RULES",
+ "SAAS_RULES",
+ "API_RULES",
+]
diff --git a/scripts/detection_specs_part3_cloud.py b/scripts/detection_specs_part3_cloud.py
new file mode 100644
index 000000000..88595112d
--- /dev/null
+++ b/scripts/detection_specs_part3_cloud.py
@@ -0,0 +1,713 @@
+"""
+Detection Pack v1 - Part 3 / Cloud (150 new specs)
+==================================================
+
+Native cloud detection rules covering AWS, Azure, GCP, Kubernetes and a small
+multi-cloud bucket. These extend the 40 stable cloud rules in `detection_specs.CLOUD`
+to a total of 190 native cloud detections.
+
+Authoring rules
+---------------
+* Use the ``S()`` helper from ``detection_specs_part3_helpers`` so every spec
+ auto-generates positive/negative fixtures from a flat ``match_when`` clause.
+ For nested ``any_of`` / ``all_of`` clauses you must pass explicit fixtures.
+* Slugs prefixed with ``aws-``, ``azure-``, ``gcp-``, ``k8s-`` or ``cloud-``
+ follow the convention used in ``detection_specs.CLOUD``. New slugs MUST NOT
+ collide with existing ones.
+* Severity guidance:
+ * critical : direct credential or data compromise / persistence with broad
+ blast radius.
+ * high : strong indicator of a single-tenant attack technique.
+ * medium : posture / mis-configuration / suspicious-but-tunable behaviour.
+ * low : noisy or intel-only signals.
+"""
+
+from __future__ import annotations
+
+from detection_specs_part3_helpers import ( # type: ignore[import-not-found]
+ FP_AUTOMATION,
+ FP_BACKUP,
+ FP_BREAK_GLASS,
+ FP_FORENSIC,
+ FP_ONBOARD,
+ FP_PATCH,
+ FP_PENTEST,
+ FP_TUNING,
+ S,
+)
+
+
+# ---------------------------------------------------------------------------
+# AWS (60 rules)
+# ---------------------------------------------------------------------------
+AWS_RULES: list[dict] = [
+ # ---- IAM (15) ----
+ S(slug="aws-iam-attach-administrator-access", name="AWS IAM AdministratorAccess Policy Attached",
+ severity="high", mitre=["t1078.004", "t1098"], product="aws", service="iam",
+ when={"event_name_in": ["AttachUserPolicy", "AttachRolePolicy", "AttachGroupPolicy"],
+ "policy_arn": "arn:aws:iam::aws:policy/AdministratorAccess"},
+ fp=["IAM bootstrap during account vending", FP_AUTOMATION], playbook="tpl-privilege-escalation"),
+ S(slug="aws-iam-key-rotation-skipped", name="AWS IAM Access Key Older Than 365 Days",
+ severity="medium", mitre=["t1078.004"], product="aws", service="iam",
+ when={"event_name": "ListAccessKeys", "key_age_days_gt": 365},
+ fp=[FP_AUTOMATION, "Service-account key intentionally pinned"], playbook="tpl-credential-hygiene"),
+ S(slug="aws-iam-mfa-disabled-on-priv-user", name="AWS IAM MFA Removed From Privileged User",
+ severity="critical", mitre=["t1556.006"], product="aws", service="iam",
+ when={"event_name": "DeactivateMFADevice", "target_user_priv": True},
+ fp=[FP_BREAK_GLASS, "Token rotation procedure"], playbook="tpl-defense-evasion"),
+ S(slug="aws-iam-role-trust-broadened-wildcard", name="AWS IAM Role Trust Policy Allows Principal '*'",
+ severity="critical", mitre=["t1078.004", "t1098.001"], product="aws", service="iam",
+ when={"event_name": "UpdateAssumeRolePolicy", "trust_principal": "*"},
+ fp=["Sandbox / training account by design"], playbook="tpl-privilege-escalation"),
+ S(slug="aws-iam-policy-version-set-default-broad", name="AWS IAM Policy Version Set With Wildcard Action",
+ severity="high", mitre=["t1098"], product="aws", service="iam",
+ when={"event_name": "SetDefaultPolicyVersion", "policy_action": "*", "policy_resource": "*"},
+ fp=[FP_AUTOMATION], playbook="tpl-privilege-escalation"),
+ S(slug="aws-iam-permissions-boundary-removed", name="AWS IAM Permissions Boundary Removed",
+ severity="high", mitre=["t1098"], product="aws", service="iam",
+ when={"event_name": "DeleteUserPermissionsBoundary"},
+ fp=["Boundary refactor (tracked in change ticket)"], playbook="tpl-privilege-escalation"),
+ S(slug="aws-iam-saml-provider-modified", name="AWS IAM SAML Provider Updated",
+ severity="high", mitre=["t1556"], product="aws", service="iam",
+ when={"event_name_in": ["UpdateSAMLProvider", "CreateSAMLProvider"]},
+ fp=["IdP migration (must be ticketed)", FP_AUTOMATION], playbook="tpl-defense-evasion"),
+ S(slug="aws-iam-cross-account-role-broad-trust", name="AWS IAM Role Trusts Foreign Account Root",
+ severity="high", mitre=["t1199"], product="aws", service="iam",
+ when={"event_name": "CreateRole", "trust_principal_endswith": ":root", "trust_principal_external": True},
+ fp=["Approved partner integration"], playbook="tpl-initial-access"),
+ S(slug="aws-iam-anonymous-role-trust", name="AWS IAM Role Trusts Anonymous Federation",
+ severity="critical", mitre=["t1199"], product="aws", service="iam",
+ when={"event_name": "CreateRole", "trust_principal_in": ["anonymous", "AllUsers"]},
+ fp=[], playbook="tpl-initial-access"),
+ S(slug="aws-iam-create-user-burst", name="AWS IAM CreateUser Burst",
+ severity="medium", mitre=["t1136.003"], product="aws", service="iam",
+ when={"event_name": "CreateUser", "events_per_minute_gt": 10},
+ fp=["Bulk onboarding window", FP_AUTOMATION], playbook="tpl-persistence"),
+ S(slug="aws-iam-account-summary-recon", name="AWS IAM GetAccountSummary Recon Burst",
+ severity="low", mitre=["t1087.004"], product="aws", service="iam",
+ when={"event_name_in": ["GetAccountSummary", "GetAccountAuthorizationDetails"], "events_per_minute_gt": 5},
+ fp=["IAM Access Analyzer routine"], playbook="tpl-discovery"),
+ S(slug="aws-iam-list-keys-recon", name="AWS IAM ListAccessKeys Recon Across Users",
+ severity="medium", mitre=["t1087.004"], product="aws", service="iam",
+ when={"event_name": "ListAccessKeys", "distinct_users_per_minute_gt": 20},
+ fp=["Compliance audit job"], playbook="tpl-discovery"),
+ S(slug="aws-iam-login-profile-created-existing-user", name="AWS IAM Login Profile Added To Existing User",
+ severity="high", mitre=["t1098.001"], product="aws", service="iam",
+ when={"event_name": "CreateLoginProfile", "user_existed": True},
+ fp=["Migrating service account to interactive use"], playbook="tpl-persistence"),
+ S(slug="aws-iam-access-key-created-other-user", name="AWS IAM Access Key Created For Another User",
+ severity="high", mitre=["t1098.001"], product="aws", service="iam",
+ when={"event_name": "CreateAccessKey", "actor_eq_target": False},
+ fp=["Helpdesk ticket (must be linked)"], playbook="tpl-persistence"),
+ S(slug="aws-iam-policy-with-notaction", name="AWS IAM Policy Created With NotAction Wildcard",
+ severity="high", mitre=["t1098"], product="aws", service="iam",
+ when={"event_name_in": ["CreatePolicy", "CreatePolicyVersion"], "policy_uses_notaction": True},
+ fp=[FP_TUNING], playbook="tpl-privilege-escalation"),
+ # ---- S3 / EBS (8) ----
+ S(slug="aws-s3-block-public-access-disabled", name="AWS S3 Block Public Access Disabled",
+ severity="critical", mitre=["t1530"], product="aws", service="s3",
+ when={"event_name_in": ["PutBucketPublicAccessBlock", "DeletePublicAccessBlock"], "block_public_acls": False},
+ fp=["Static site bucket explicitly public"], playbook="tpl-data-exposure"),
+ S(slug="aws-s3-bucket-policy-allows-anonymous", name="AWS S3 Bucket Policy Allows Principal '*'",
+ severity="critical", mitre=["t1530"], product="aws", service="s3",
+ when={"event_name": "PutBucketPolicy", "policy_principal": "*"},
+ fp=["Public download bucket (documented)"], playbook="tpl-data-exposure"),
+ S(slug="aws-s3-replication-to-foreign-account", name="AWS S3 Replication Configured To External Account",
+ severity="high", mitre=["t1537"], product="aws", service="s3",
+ when={"event_name": "PutBucketReplication", "destination_account_external": True},
+ fp=["Approved cross-account DR pipeline"], playbook="tpl-exfiltration"),
+ S(slug="aws-s3-server-access-logging-disabled", name="AWS S3 Server Access Logging Disabled",
+ severity="medium", mitre=["t1562.008"], product="aws", service="s3",
+ when={"event_name": "PutBucketLogging", "logging_enabled": False},
+ fp=[FP_AUTOMATION, "Decommissioned bucket"], playbook="tpl-defense-evasion"),
+ S(slug="aws-s3-object-lock-disabled", name="AWS S3 Object Lock / Retention Disabled",
+ severity="high", mitre=["t1485"], product="aws", service="s3",
+ when={"event_name_in": ["PutObjectLockConfiguration", "PutObjectRetention"], "retention_disabled": True},
+ fp=[FP_AUTOMATION], playbook="tpl-impact"),
+ S(slug="aws-s3-mass-deleteobject", name="AWS S3 Mass DeleteObject Burst",
+ severity="critical", mitre=["t1485"], product="aws", service="s3",
+ when={"event_name": "DeleteObject", "objects_per_minute_gt": 1000},
+ fp=["Lifecycle policy run", FP_BACKUP], playbook="tpl-impact"),
+ S(slug="aws-ebs-snapshot-shared-foreign", name="AWS EBS Snapshot Shared With Foreign Account",
+ severity="high", mitre=["t1537"], product="aws", service="ec2",
+ when={"event_name": "ModifySnapshotAttribute", "shared_account_external": True},
+ fp=["Approved DR copy"], playbook="tpl-exfiltration"),
+ S(slug="aws-ami-shared-public", name="AWS AMI Shared Publicly",
+ severity="high", mitre=["t1537"], product="aws", service="ec2",
+ when={"event_name": "ModifyImageAttribute", "ami_made_public": True},
+ fp=["Marketplace publishing workflow"], playbook="tpl-exfiltration"),
+ # ---- EC2 / VPC (8) ----
+ S(slug="aws-ec2-imds-v1-allowed", name="AWS EC2 Instance Launched With IMDSv1 Allowed",
+ severity="medium", mitre=["t1552.005"], product="aws", service="ec2",
+ when={"event_name": "RunInstances", "imds_v1_allowed": True},
+ fp=["Legacy AMI (must be ticketed)"], playbook="tpl-credential-access"),
+ S(slug="aws-ec2-key-pair-imported", name="AWS EC2 Key Pair Imported",
+ severity="medium", mitre=["t1098.004"], product="aws", service="ec2",
+ when={"event_name": "ImportKeyPair"},
+ fp=["Bootstrap of golden image", FP_AUTOMATION], playbook="tpl-persistence"),
+ S(slug="aws-ec2-disable-api-stop-revoked", name="AWS EC2 DisableApiStop Protection Revoked",
+ severity="medium", mitre=["t1485"], product="aws", service="ec2",
+ when={"event_name": "ModifyInstanceAttribute", "attribute": "disableApiStop", "value": False},
+ fp=["Decommissioning workflow"], playbook="tpl-impact"),
+ S(slug="aws-ec2-userdata-modified-running", name="AWS EC2 UserData Modified On Running Instance",
+ severity="high", mitre=["t1059.001", "t1059.004"], product="aws", service="ec2",
+ when={"event_name": "ModifyInstanceAttribute", "attribute": "userData", "instance_state": "running"},
+ fp=["Approved cloud-init re-run"], playbook="tpl-execution"),
+ S(slug="aws-vpc-route-to-internet-gateway", name="AWS VPC Default Route Pointed At New IGW",
+ severity="high", mitre=["t1090"], product="aws", service="ec2",
+ when={"event_name": "CreateRoute", "destination_cidr": "0.0.0.0/0", "target_type": "internet-gateway"},
+ fp=["New public subnet provisioning"], playbook="tpl-command-and-control"),
+ S(slug="aws-security-group-rule-add-22-from-anywhere", name="AWS SG Rule Allows SSH From 0.0.0.0/0",
+ severity="high", mitre=["t1133"], product="aws", service="ec2",
+ when={"event_name": "AuthorizeSecurityGroupIngress", "ip_protocol": "tcp", "from_port": 22, "to_port": 22, "cidr": "0.0.0.0/0"},
+ fp=["Bastion/jump-host with MFA"], playbook="tpl-initial-access"),
+ S(slug="aws-security-group-rule-add-3389-from-anywhere", name="AWS SG Rule Allows RDP From 0.0.0.0/0",
+ severity="high", mitre=["t1133"], product="aws", service="ec2",
+ when={"event_name": "AuthorizeSecurityGroupIngress", "ip_protocol": "tcp", "from_port": 3389, "to_port": 3389, "cidr": "0.0.0.0/0"},
+ fp=["Lab account by design"], playbook="tpl-initial-access"),
+ S(slug="aws-vpc-peering-cross-org", name="AWS VPC Peering Connection Across Organizations",
+ severity="high", mitre=["t1199"], product="aws", service="ec2",
+ when={"event_name": "CreateVpcPeeringConnection", "peer_account_external": True},
+ fp=["Approved partner network"], playbook="tpl-initial-access"),
+ # ---- RDS (5) ----
+ S(slug="aws-rds-publicly-accessible-true", name="AWS RDS Instance Modified To Publicly Accessible",
+ severity="critical", mitre=["t1530"], product="aws", service="rds",
+ when={"event_name_in": ["CreateDBInstance", "ModifyDBInstance"], "publicly_accessible": True},
+ fp=["Lab/demo workload only"], playbook="tpl-data-exposure"),
+ S(slug="aws-rds-snapshot-shared", name="AWS RDS Snapshot Shared With Other Account",
+ severity="high", mitre=["t1537"], product="aws", service="rds",
+ when={"event_name": "ModifyDBSnapshotAttribute", "shared_account_external": True},
+ fp=["DR copy to disaster account"], playbook="tpl-exfiltration"),
+ S(slug="aws-rds-iam-auth-disabled", name="AWS RDS IAM Authentication Disabled",
+ severity="medium", mitre=["t1556"], product="aws", service="rds",
+ when={"event_name": "ModifyDBInstance", "iam_database_authentication_enabled": False},
+ fp=[FP_TUNING], playbook="tpl-defense-evasion"),
+ S(slug="aws-rds-master-password-reset", name="AWS RDS Master User Password Reset",
+ severity="high", mitre=["t1098"], product="aws", service="rds",
+ when={"event_name": "ModifyDBInstance", "master_user_password_changed": True},
+ fp=["Scheduled rotation"], playbook="tpl-credential-access"),
+ S(slug="aws-rds-deletion-protection-disabled", name="AWS RDS Deletion Protection Disabled",
+ severity="medium", mitre=["t1485"], product="aws", service="rds",
+ when={"event_name": "ModifyDBInstance", "deletion_protection": False},
+ fp=["Planned decommission"], playbook="tpl-impact"),
+ # ---- Lambda (4) ----
+ S(slug="aws-lambda-add-permission-anonymous", name="AWS Lambda AddPermission Allows Principal '*'",
+ severity="critical", mitre=["t1190"], product="aws", service="lambda",
+ when={"event_name": "AddPermission", "principal": "*"},
+ fp=["Public webhook endpoint by design"], playbook="tpl-initial-access"),
+ S(slug="aws-lambda-env-var-secret-pattern", name="AWS Lambda Env Var Contains Secret Pattern",
+ severity="high", mitre=["t1552.001"], product="aws", service="lambda",
+ when={"event_name_in": ["CreateFunction", "UpdateFunctionConfiguration"], "env_secret_pattern": True},
+ fp=["Local-only fixture / unit-test value"], playbook="tpl-credential-access"),
+ S(slug="aws-lambda-create-url-public", name="AWS Lambda Function URL With AuthType=NONE",
+ severity="high", mitre=["t1190"], product="aws", service="lambda",
+ when={"event_name": "CreateFunctionUrlConfig", "auth_type": "NONE"},
+ fp=["Public ingest endpoint by design"], playbook="tpl-initial-access"),
+ S(slug="aws-lambda-runtime-deprecated", name="AWS Lambda Function Uses Deprecated Runtime",
+ severity="medium", mitre=["t1610"], product="aws", service="lambda",
+ when={"event_name": "CreateFunction", "runtime_in": ["nodejs10.x", "nodejs12.x", "python2.7", "python3.6"]},
+ fp=[FP_TUNING], playbook="tpl-vulnerability"),
+ # ---- EKS / ECS (6) ----
+ S(slug="aws-eks-cluster-public-endpoint", name="AWS EKS Cluster API Endpoint Made Public",
+ severity="critical", mitre=["t1133"], product="aws", service="eks",
+ when={"event_name_in": ["CreateCluster", "UpdateClusterConfig"], "endpoint_public_access": True, "public_access_cidrs_contains": "0.0.0.0/0"},
+ fp=["Lab cluster"], playbook="tpl-initial-access"),
+ S(slug="aws-eks-fargate-profile-default-ns", name="AWS EKS Fargate Profile Targets default Namespace",
+ severity="medium", mitre=["t1610"], product="aws", service="eks",
+ when={"event_name": "CreateFargateProfile", "namespace": "default"},
+ fp=["Greenfield cluster"], playbook="tpl-execution"),
+ S(slug="aws-ecs-task-privileged", name="AWS ECS Task Definition With privileged=true",
+ severity="high", mitre=["t1611"], product="aws", service="ecs",
+ when={"event_name": "RegisterTaskDefinition", "privileged": True},
+ fp=["Sysdig / debugger task"], playbook="tpl-privilege-escalation"),
+ S(slug="aws-ecs-execute-command-enabled", name="AWS ECS ExecuteCommand Enabled On Service",
+ severity="medium", mitre=["t1059"], product="aws", service="ecs",
+ when={"event_name_in": ["CreateService", "UpdateService"], "enable_execute_command": True},
+ fp=["Debugging window"], playbook="tpl-execution"),
+ S(slug="aws-ecr-repo-publicly-readable", name="AWS ECR Repository Policy Public",
+ severity="high", mitre=["t1525"], product="aws", service="ecr",
+ when={"event_name": "SetRepositoryPolicy", "policy_principal": "*"},
+ fp=["Public images repo"], playbook="tpl-supply-chain"),
+ S(slug="aws-ecr-image-scan-disabled", name="AWS ECR Image Scan-On-Push Disabled",
+ severity="low", mitre=["t1610"], product="aws", service="ecr",
+ when={"event_name": "PutImageScanningConfiguration", "scan_on_push": False},
+ fp=[FP_TUNING], playbook="tpl-vulnerability"),
+ # ---- KMS / Secrets (4) ----
+ S(slug="aws-kms-key-policy-anonymous", name="AWS KMS Key Policy Allows Principal '*'",
+ severity="critical", mitre=["t1552.001"], product="aws", service="kms",
+ when={"event_name": "PutKeyPolicy", "policy_principal": "*"},
+ fp=[], playbook="tpl-credential-access"),
+ S(slug="aws-kms-schedule-key-deletion", name="AWS KMS ScheduleKeyDeletion Used",
+ severity="high", mitre=["t1485"], product="aws", service="kms",
+ when={"event_name": "ScheduleKeyDeletion"},
+ fp=["Decommissioning"], playbook="tpl-impact"),
+ S(slug="aws-secretsmanager-mass-getsecret", name="AWS SecretsManager Mass GetSecretValue",
+ severity="high", mitre=["t1552.001"], product="aws", service="secretsmanager",
+ when={"event_name": "GetSecretValue", "distinct_secrets_per_minute_gt": 30},
+ fp=["Bootstrap of new microservice"], playbook="tpl-credential-access"),
+ S(slug="aws-ssm-parameter-secure-no-kms", name="AWS SSM SecureString Parameter Created Without KMS",
+ severity="medium", mitre=["t1552.001"], product="aws", service="ssm",
+ when={"event_name": "PutParameter", "type": "SecureString", "key_id": None},
+ fp=[FP_TUNING], playbook="tpl-credential-access"),
+ # ---- CloudTrail / Config / GuardDuty / Org (5) ----
+ S(slug="aws-config-recorder-stopped", name="AWS Config Recorder Stopped",
+ severity="critical", mitre=["t1562.008"], product="aws", service="config",
+ when={"event_name": "StopConfigurationRecorder"},
+ fp=["Account decommission"], playbook="tpl-defense-evasion"),
+ S(slug="aws-guardduty-detector-deleted", name="AWS GuardDuty Detector Deleted",
+ severity="critical", mitre=["t1562.001"], product="aws", service="guardduty",
+ when={"event_name": "DeleteDetector"},
+ fp=["Region pruning approved"], playbook="tpl-defense-evasion"),
+ S(slug="aws-securityhub-disabled", name="AWS SecurityHub DisableSecurityHub",
+ severity="critical", mitre=["t1562.001"], product="aws", service="securityhub",
+ when={"event_name": "DisableSecurityHub"},
+ fp=["Account decommission"], playbook="tpl-defense-evasion"),
+ S(slug="aws-cloudtrail-event-selector-narrowed", name="AWS CloudTrail Event Selector Narrowed",
+ severity="high", mitre=["t1562.008"], product="aws", service="cloudtrail",
+ when={"event_name": "PutEventSelectors", "selector_includes_management_events": False},
+ fp=["Cost-optimisation work"], playbook="tpl-defense-evasion"),
+ S(slug="aws-organizations-account-removed", name="AWS Organizations Account Removed",
+ severity="high", mitre=["t1078.004"], product="aws", service="organizations",
+ when={"event_name_in": ["RemoveAccountFromOrganization", "LeaveOrganization"]},
+ fp=["Approved account divestiture"], playbook="tpl-defense-evasion"),
+ # ---- Misc AWS (5) ----
+ S(slug="aws-route53-domain-transfer-out", name="AWS Route53 Domain Transfer Out",
+ severity="high", mitre=["t1583.001"], product="aws", service="route53domains",
+ when={"event_name": "TransferDomainToAnotherAwsAccount"},
+ fp=["Account merger workflow"], playbook="tpl-impact"),
+ S(slug="aws-cloudfront-origin-changed", name="AWS CloudFront Origin Changed Mid-Service",
+ severity="high", mitre=["t1565.002"], product="aws", service="cloudfront",
+ when={"event_name": "UpdateDistribution", "origin_changed": True, "distribution_age_days_gt": 30},
+ fp=["Approved migration"], playbook="tpl-impact"),
+ S(slug="aws-waf-web-acl-disassociated", name="AWS WAF Web ACL Disassociated",
+ severity="high", mitre=["t1562.001"], product="aws", service="wafv2",
+ when={"event_name": "DisassociateWebACL"},
+ fp=["Re-association in same window"], playbook="tpl-defense-evasion"),
+ S(slug="aws-sns-topic-public-subscribe", name="AWS SNS Topic Policy Allows Anonymous Subscribe",
+ severity="medium", mitre=["t1098"], product="aws", service="sns",
+ when={"event_name": "SetTopicAttributes", "policy_principal": "*"},
+ fp=["Public notifications topic"], playbook="tpl-data-exposure"),
+ S(slug="aws-sqs-queue-public-policy", name="AWS SQS Queue Policy Allows Principal '*'",
+ severity="medium", mitre=["t1098"], product="aws", service="sqs",
+ when={"event_name": "SetQueueAttributes", "policy_principal": "*"},
+ fp=["Public webhook ingestion"], playbook="tpl-initial-access"),
+]
+
+
+# ---------------------------------------------------------------------------
+# Azure / M365 (35 rules)
+# ---------------------------------------------------------------------------
+AZURE_RULES: list[dict] = [
+ # ---- Entra / AAD (12) ----
+ S(slug="azure-ad-app-consent-grant", name="Entra ID Admin Consent Granted To App",
+ severity="high", mitre=["t1528"], product="azure", service="entra-audit",
+ when={"operation_name": "Consent to application", "consent_type": "AllPrincipals"},
+ fp=["Sanctioned SaaS rollout"], playbook="tpl-credential-access"),
+ S(slug="azure-ad-app-credential-added-out-of-hours", name="Entra ID App Credential Added Outside Business Hours",
+ severity="high", mitre=["t1098.001"], product="azure", service="entra-audit",
+ when={"operation_name": "Add service principal credentials", "is_business_hours": False},
+ fp=["On-call engineer rotation"], playbook="tpl-persistence"),
+ S(slug="azure-ad-conditional-access-bypass-rule", name="Entra ID Conditional Access Rule Excludes Privileged User",
+ severity="high", mitre=["t1556"], product="azure", service="entra-audit",
+ when={"operation_name": "Update policy", "policy_excludes_priv_user": True},
+ fp=[FP_BREAK_GLASS], playbook="tpl-defense-evasion"),
+ S(slug="azure-ad-mfa-method-removed-priv", name="Entra ID MFA Method Removed From Privileged User",
+ severity="critical", mitre=["t1556.006"], product="azure", service="entra-audit",
+ when={"operation_name_in": ["User registered security info", "User deleted security info"], "target_user_priv": True, "method_removed": True},
+ fp=[FP_BREAK_GLASS], playbook="tpl-defense-evasion"),
+ S(slug="azure-ad-pim-role-eligibility-self-assigned", name="Entra ID PIM Role Eligibility Self-Assigned",
+ severity="high", mitre=["t1078.004"], product="azure", service="entra-audit",
+ when={"operation_name": "Add eligible member to role", "actor_eq_target": True},
+ fp=["Bootstrap by Global Admin"], playbook="tpl-privilege-escalation"),
+ S(slug="azure-ad-app-permissions-graph-read-write-all", name="Entra ID App Granted Directory.ReadWrite.All",
+ severity="critical", mitre=["t1098.003"], product="azure", service="entra-audit",
+ when={"operation_name": "Update application", "permissions_added_contains_any": ["Directory.ReadWrite.All", "RoleManagement.ReadWrite.Directory"]},
+ fp=["Approved IAM tooling"], playbook="tpl-privilege-escalation"),
+ S(slug="azure-ad-bulk-user-creation", name="Entra ID Bulk User Creation Burst",
+ severity="medium", mitre=["t1136.003"], product="azure", service="entra-audit",
+ when={"operation_name": "Add user", "events_per_minute_gt": 25},
+ fp=["Bulk onboarding"], playbook="tpl-persistence"),
+ S(slug="azure-ad-named-location-removed", name="Entra ID Trusted Named Location Removed",
+ severity="medium", mitre=["t1556"], product="azure", service="entra-audit",
+ when={"operation_name": "Delete named location"},
+ fp=["Office relocation project"], playbook="tpl-defense-evasion"),
+ S(slug="azure-ad-legacy-auth-allowed", name="Entra ID Legacy Authentication Re-Enabled",
+ severity="high", mitre=["t1556"], product="azure", service="entra-audit",
+ when={"operation_name": "Update policy", "block_legacy_auth": False},
+ fp=["Migration of legacy app"], playbook="tpl-defense-evasion"),
+ S(slug="azure-ad-bulk-license-assignment", name="Entra ID Bulk License Assignment",
+ severity="low", mitre=["t1078.004"], product="azure", service="entra-audit",
+ when={"operation_name": "Change user license", "events_per_minute_gt": 50},
+ fp=["Bulk onboarding"], playbook="tpl-discovery"),
+ S(slug="azure-ad-admin-consent-workflow-disabled", name="Entra ID Admin Consent Workflow Disabled",
+ severity="medium", mitre=["t1556"], product="azure", service="entra-audit",
+ when={"operation_name": "Set Company Information", "admin_consent_workflow": False},
+ fp=["Tenant config refactor"], playbook="tpl-defense-evasion"),
+ S(slug="azure-ad-self-service-pwd-reset-policy-modified", name="Entra ID SSPR Policy Weakened",
+ severity="medium", mitre=["t1556"], product="azure", service="entra-audit",
+ when={"operation_name_in": ["Update password reset policy", "Disable password reset policy"]},
+ fp=[FP_TUNING], playbook="tpl-defense-evasion"),
+ # ---- ARM (8) ----
+ S(slug="azure-arm-policy-assignment-deleted", name="Azure Policy Assignment Deleted",
+ severity="high", mitre=["t1562.001"], product="azure", service="activity",
+ when={"operation_name_endswith": "policyAssignments/delete", "scope_root": True},
+ fp=["Policy refactor"], playbook="tpl-defense-evasion"),
+ S(slug="azure-arm-blueprint-deleted", name="Azure Blueprint Assignment Removed",
+ severity="medium", mitre=["t1562.001"], product="azure", service="activity",
+ when={"operation_name_endswith": "blueprintAssignments/delete"},
+ fp=["Subscription decommission"], playbook="tpl-defense-evasion"),
+ S(slug="azure-arm-role-assignment-owner-tenant", name="Azure Role Assignment Owner At Tenant Scope",
+ severity="critical", mitre=["t1078.004"], product="azure", service="activity",
+ when={"operation_name_endswith": "roleAssignments/write", "role": "Owner", "scope_root": True},
+ fp=[FP_BREAK_GLASS], playbook="tpl-privilege-escalation"),
+ S(slug="azure-arm-locks-removed-bulk", name="Azure ResourceGroup Locks Removed In Bulk",
+ severity="high", mitre=["t1485"], product="azure", service="activity",
+ when={"operation_name_endswith": "locks/delete", "events_per_minute_gt": 10},
+ fp=["Decommission project"], playbook="tpl-impact"),
+ S(slug="azure-arm-diagnostic-settings-deleted", name="Azure Diagnostic Settings Deleted",
+ severity="critical", mitre=["t1562.008"], product="azure", service="activity",
+ when={"operation_name_endswith": "diagnosticSettings/delete"},
+ fp=["Log pipeline migration"], playbook="tpl-defense-evasion"),
+ S(slug="azure-arm-mass-resource-modify", name="Azure Mass Resource Modify Burst",
+ severity="medium", mitre=["t1485"], product="azure", service="activity",
+ when={"operation_name_endswith_any": ["/write", "/delete"], "events_per_minute_gt": 200},
+ fp=["IaC pipeline run"], playbook="tpl-impact"),
+ S(slug="azure-arm-management-group-removed", name="Azure Management Group Removed",
+ severity="high", mitre=["t1485"], product="azure", service="activity",
+ when={"operation_name_endswith": "managementGroups/delete"},
+ fp=["Org restructure"], playbook="tpl-impact"),
+ S(slug="azure-arm-subscription-transferred", name="Azure Subscription Transferred",
+ severity="critical", mitre=["t1078.004"], product="azure", service="activity",
+ when={"operation_name_contains": "subscriptions/transfer"},
+ fp=["Approved EA migration"], playbook="tpl-impact"),
+ # ---- Storage (5) ----
+ S(slug="azure-storage-blob-anonymous-read", name="Azure Storage Container Allows Anonymous Read",
+ severity="critical", mitre=["t1530"], product="azure", service="activity",
+ when={"operation_name_endswith": "blobServices/containers/write", "public_access_in": ["Container", "Blob"]},
+ fp=["Static-site container by design"], playbook="tpl-data-exposure"),
+ S(slug="azure-storage-account-firewall-disabled", name="Azure Storage Account Firewall Disabled",
+ severity="high", mitre=["t1133"], product="azure", service="activity",
+ when={"operation_name_endswith": "storageAccounts/write", "default_action": "Allow"},
+ fp=["Public datalake by design"], playbook="tpl-initial-access"),
+ S(slug="azure-storage-shared-key-issued", name="Azure Storage Shared Access Signature Generated With Long TTL",
+ severity="medium", mitre=["t1078"], product="azure", service="activity",
+ when={"operation_name_contains": "ListKeys", "ttl_days_gt": 365},
+ fp=[FP_AUTOMATION], playbook="tpl-credential-access"),
+ S(slug="azure-storage-immutability-removed", name="Azure Storage Immutability Policy Removed",
+ severity="high", mitre=["t1485"], product="azure", service="activity",
+ when={"operation_name_endswith": "immutabilityPolicies/delete"},
+ fp=["Retention review"], playbook="tpl-impact"),
+ S(slug="azure-storage-soft-delete-disabled", name="Azure Blob Soft Delete Disabled",
+ severity="medium", mitre=["t1490"], product="azure", service="activity",
+ when={"operation_name_endswith": "blobServices/write", "delete_retention_enabled": False},
+ fp=[FP_TUNING], playbook="tpl-impact"),
+ # ---- Key Vault (5) ----
+ S(slug="azure-keyvault-purge-protection-disabled", name="Azure Key Vault Purge Protection Disabled",
+ severity="high", mitre=["t1485"], product="azure", service="keyvault",
+ when={"operation_name_endswith": "vaults/write", "enable_purge_protection": False},
+ fp=[FP_TUNING], playbook="tpl-impact"),
+ S(slug="azure-keyvault-secret-mass-get", name="Azure Key Vault Mass GetSecret",
+ severity="high", mitre=["t1552.001"], product="azure", service="keyvault",
+ when={"operation_name": "SecretGet", "distinct_secrets_per_minute_gt": 30},
+ fp=["App boot"], playbook="tpl-credential-access"),
+ S(slug="azure-keyvault-access-policy-broadened", name="Azure Key Vault Access Policy Adds Permission '*'",
+ severity="critical", mitre=["t1098"], product="azure", service="keyvault",
+ when={"operation_name_endswith": "vaults/accessPolicies/write", "permissions_contains": "all"},
+ fp=[], playbook="tpl-privilege-escalation"),
+ S(slug="azure-keyvault-firewall-allow-all", name="Azure Key Vault Network ACL Allows All",
+ severity="high", mitre=["t1133"], product="azure", service="keyvault",
+ when={"operation_name_endswith": "vaults/write", "default_action": "Allow"},
+ fp=[FP_TUNING], playbook="tpl-initial-access"),
+ S(slug="azure-keyvault-key-export-allowed", name="Azure Key Vault Key Export Attribute Set",
+ severity="high", mitre=["t1552"], product="azure", service="keyvault",
+ when={"operation_name_endswith": "keys/create", "exportable": True},
+ fp=["Approved cross-region migration"], playbook="tpl-credential-access"),
+ # ---- AKS / Compute (5) ----
+ S(slug="azure-aks-cluster-public-fqdn", name="Azure AKS Cluster API With Public FQDN",
+ severity="high", mitre=["t1133"], product="azure", service="activity",
+ when={"operation_name_endswith": "managedClusters/write", "private_cluster": False, "authorized_ip_ranges_empty": True},
+ fp=["Lab"], playbook="tpl-initial-access"),
+ S(slug="azure-aks-rbac-disabled", name="Azure AKS Cluster RBAC Disabled",
+ severity="high", mitre=["t1556"], product="azure", service="activity",
+ when={"operation_name_endswith": "managedClusters/write", "enable_rbac": False},
+ fp=["Lab"], playbook="tpl-defense-evasion"),
+ S(slug="azure-vm-runcommand", name="Azure VM RunCommand Invoked",
+ severity="high", mitre=["t1059"], product="azure", service="activity",
+ when={"operation_name_endswith": "virtualMachines/runCommand/action"},
+ fp=["Approved DevOps script"], playbook="tpl-execution"),
+ S(slug="azure-vm-extension-customscript", name="Azure VM CustomScript Extension Installed",
+ severity="medium", mitre=["t1059"], product="azure", service="activity",
+ when={"operation_name_endswith": "extensions/write", "extension_type": "CustomScript"},
+ fp=["Cloud-init bootstrap"], playbook="tpl-execution"),
+ S(slug="azure-vm-disk-encryption-disabled", name="Azure VM Disk Encryption Disabled",
+ severity="medium", mitre=["t1485"], product="azure", service="activity",
+ when={"operation_name_endswith": "encryptionExtensions/write", "encryption_enabled": False},
+ fp=["Data classification change"], playbook="tpl-impact"),
+]
+
+
+# ---------------------------------------------------------------------------
+# GCP (30 rules)
+# ---------------------------------------------------------------------------
+GCP_RULES: list[dict] = [
+ # ---- IAM (10) ----
+ S(slug="gcp-iam-allusers-binding", name="GCP IAM Binding Adds allUsers / allAuthenticatedUsers",
+ severity="critical", mitre=["t1530"], product="gcp", service="audit",
+ when={"method_name_endswith": "SetIamPolicy", "added_member_in": ["allUsers", "allAuthenticatedUsers"]},
+ fp=["Public dataset by design"], playbook="tpl-data-exposure"),
+ S(slug="gcp-iam-service-account-disable", name="GCP Service Account Disabled",
+ severity="medium", mitre=["t1531"], product="gcp", service="audit",
+ when={"method_name_endswith": "DisableServiceAccount"},
+ fp=["Decommissioning"], playbook="tpl-impact"),
+ S(slug="gcp-iam-service-account-actas-grant", name="GCP iam.serviceAccountUser Grant",
+ severity="high", mitre=["t1078.004"], product="gcp", service="audit",
+ when={"method_name_endswith": "SetIamPolicy", "role_added": "roles/iam.serviceAccountUser"},
+ fp=[FP_AUTOMATION], playbook="tpl-privilege-escalation"),
+ S(slug="gcp-iam-token-creator-grant", name="GCP iam.serviceAccountTokenCreator Grant",
+ severity="high", mitre=["t1078.004"], product="gcp", service="audit",
+ when={"method_name_endswith": "SetIamPolicy", "role_added": "roles/iam.serviceAccountTokenCreator"},
+ fp=[FP_AUTOMATION], playbook="tpl-privilege-escalation"),
+ S(slug="gcp-iam-billing-admin-grant", name="GCP roles/billing.admin Granted",
+ severity="high", mitre=["t1098"], product="gcp", service="audit",
+ when={"method_name_endswith": "SetIamPolicy", "role_added": "roles/billing.admin"},
+ fp=["Org bootstrap"], playbook="tpl-privilege-escalation"),
+ S(slug="gcp-iam-org-policy-disabled", name="GCP Organization Policy Constraint Disabled",
+ severity="high", mitre=["t1562.001"], product="gcp", service="audit",
+ when={"method_name_endswith": "SetOrgPolicy", "list_policy_all_values": "ALLOW"},
+ fp=[FP_TUNING], playbook="tpl-defense-evasion"),
+ S(slug="gcp-iam-service-account-key-mass-create", name="GCP Service Account Key Burst",
+ severity="high", mitre=["t1098.001"], product="gcp", service="audit",
+ when={"method_name_endswith": "CreateServiceAccountKey", "events_per_minute_gt": 5},
+ fp=[FP_AUTOMATION], playbook="tpl-persistence"),
+ S(slug="gcp-iam-grant-from-foreign-domain", name="GCP IAM Binding To External Domain",
+ severity="high", mitre=["t1199"], product="gcp", service="audit",
+ when={"method_name_endswith": "SetIamPolicy", "added_member_external_domain": True},
+ fp=["Approved partner identity"], playbook="tpl-initial-access"),
+ S(slug="gcp-iam-impersonation-burst", name="GCP Service Account Impersonation Burst",
+ severity="high", mitre=["t1078.004"], product="gcp", service="audit",
+ when={"method_name_endswith": "GenerateAccessToken", "distinct_targets_per_minute_gt": 10},
+ fp=[FP_AUTOMATION], playbook="tpl-credential-access"),
+ S(slug="gcp-iam-conditional-binding-removed", name="GCP IAM Conditional Binding Removed",
+ severity="medium", mitre=["t1556"], product="gcp", service="audit",
+ when={"method_name_endswith": "SetIamPolicy", "condition_removed": True},
+ fp=[FP_TUNING], playbook="tpl-defense-evasion"),
+ # ---- GCS (6) ----
+ S(slug="gcp-gcs-bucket-iam-allusers", name="GCS Bucket IAM Granted To allUsers",
+ severity="critical", mitre=["t1530"], product="gcp", service="audit",
+ when={"method_name_endswith_any": ["storage.setIamPermissions", "storage.buckets.update"], "added_member_in": ["allUsers", "allAuthenticatedUsers"]},
+ fp=["Public CDN bucket by design"], playbook="tpl-data-exposure"),
+ S(slug="gcp-gcs-uniform-access-disabled", name="GCS Uniform Bucket-Level Access Disabled",
+ severity="medium", mitre=["t1530"], product="gcp", service="audit",
+ when={"method_name_endswith": "storage.buckets.update", "uniform_bucket_level_access": False},
+ fp=[FP_TUNING], playbook="tpl-data-exposure"),
+ S(slug="gcp-gcs-mass-delete", name="GCS Mass Object Delete Burst",
+ severity="critical", mitre=["t1485"], product="gcp", service="audit",
+ when={"method_name": "storage.objects.delete", "events_per_minute_gt": 1000},
+ fp=["Lifecycle rule"], playbook="tpl-impact"),
+ S(slug="gcp-gcs-bucket-retention-removed", name="GCS Bucket Retention Policy Removed",
+ severity="high", mitre=["t1485"], product="gcp", service="audit",
+ when={"method_name_endswith": "storage.buckets.removeRetentionPolicy"},
+ fp=[FP_TUNING], playbook="tpl-impact"),
+ S(slug="gcp-gcs-versioning-disabled", name="GCS Object Versioning Disabled",
+ severity="medium", mitre=["t1490"], product="gcp", service="audit",
+ when={"method_name_endswith": "storage.buckets.update", "versioning_enabled": False},
+ fp=[FP_TUNING], playbook="tpl-impact"),
+ S(slug="gcp-gcs-cors-wildcard", name="GCS Bucket CORS Wildcard Origin",
+ severity="medium", mitre=["t1530"], product="gcp", service="audit",
+ when={"method_name_endswith": "storage.buckets.update", "cors_origin": "*"},
+ fp=["Public API by design"], playbook="tpl-data-exposure"),
+ # ---- GKE (5) ----
+ S(slug="gcp-gke-rbac-anonymous", name="GKE Cluster Anonymous Auth Enabled",
+ severity="critical", mitre=["t1133"], product="gcp", service="audit",
+ when={"method_name_endswith": "clusters.update", "anonymous_auth": True},
+ fp=[], playbook="tpl-initial-access"),
+ S(slug="gcp-gke-private-cluster-disabled", name="GKE Cluster Private Cluster Disabled",
+ severity="high", mitre=["t1133"], product="gcp", service="audit",
+ when={"method_name_endswith": "clusters.update", "private_cluster": False, "authorized_networks_empty": True},
+ fp=["Lab cluster"], playbook="tpl-initial-access"),
+ S(slug="gcp-gke-workload-identity-disabled", name="GKE Workload Identity Disabled",
+ severity="medium", mitre=["t1078"], product="gcp", service="audit",
+ when={"method_name_endswith": "clusters.update", "workload_identity_config": None},
+ fp=[FP_TUNING], playbook="tpl-defense-evasion"),
+ S(slug="gcp-gke-shielded-nodes-disabled", name="GKE Shielded Nodes Disabled",
+ severity="medium", mitre=["t1610"], product="gcp", service="audit",
+ when={"method_name_endswith": "clusters.update", "shielded_nodes": False},
+ fp=[FP_TUNING], playbook="tpl-defense-evasion"),
+ S(slug="gcp-gke-binary-auth-disabled", name="GKE Binary Authorization Disabled",
+ severity="medium", mitre=["t1610"], product="gcp", service="audit",
+ when={"method_name_endswith": "clusters.update", "binary_authorization": False},
+ fp=[FP_TUNING], playbook="tpl-supply-chain"),
+ # ---- BigQuery (5) ----
+ S(slug="gcp-bq-dataset-allusers-access", name="BigQuery Dataset ACL Adds allUsers",
+ severity="critical", mitre=["t1530"], product="gcp", service="audit",
+ when={"method_name": "datasetservice.update", "added_member_in": ["allUsers", "allAuthenticatedUsers"]},
+ fp=["Public dataset by design"], playbook="tpl-data-exposure"),
+ S(slug="gcp-bq-mass-export", name="BigQuery Mass Export Burst",
+ severity="high", mitre=["t1567.002"], product="gcp", service="audit",
+ when={"method_name_in": ["jobservice.jobcompleted", "jobs.insert"], "job_type": "EXPORT", "events_per_minute_gt": 5},
+ fp=["Scheduled BI export"], playbook="tpl-exfiltration"),
+ S(slug="gcp-bq-cross-project-query", name="BigQuery Query Across External Project",
+ severity="medium", mitre=["t1083"], product="gcp", service="audit",
+ when={"method_name": "jobservice.jobcompleted", "referenced_project_external": True},
+ fp=["Cross-project analytics by design"], playbook="tpl-discovery"),
+ S(slug="gcp-bq-table-deleted-recently-created", name="BigQuery Table Deleted Within 1 Hour Of Creation",
+ severity="medium", mitre=["t1485"], product="gcp", service="audit",
+ when={"method_name": "tableservice.delete", "table_age_minutes_lt": 60},
+ fp=["Test/CI run"], playbook="tpl-impact"),
+ S(slug="gcp-bq-cmek-removed", name="BigQuery Dataset CMEK Removed",
+ severity="medium", mitre=["t1485"], product="gcp", service="audit",
+ when={"method_name": "datasetservice.update", "kms_key_removed": True},
+ fp=[FP_TUNING], playbook="tpl-impact"),
+ # ---- Compute / Networking (4) ----
+ S(slug="gcp-compute-firewall-source-any-port-any", name="GCP Firewall Rule 0.0.0.0/0 With Any Port",
+ severity="high", mitre=["t1133"], product="gcp", service="audit",
+ when={"method_name_endswith": "firewalls.insert", "source_ranges_contains": "0.0.0.0/0", "port_any": True},
+ fp=["Lab project"], playbook="tpl-initial-access"),
+ S(slug="gcp-compute-instance-public-ip-attached", name="GCP Compute Public IP Attached To Instance",
+ severity="medium", mitre=["t1133"], product="gcp", service="audit",
+ when={"method_name_endswith": "instances.insert", "external_ip_attached": True, "label_internal": True},
+ fp=[FP_TUNING], playbook="tpl-initial-access"),
+ S(slug="gcp-compute-os-login-disabled", name="GCP Project OS Login Disabled",
+ severity="medium", mitre=["t1556"], product="gcp", service="audit",
+ when={"method_name_endswith": "projects.setCommonInstanceMetadata", "metadata_oslogin": "FALSE"},
+ fp=[FP_TUNING], playbook="tpl-defense-evasion"),
+ S(slug="gcp-compute-shielded-vm-disabled", name="GCP Compute Shielded VM Disabled",
+ severity="medium", mitre=["t1610"], product="gcp", service="audit",
+ when={"method_name_endswith": "instances.update", "shielded_instance_config": False},
+ fp=[FP_TUNING], playbook="tpl-defense-evasion"),
+]
+
+
+# ---------------------------------------------------------------------------
+# Kubernetes (15 rules) - cloud-agnostic
+# ---------------------------------------------------------------------------
+K8S_RULES: list[dict] = [
+ S(slug="k8s-cluster-admin-binding-non-system", name="Kubernetes cluster-admin ClusterRoleBinding For Non-System Subject",
+ severity="critical", mitre=["t1098.001"], product="kubernetes", service="audit",
+ when={"verb": "create", "object_resource": "clusterrolebindings", "role_ref_name": "cluster-admin", "subject_namespace_not": "kube-system"},
+ fp=["Bootstrap of new cluster"], playbook="tpl-privilege-escalation"),
+ S(slug="k8s-secret-mass-get", name="Kubernetes Secret Mass Get",
+ severity="high", mitre=["t1552.001"], product="kubernetes", service="audit",
+ when={"verb": "get", "object_resource": "secrets", "distinct_secrets_per_minute_gt": 30},
+ fp=["Operator boot"], playbook="tpl-credential-access"),
+ S(slug="k8s-pod-exec-prod-namespace", name="Kubernetes pods/exec In Production Namespace",
+ severity="high", mitre=["t1610"], product="kubernetes", service="audit",
+ when={"verb": "create", "object_resource": "pods/exec", "object_namespace_in": ["prod", "production"]},
+ fp=["DFIR responder", FP_FORENSIC], playbook="tpl-execution"),
+ S(slug="k8s-pod-attach-prod-namespace", name="Kubernetes pods/attach In Production Namespace",
+ severity="medium", mitre=["t1610"], product="kubernetes", service="audit",
+ when={"verb": "create", "object_resource": "pods/attach", "object_namespace_in": ["prod", "production"]},
+ fp=[FP_FORENSIC], playbook="tpl-execution"),
+ S(slug="k8s-anonymous-system-unauth", name="Kubernetes Request By system:anonymous",
+ severity="critical", mitre=["t1078"], product="kubernetes", service="audit",
+ when={"user_name": "system:anonymous", "response_status_code_lt": 400},
+ fp=["Healthz probe (must be ticketed)"], playbook="tpl-initial-access"),
+ S(slug="k8s-rbac-wildcard-verb", name="Kubernetes Role Created With Wildcard Verb",
+ severity="high", mitre=["t1078"], product="kubernetes", service="audit",
+ when={"verb_in": ["create", "update"], "object_resource_in": ["roles", "clusterroles"], "rule_verbs_contains": "*"},
+ fp=["Operator chart"], playbook="tpl-privilege-escalation"),
+ S(slug="k8s-pod-host-pid-enabled", name="Kubernetes Pod hostPID=true",
+ severity="high", mitre=["t1611"], product="kubernetes", service="audit",
+ when={"verb": "create", "object_resource": "pods", "host_pid": True},
+ fp=["DaemonSet for monitoring"], playbook="tpl-privilege-escalation"),
+ S(slug="k8s-pod-host-network-enabled", name="Kubernetes Pod hostNetwork=true",
+ severity="high", mitre=["t1611"], product="kubernetes", service="audit",
+ when={"verb": "create", "object_resource": "pods", "host_network": True},
+ fp=["CNI / kube-proxy DaemonSet"], playbook="tpl-privilege-escalation"),
+ S(slug="k8s-pod-privileged-container", name="Kubernetes Privileged Container Created",
+ severity="high", mitre=["t1611"], product="kubernetes", service="audit",
+ when={"verb": "create", "object_resource": "pods", "privileged": True},
+ fp=["Sysdig / Falco DaemonSet"], playbook="tpl-privilege-escalation"),
+ S(slug="k8s-validating-webhook-deleted", name="Kubernetes ValidatingWebhookConfiguration Deleted",
+ severity="medium", mitre=["t1562.001"], product="kubernetes", service="audit",
+ when={"verb": "delete", "object_resource": "validatingwebhookconfigurations"},
+ fp=[FP_TUNING], playbook="tpl-defense-evasion"),
+ S(slug="k8s-mutating-webhook-suspicious-target", name="Kubernetes MutatingWebhookConfiguration With External Endpoint",
+ severity="high", mitre=["t1556"], product="kubernetes", service="audit",
+ when={"verb_in": ["create", "update"], "object_resource": "mutatingwebhookconfigurations", "webhook_url_external": True},
+ fp=["Approved policy controller"], playbook="tpl-defense-evasion"),
+ S(slug="k8s-service-account-token-mount-default", name="Kubernetes Pod Default ServiceAccount Token Mount",
+ severity="low", mitre=["t1078"], product="kubernetes", service="audit",
+ when={"verb": "create", "object_resource": "pods", "service_account": "default", "automount_token": True},
+ fp=["Greenfield workload"], playbook="tpl-credential-access"),
+ S(slug="k8s-impersonation-by-user", name="Kubernetes Impersonate Privileged User",
+ severity="high", mitre=["t1078.001"], product="kubernetes", service="audit",
+ when={"verb_contains": "impersonate", "impersonated_user_in": ["system:masters", "kubernetes-admin"]},
+ fp=[FP_FORENSIC], playbook="tpl-privilege-escalation"),
+ S(slug="k8s-namespace-deletion-prod", name="Kubernetes Production Namespace Deleted",
+ severity="critical", mitre=["t1485"], product="kubernetes", service="audit",
+ when={"verb": "delete", "object_resource": "namespaces", "object_name_in": ["prod", "production"]},
+ fp=[FP_BREAK_GLASS], playbook="tpl-impact"),
+ S(slug="k8s-network-policy-deleted-prod", name="Kubernetes NetworkPolicy Deleted In Production",
+ severity="high", mitre=["t1562.004"], product="kubernetes", service="audit",
+ when={"verb": "delete", "object_resource": "networkpolicies", "object_namespace_in": ["prod", "production"]},
+ fp=[FP_TUNING], playbook="tpl-defense-evasion"),
+]
+
+
+# ---------------------------------------------------------------------------
+# Multi-cloud / SaaS-cloud (10 rules)
+# ---------------------------------------------------------------------------
+MULTI_CLOUD_RULES: list[dict] = [
+ S(slug="cloud-cloudflare-zone-transfer", name="Cloudflare Zone Transferred Out Of Account",
+ severity="high", mitre=["t1583.001"], product="cloudflare", service="audit",
+ when={"action": "zone.transfer_out"},
+ fp=["Approved org migration"], playbook="tpl-impact"),
+ S(slug="cloud-cloudflare-waf-rule-disabled", name="Cloudflare WAF Rule Disabled",
+ severity="high", mitre=["t1562.001"], product="cloudflare", service="audit",
+ when={"action_in": ["firewall_rule.disable", "waf_rule.disable"]},
+ fp=[FP_TUNING], playbook="tpl-defense-evasion"),
+ S(slug="cloud-cloudflare-access-policy-bypass", name="Cloudflare Access Policy Bypass Granted",
+ severity="critical", mitre=["t1556"], product="cloudflare", service="audit",
+ when={"action": "access_policy.create", "decision": "bypass"},
+ fp=[FP_BREAK_GLASS], playbook="tpl-defense-evasion"),
+ S(slug="cloud-do-droplet-snapshot-shared", name="DigitalOcean Droplet Snapshot Transferred",
+ severity="high", mitre=["t1537"], product="digitalocean", service="api",
+ when={"action": "snapshot.transfer", "destination_account_external": True},
+ fp=["Approved DR copy"], playbook="tpl-exfiltration"),
+ S(slug="cloud-oci-iam-tenant-admin-binding", name="OCI Tenant Administrators Group Membership Added",
+ severity="critical", mitre=["t1078.004"], product="oci", service="audit",
+ when={"event_name": "AddUserToGroup", "group": "Administrators", "compartment": "tenancy"},
+ fp=[FP_BREAK_GLASS], playbook="tpl-privilege-escalation"),
+ S(slug="cloud-multi-cross-cloud-mass-egress", name="Multi-Cloud Cross-Cloud Mass Egress Burst",
+ severity="high", mitre=["t1567"], product="multi-cloud", service="netflow",
+ when={"src_cloud_in": ["aws", "azure", "gcp"], "dst_cloud_in": ["aws", "azure", "gcp"], "src_cloud_neq_dst_cloud": True, "bytes_out_per_minute_gt": 1073741824},
+ fp=["Approved cross-cloud replication pipeline"], playbook="tpl-exfiltration"),
+ S(slug="cloud-iac-drift-bypassed", name="Infra-As-Code Drift Bypassed With Manual Override",
+ severity="medium", mitre=["t1610"], product="multi-cloud", service="iac",
+ when={"action": "manual_override", "approver_in": ["self"], "out_of_hours": True},
+ fp=[FP_BREAK_GLASS], playbook="tpl-impact"),
+ S(slug="cloud-terraform-state-modified-direct", name="Terraform State File Modified Outside Pipeline",
+ severity="high", mitre=["t1565.001"], product="multi-cloud", service="iac",
+ when={"action": "state.modify", "actor_in_pipeline": False},
+ fp=["Manual recovery (incident-tracked)"], playbook="tpl-impact"),
+ S(slug="cloud-saml-idp-trust-changed", name="Cloud Provider SAML IdP Trust Changed",
+ severity="high", mitre=["t1556"], product="multi-cloud", service="iam",
+ when={"event_name_in": ["UpdateSAMLProvider", "Update federation configuration", "SetIdentityProvider"], "metadata_url_changed": True},
+ fp=["IdP migration (must be ticketed)"], playbook="tpl-defense-evasion"),
+ S(slug="cloud-org-rootmail-modified", name="Cloud Provider Root/Owner Email Modified",
+ severity="critical", mitre=["t1078.004"], product="multi-cloud", service="iam",
+ when={"event_name_in": ["UpdateAccountEmail", "Update tenant primary contact", "ChangeRootMail"], "actor_eq_target": False},
+ fp=["Approved ownership transfer"], playbook="tpl-account-manipulation"),
+]
+
+
+# ---------------------------------------------------------------------------
+# Combined CLOUD extras
+# ---------------------------------------------------------------------------
+CLOUD_EXTRA: list[dict] = [
+ *AWS_RULES,
+ *AZURE_RULES,
+ *GCP_RULES,
+ *K8S_RULES,
+ *MULTI_CLOUD_RULES,
+]
+
+
+if __name__ == "__main__":
+ print(f"AWS: {len(AWS_RULES)}")
+ print(f"Azure: {len(AZURE_RULES)}")
+ print(f"GCP: {len(GCP_RULES)}")
+ print(f"Kubernetes: {len(K8S_RULES)}")
+ print(f"Multi: {len(MULTI_CLOUD_RULES)}")
+ print(f"TOTAL: {len(CLOUD_EXTRA)}")
diff --git a/scripts/detection_specs_part3_endpoint.py b/scripts/detection_specs_part3_endpoint.py
new file mode 100644
index 000000000..6ad179408
--- /dev/null
+++ b/scripts/detection_specs_part3_endpoint.py
@@ -0,0 +1,1083 @@
+"""
+Detection Pack v1 - Part 3 / Endpoint (240 new specs)
+=====================================================
+
+Native endpoint detection rules covering Windows, Linux, macOS, container
+hosts and mobile/EDR posture. These extend the 40 stable endpoint rules in
+``detection_specs.ENDPOINT`` to a total of 280 native endpoint detections.
+
+Authoring rules are documented in ``detection_specs_part3_helpers.py``; the
+short version is "use the ``S()`` builder, supply a flat ``match_when``, and
+the helper synthesises both fixtures."
+"""
+
+from __future__ import annotations
+
+from detection_specs_part3_helpers import ( # type: ignore[import-not-found]
+ FP_AUTOMATION,
+ FP_BACKUP,
+ FP_BREAK_GLASS,
+ FP_FORENSIC,
+ FP_ONBOARD,
+ FP_PATCH,
+ FP_PENTEST,
+ FP_TUNING,
+ S,
+)
+
+
+# ---------------------------------------------------------------------------
+# Windows (90 rules)
+# ---------------------------------------------------------------------------
+WINDOWS_RULES: list[dict] = [
+ # ---- Persistence: services, tasks, registry (20) ----
+ S(slug="win-service-create-suspicious-binpath", name="Windows Service Created With Suspicious BinaryPath",
+ severity="high", mitre=["t1543.003"], product="windows", service="services",
+ when={"event_id": 7045, "service_image_path_contains_any": ["\\users\\public\\", "\\appdata\\local\\temp\\", "\\programdata\\"]},
+ fp=[FP_PATCH, FP_AUTOMATION], playbook="tpl-persistence"),
+ S(slug="win-service-modify-image-path", name="Windows Service Image Path Modified",
+ severity="high", mitre=["t1543.003", "t1574"], product="windows", service="services",
+ when={"event_id": 4697, "service_image_path_changed": True},
+ fp=[FP_PATCH, "Approved binary upgrade"], playbook="tpl-persistence"),
+ S(slug="win-service-svchost-loaded-suspicious-dll", name="Windows svchost.exe Loaded DLL From User Path",
+ severity="high", mitre=["t1574.002"], product="windows", service="sysmon",
+ when={"image_loaded_path_contains_any": ["\\users\\", "\\temp\\", "\\appdata\\"], "process_name": "svchost.exe"},
+ fp=["Sanctioned 3rd-party tooling installer"], playbook="tpl-defense-evasion"),
+ S(slug="win-task-create-from-untrusted-process", name="Scheduled Task Created From Office or Browser",
+ severity="high", mitre=["t1053.005"], product="windows", service="task-scheduler",
+ when={"event_id": 4698, "creator_process_endswith_any": ["winword.exe", "excel.exe", "outlook.exe", "chrome.exe", "msedge.exe"]},
+ fp=[FP_AUTOMATION], playbook="tpl-persistence"),
+ S(slug="win-task-runs-encoded-powershell", name="Scheduled Task Runs Encoded PowerShell",
+ severity="high", mitre=["t1053.005", "t1027"], product="windows", service="task-scheduler",
+ when={"event_id": 4698, "task_command_contains": "-encodedcommand"},
+ fp=["Vendor agent that uses encoded payloads (allow-listed)"], playbook="tpl-execution"),
+ S(slug="win-runkey-write-binary-temp", name="Registry Run Key Points To Temp Path",
+ severity="high", mitre=["t1547.001"], product="windows", service="sysmon",
+ when={"event_id": 13, "target_object_contains": "\\currentversion\\run", "value_data_contains_any": ["\\temp\\", "\\appdata\\local\\temp\\"]},
+ fp=["Installer pre-warm (verify hash)"], playbook="tpl-persistence"),
+ S(slug="win-runonceex-write", name="Registry RunOnceEx Key Modified",
+ severity="medium", mitre=["t1547.001"], product="windows", service="sysmon",
+ when={"event_id": 13, "target_object_contains": "\\runonceex"},
+ fp=[FP_PATCH], playbook="tpl-persistence"),
+ S(slug="win-image-file-execution-options-debugger", name="Image File Execution Options Debugger Set",
+ severity="critical", mitre=["t1546.012"], product="windows", service="sysmon",
+ when={"event_id": 13, "target_object_contains": "image file execution options", "value_name": "Debugger"},
+ fp=["Authorised debugger setup (development host)"], playbook="tpl-persistence"),
+ S(slug="win-appinit-dll-write", name="AppInit_DLLs Registry Value Modified",
+ severity="high", mitre=["t1546.010"], product="windows", service="sysmon",
+ when={"event_id": 13, "target_object_endswith": "\\appinit_dlls"},
+ fp=["Endpoint protection installer"], playbook="tpl-persistence"),
+ S(slug="win-winlogon-userinit-modified", name="Winlogon Userinit Registry Value Modified",
+ severity="critical", mitre=["t1547.004"], product="windows", service="sysmon",
+ when={"event_id": 13, "target_object_endswith_any": ["\\userinit", "\\shell"]},
+ fp=["Imaging baseline (verify deployment ticket)"], playbook="tpl-persistence"),
+ S(slug="win-screensaver-registry-binary", name="ScreenSaver Registry Path Set To Custom Binary",
+ severity="medium", mitre=["t1546.002"], product="windows", service="sysmon",
+ when={"event_id": 13, "target_object_endswith": "\\scrnsave.exe"},
+ fp=["Corporate-branded screensaver via GPO"], playbook="tpl-persistence"),
+ S(slug="win-bootexecute-modified", name="HKLM BootExecute Registry Value Modified",
+ severity="critical", mitre=["t1547"], product="windows", service="sysmon",
+ when={"event_id": 13, "target_object_endswith": "\\session manager\\bootexecute"},
+ fp=[FP_PATCH], playbook="tpl-persistence"),
+ S(slug="win-startup-folder-write", name="Startup Folder Written By Non-Installer Process",
+ severity="medium", mitre=["t1547.001"], product="windows", service="sysmon",
+ when={"event_id": 11, "target_filename_contains": "\\start menu\\programs\\startup\\", "creator_process_not_endswith_any": ["msiexec.exe", "setup.exe"]},
+ fp=["Self-published in-house tooling (allow-listed signer)"], playbook="tpl-persistence"),
+ S(slug="win-logon-script-registry", name="Logon Script Registry Modified",
+ severity="high", mitre=["t1037.001"], product="windows", service="sysmon",
+ when={"event_id": 13, "target_object_endswith": "\\environment\\userinitmprlogonscript"},
+ fp=[FP_AUTOMATION], playbook="tpl-persistence"),
+ S(slug="win-com-hijack-classes-root", name="COM Hijack Via HKCR\\CLSID\\InprocServer32 Modification",
+ severity="high", mitre=["t1546.015"], product="windows", service="sysmon",
+ when={"event_id": 13, "target_object_contains": "\\classes\\clsid\\", "target_object_endswith": "\\inprocserver32\\(default)"},
+ fp=["MSI install of legitimate COM component"], playbook="tpl-persistence"),
+ S(slug="win-wmi-eventfilter-create", name="Permanent WMI EventFilter Created",
+ severity="high", mitre=["t1546.003"], product="windows", service="sysmon",
+ when={"event_id": 19},
+ fp=["Endpoint mgmt agent uses WMI persistence (allow-listed)"], playbook="tpl-persistence"),
+ S(slug="win-wmi-eventconsumer-create", name="Permanent WMI EventConsumer Created",
+ severity="high", mitre=["t1546.003"], product="windows", service="sysmon",
+ when={"event_id": 20},
+ fp=["Endpoint mgmt agent uses WMI persistence (allow-listed)"], playbook="tpl-persistence"),
+ S(slug="win-wmi-binding-create", name="WMI Filter-To-Consumer Binding Created",
+ severity="high", mitre=["t1546.003"], product="windows", service="sysmon",
+ when={"event_id": 21},
+ fp=["Endpoint mgmt agent uses WMI persistence (allow-listed)"], playbook="tpl-persistence"),
+ S(slug="win-shim-database-installed", name="Application Compatibility Shim Database Installed",
+ severity="high", mitre=["t1546.011"], product="windows", service="sysmon",
+ when={"event_id": 1, "process_name_endswith": "sdbinst.exe", "process_command_line_contains_any": [".sdb", "/install"]},
+ fp=["Microsoft compatibility tooling rolled by IT"], playbook="tpl-persistence"),
+ S(slug="win-print-monitor-installed", name="Print Monitor DLL Installed",
+ severity="high", mitre=["t1547.010"], product="windows", service="sysmon",
+ when={"event_id": 13, "target_object_contains": "\\control\\print\\monitors\\"},
+ fp=["Vendor printer driver install"], playbook="tpl-persistence"),
+
+ # ---- Defense evasion (15) ----
+ S(slug="win-defender-disabled-via-registry", name="Microsoft Defender Disabled Via Registry",
+ severity="high", mitre=["t1562.001"], product="windows", service="sysmon",
+ when={"event_id": 13, "target_object_contains": "\\windows defender\\", "value_name": "DisableAntiSpyware", "value_data": "1"},
+ fp=["Conflicting AV product install"], playbook="tpl-defense-evasion"),
+ S(slug="win-defender-realtime-monitoring-off", name="Defender Real-Time Monitoring Disabled",
+ severity="high", mitre=["t1562.001"], product="windows", service="defender",
+ when={"event_id": 5001},
+ fp=["Conflicting AV product install"], playbook="tpl-defense-evasion"),
+ S(slug="win-defender-exclusion-added", name="Microsoft Defender Path Exclusion Added",
+ severity="medium", mitre=["t1562.001"], product="windows", service="defender",
+ when={"event_name": "AddPreference", "exclusion_path_contains_any": ["\\users\\", "\\temp\\", "\\appdata\\"]},
+ fp=["Approved third-party tool exclusion"], playbook="tpl-defense-evasion"),
+ S(slug="win-amsi-provider-loaded", name="AMSI Provider DLL Loaded From User Path",
+ severity="high", mitre=["t1562.001"], product="windows", service="sysmon",
+ when={"event_id": 13, "target_object_endswith": "\\amsi\\providers", "value_data_contains_any": ["\\users\\", "\\temp\\"]},
+ fp=[FP_PENTEST], playbook="tpl-defense-evasion"),
+ S(slug="win-etw-tampering-via-registry", name="ETW Disabled Via Registry",
+ severity="high", mitre=["t1562.006"], product="windows", service="sysmon",
+ when={"event_id": 13, "target_object_endswith": "\\autologger\\eventlog-application", "value_name": "Start", "value_data": "0"},
+ fp=[FP_PATCH], playbook="tpl-defense-evasion"),
+ S(slug="win-eventlog-service-stopped", name="Windows Event Log Service Stopped",
+ severity="high", mitre=["t1562.001"], product="windows", service="services",
+ when={"event_id": 7036, "service_name": "eventlog", "service_state": "stopped"},
+ fp=[FP_PATCH], playbook="tpl-defense-evasion"),
+ S(slug="win-application-log-cleared", name="Windows Application Event Log Cleared",
+ severity="high", mitre=["t1070.001"], product="windows", service="security",
+ when={"event_id": 1102, "log_name": "Application"},
+ fp=["Approved log archival job"], playbook="tpl-defense-evasion"),
+ S(slug="win-system-log-cleared", name="Windows System Event Log Cleared",
+ severity="high", mitre=["t1070.001"], product="windows", service="security",
+ when={"event_id": 104, "log_name": "System"},
+ fp=["Approved log archival job"], playbook="tpl-defense-evasion"),
+ S(slug="win-sysmon-config-changed", name="Sysmon Configuration Changed",
+ severity="high", mitre=["t1562.001"], product="windows", service="sysmon",
+ when={"event_id": 16},
+ fp=[FP_TUNING, FP_AUTOMATION], playbook="tpl-defense-evasion"),
+ S(slug="win-uac-bypass-fodhelper", name="UAC Bypass Via fodhelper.exe",
+ severity="high", mitre=["t1548.002"], product="windows", service="sysmon",
+ when={"event_id": 1, "process_name_endswith": "fodhelper.exe", "parent_process_endswith_any": ["powershell.exe", "cmd.exe"]},
+ fp=["Microsoft Optional Features install workflow"], playbook="tpl-privilege-escalation"),
+ S(slug="win-uac-bypass-eventvwr", name="UAC Bypass Via eventvwr.exe",
+ severity="high", mitre=["t1548.002"], product="windows", service="sysmon",
+ when={"event_id": 1, "process_name_endswith": "eventvwr.exe", "child_process_endswith_any": ["cmd.exe", "powershell.exe", "wscript.exe"]},
+ fp=["Admin support session"], playbook="tpl-privilege-escalation"),
+ S(slug="win-uac-bypass-sdclt", name="UAC Bypass Via sdclt.exe",
+ severity="high", mitre=["t1548.002"], product="windows", service="sysmon",
+ when={"event_id": 1, "process_name_endswith": "sdclt.exe", "child_process_endswith_any": ["cmd.exe", "powershell.exe"]},
+ fp=["Backup utility usage"], playbook="tpl-privilege-escalation"),
+ S(slug="win-always-install-elevated", name="AlwaysInstallElevated Registry Enabled",
+ severity="high", mitre=["t1548.002"], product="windows", service="sysmon",
+ when={"event_id": 13, "target_object_endswith": "\\installer\\alwaysinstallelevated", "value_data": "1"},
+ fp=[FP_AUTOMATION], playbook="tpl-privilege-escalation"),
+ S(slug="win-bcdedit-recovery-disabled", name="bcdedit Used To Disable Recovery",
+ severity="high", mitre=["t1490"], product="windows", service="sysmon",
+ when={"event_id": 1, "process_name_endswith": "bcdedit.exe", "process_command_line_contains_any": ["recoveryenabled no", "bootstatuspolicy ignoreallfailures"]},
+ fp=[FP_FORENSIC], playbook="tpl-impact"),
+ S(slug="win-vssadmin-list-shadows-then-delete", name="vssadmin Used To Enumerate And Delete Shadow Copies",
+ severity="critical", mitre=["t1490"], product="windows", service="sysmon",
+ when={"event_id": 1, "process_name_endswith": "vssadmin.exe", "process_command_line_contains_all": ["delete", "shadows"]},
+ fp=[FP_BACKUP], playbook="tpl-impact"),
+
+ # ---- Execution / scripting (15) ----
+ S(slug="win-powershell-iex-from-web", name="PowerShell Invoke-Expression On Web Download",
+ severity="high", mitre=["t1059.001"], product="windows", service="sysmon",
+ when={"event_id": 1, "process_name_endswith": "powershell.exe", "process_command_line_contains_all": ["iex", "downloadstring"]},
+ fp=[FP_AUTOMATION, "Allow-listed deployment script"], playbook="tpl-execution"),
+ S(slug="win-powershell-bypass-flag", name="PowerShell Run With ExecutionPolicy Bypass",
+ severity="medium", mitre=["t1059.001"], product="windows", service="sysmon",
+ when={"event_id": 1, "process_name_endswith": "powershell.exe", "process_command_line_contains_any": ["-executionpolicy bypass", "-ep bypass"]},
+ fp=[FP_AUTOMATION, "Sanctioned dev environment"], playbook="tpl-execution"),
+ S(slug="win-powershell-amsi-bypass-string", name="PowerShell Command Line Contains AMSI Bypass String",
+ severity="high", mitre=["t1562.001", "t1059.001"], product="windows", service="sysmon",
+ when={"event_id": 1, "process_command_line_contains_any": ["amsiUtils", "amsiInitFailed", "amsiContext"]},
+ fp=[FP_PENTEST], playbook="tpl-defense-evasion"),
+ S(slug="win-mshta-running-script", name="mshta.exe Executed Inline Script",
+ severity="high", mitre=["t1218.005"], product="windows", service="sysmon",
+ when={"event_id": 1, "process_name_endswith": "mshta.exe", "process_command_line_contains_any": ["javascript:", "vbscript:", "http"]},
+ fp=["Vendor installer that abuses mshta (allow-listed)"], playbook="tpl-execution"),
+ S(slug="win-rundll32-from-temp", name="rundll32.exe Loaded DLL From Temp Path",
+ severity="high", mitre=["t1218.011"], product="windows", service="sysmon",
+ when={"event_id": 1, "process_name_endswith": "rundll32.exe", "process_command_line_contains_any": ["\\temp\\", "\\appdata\\local\\temp"]},
+ fp=[FP_PATCH], playbook="tpl-execution"),
+ S(slug="win-rundll32-no-args", name="rundll32.exe Started Without Arguments",
+ severity="medium", mitre=["t1218.011"], product="windows", service="sysmon",
+ when={"event_id": 1, "process_name_endswith": "rundll32.exe", "process_command_line_endswith": "rundll32.exe"},
+ fp=["Cobalt Strike known false positive in dev VMs"], playbook="tpl-execution"),
+ S(slug="win-regsvr32-scrobj", name="regsvr32.exe Used With scrobj.dll (Squiblydoo)",
+ severity="high", mitre=["t1218.010"], product="windows", service="sysmon",
+ when={"event_id": 1, "process_name_endswith": "regsvr32.exe", "process_command_line_contains_all": ["scrobj.dll", "/i:"]},
+ fp=[FP_PENTEST], playbook="tpl-execution"),
+ S(slug="win-wmic-process-call-create-remote", name="wmic process call create Used For Remote Execution",
+ severity="high", mitre=["t1047"], product="windows", service="sysmon",
+ when={"event_id": 1, "process_name_endswith": "wmic.exe", "process_command_line_contains_all": ["/node:", "process call create"]},
+ fp=["IT remote support tooling (allow-listed)"], playbook="tpl-lateral-movement"),
+ S(slug="win-cscript-from-temp", name="cscript.exe Executing Script From Temp",
+ severity="medium", mitre=["t1059.005"], product="windows", service="sysmon",
+ when={"event_id": 1, "process_name_endswith": "cscript.exe", "process_command_line_contains_any": ["\\temp\\", "\\downloads\\"]},
+ fp=[FP_AUTOMATION], playbook="tpl-execution"),
+ S(slug="win-bitsadmin-download", name="bitsadmin.exe Downloading File",
+ severity="medium", mitre=["t1197"], product="windows", service="sysmon",
+ when={"event_id": 1, "process_name_endswith": "bitsadmin.exe", "process_command_line_contains_any": ["/transfer", "http"]},
+ fp=["Microsoft auto-update workflow"], playbook="tpl-command-and-control"),
+ S(slug="win-certutil-decode", name="certutil.exe Used To Decode Encoded File",
+ severity="high", mitre=["t1140"], product="windows", service="sysmon",
+ when={"event_id": 1, "process_name_endswith": "certutil.exe", "process_command_line_contains_any": ["-decode", "-decodehex", "-urlcache -split -f"]},
+ fp=[FP_PATCH], playbook="tpl-defense-evasion"),
+ S(slug="win-certutil-download-url", name="certutil.exe Used To Download Remote File",
+ severity="high", mitre=["t1105"], product="windows", service="sysmon",
+ when={"event_id": 1, "process_name_endswith": "certutil.exe", "process_command_line_contains": "-urlcache"},
+ fp=[FP_PATCH], playbook="tpl-command-and-control"),
+ S(slug="win-cmstp-load-untrusted-inf", name="cmstp.exe Loaded INF From Suspicious Path",
+ severity="high", mitre=["t1218.003"], product="windows", service="sysmon",
+ when={"event_id": 1, "process_name_endswith": "cmstp.exe", "process_command_line_contains_any": ["\\appdata\\", "\\temp\\"]},
+ fp=["Microsoft Configuration Manager rollouts"], playbook="tpl-execution"),
+ S(slug="win-installutil-from-temp", name="InstallUtil.exe Run From Temp Path",
+ severity="high", mitre=["t1218.004"], product="windows", service="sysmon",
+ when={"event_id": 1, "process_name_endswith": "installutil.exe", "process_command_line_contains_any": ["\\temp\\", "\\appdata\\"]},
+ fp=["Approved .NET deploy"], playbook="tpl-execution"),
+ S(slug="win-msbuild-running-inline-task", name="MSBuild Running Inline Task XML From User Path",
+ severity="high", mitre=["t1127.001"], product="windows", service="sysmon",
+ when={"event_id": 1, "process_name_endswith": "msbuild.exe", "process_command_line_contains_any": ["\\users\\public\\", "\\appdata\\"]},
+ fp=["Developer build pipeline (allow-listed)"], playbook="tpl-execution"),
+
+ # ---- Credential access (12) ----
+ S(slug="win-procdump-lsass", name="ProcDump Used Against lsass.exe",
+ severity="critical", mitre=["t1003.001"], product="windows", service="sysmon",
+ when={"event_id": 1, "process_name_endswith": "procdump.exe", "process_command_line_contains_any": ["lsass", "-ma lsass"]},
+ fp=[FP_FORENSIC, "Microsoft support memory capture"], playbook="tpl-credential-access"),
+ S(slug="win-comsvcs-minidump", name="comsvcs.dll MiniDump Of lsass",
+ severity="critical", mitre=["t1003.001"], product="windows", service="sysmon",
+ when={"event_id": 1, "process_name_endswith": "rundll32.exe", "process_command_line_contains_all": ["comsvcs.dll", "minidump"]},
+ fp=[FP_FORENSIC], playbook="tpl-credential-access"),
+ S(slug="win-mimikatz-strings-on-cli", name="Mimikatz Marker String In Process Command Line",
+ severity="critical", mitre=["t1003"], product="windows", service="sysmon",
+ when={"event_id": 1, "process_command_line_contains_any": ["sekurlsa::", "lsadump::", "kerberos::", "crypto::"]},
+ fp=[FP_PENTEST], playbook="tpl-credential-access"),
+ S(slug="win-ntds-extract-ntdsutil", name="ntdsutil.exe Used To Extract NTDS",
+ severity="critical", mitre=["t1003.003"], product="windows", service="sysmon",
+ when={"event_id": 1, "process_name_endswith": "ntdsutil.exe", "process_command_line_contains_any": ["ifm", "create full", "activate instance ntds"]},
+ fp=["AD recovery procedure"], playbook="tpl-credential-access"),
+ S(slug="win-vss-shadow-then-copy-ntds", name="VSS Shadow Created Then NTDS.dit Copied",
+ severity="critical", mitre=["t1003.003"], product="windows", service="sysmon",
+ when={"event_id": 11, "target_filename_endswith": "ntds.dit", "creator_process_endswith_any": ["copy.exe", "robocopy.exe", "powershell.exe"]},
+ fp=[FP_BACKUP], playbook="tpl-credential-access"),
+ S(slug="win-secretsdump-impacket", name="Impacket secretsdump.py Pattern Detected",
+ severity="critical", mitre=["t1003"], product="windows", service="sysmon",
+ when={"event_id": 1, "process_command_line_contains_any": ["secretsdump", "impacket", "sam.save", "system.save"]},
+ fp=[FP_PENTEST], playbook="tpl-credential-access"),
+ S(slug="win-reg-save-sam", name="reg save Used Against SAM/SECURITY/SYSTEM",
+ severity="critical", mitre=["t1003.002"], product="windows", service="sysmon",
+ when={"event_id": 1, "process_name_endswith": "reg.exe", "process_command_line_contains_all": ["save", "hklm\\sam"]},
+ fp=[FP_FORENSIC], playbook="tpl-credential-access"),
+ S(slug="win-credential-manager-vault-dump", name="vaultcmd.exe Listed All Stored Credentials",
+ severity="high", mitre=["t1555.004"], product="windows", service="sysmon",
+ when={"event_id": 1, "process_name_endswith": "vaultcmd.exe", "process_command_line_contains": "/listcreds"},
+ fp=[FP_FORENSIC], playbook="tpl-credential-access"),
+ S(slug="win-dpapi-masterkey-access", name="DPAPI Master Key File Read From Roaming Dir",
+ severity="high", mitre=["t1555.003"], product="windows", service="sysmon",
+ when={"event_id": 11, "target_filename_contains": "\\protect\\", "creator_process_not_endswith_any": ["lsass.exe", "explorer.exe"]},
+ fp=["Migration / profile fix-up tool"], playbook="tpl-credential-access"),
+ S(slug="win-browser-credential-file-read", name="Chromium Login Data SQLite File Read",
+ severity="high", mitre=["t1555.003"], product="windows", service="sysmon",
+ when={"event_id": 11, "target_filename_endswith": "\\login data", "creator_process_not_endswith_any": ["chrome.exe", "msedge.exe", "brave.exe"]},
+ fp=["Browser sync / migration tool"], playbook="tpl-credential-access"),
+ S(slug="win-dcsync-via-replication", name="DCSync Replication Right Used By Non-DC Account",
+ severity="critical", mitre=["t1003.006"], product="windows", service="security",
+ when={"event_id": 4662, "object_properties_contains": "1131f6aa-9c07-11d1-f79f-00c04fc2dcd2", "account_is_dc": False},
+ fp=["AD migration tool with replication granted"], playbook="tpl-credential-access"),
+ S(slug="win-kerberos-asrep-roast", name="Kerberos AS-REP Roasting Pattern",
+ severity="high", mitre=["t1558.004"], product="windows", service="security",
+ when={"event_id": 4768, "preauth_required": False, "ticket_encryption_type": "0x17"},
+ fp=["Legacy app with preauth disabled (deprecated, must be tracked)"], playbook="tpl-credential-access"),
+
+ # ---- Discovery / lateral (12) ----
+ S(slug="win-net-localgroup-administrators", name="net localgroup administrators Enumerated",
+ severity="medium", mitre=["t1087.001"], product="windows", service="sysmon",
+ when={"event_id": 1, "process_command_line_contains_any": ["net localgroup administrators", "net.exe localgroup administrators"]},
+ fp=["IT helpdesk routine check"], playbook="tpl-discovery"),
+ S(slug="win-net-group-domain-admins", name="net group \"Domain Admins\" Enumerated",
+ severity="high", mitre=["t1087.002"], product="windows", service="sysmon",
+ when={"event_id": 1, "process_command_line_contains_all": ["net", "group", "domain admins"]},
+ fp=["IT helpdesk routine check"], playbook="tpl-discovery"),
+ S(slug="win-nltest-domain-trusts", name="nltest /domain_trusts Enumerated",
+ severity="medium", mitre=["t1482"], product="windows", service="sysmon",
+ when={"event_id": 1, "process_name_endswith": "nltest.exe", "process_command_line_contains": "/domain_trusts"},
+ fp=["AD trust diagnostics"], playbook="tpl-discovery"),
+ S(slug="win-adfind-enumeration", name="AdFind.exe Enumeration Detected",
+ severity="high", mitre=["t1087.002"], product="windows", service="sysmon",
+ when={"event_id": 1, "process_name_endswith": "adfind.exe"},
+ fp=["IT diagnostic with security ticket"], playbook="tpl-discovery"),
+ S(slug="win-bloodhound-sharphound", name="SharpHound Collection Run Detected",
+ severity="high", mitre=["t1087.002"], product="windows", service="sysmon",
+ when={"event_id": 1, "process_command_line_contains_any": ["sharphound", "invoke-bloodhound", "bloodhound.py"]},
+ fp=[FP_PENTEST], playbook="tpl-discovery"),
+ S(slug="win-arp-cache-enum", name="arp -a Enumeration By Workstation",
+ severity="low", mitre=["t1018"], product="windows", service="sysmon",
+ when={"event_id": 1, "process_name_endswith": "arp.exe", "process_command_line_contains": "-a"},
+ fp=["Network diagnostics"], playbook="tpl-discovery"),
+ S(slug="win-route-print", name="route print Run From Workstation",
+ severity="low", mitre=["t1018"], product="windows", service="sysmon",
+ when={"event_id": 1, "process_name_endswith": "route.exe", "process_command_line_contains": "print"},
+ fp=["Network diagnostics"], playbook="tpl-discovery"),
+ S(slug="win-net-share-enum", name="net view Used To Enumerate File Shares",
+ severity="low", mitre=["t1135"], product="windows", service="sysmon",
+ when={"event_id": 1, "process_command_line_contains_any": ["net view \\\\", "net.exe share"]},
+ fp=["IT routine inventory"], playbook="tpl-discovery"),
+ S(slug="win-psexec-execution-host", name="PsExec.exe Service Created On Host",
+ severity="high", mitre=["t1021.002"], product="windows", service="sysmon",
+ when={"event_id": 1, "process_name_endswith": "psexec.exe", "process_command_line_contains": "\\\\"},
+ fp=["IT remote support tooling (allow-listed)"], playbook="tpl-lateral-movement"),
+ S(slug="win-psexesvc-service-create", name="PSEXESVC Service Created (Remote PsExec)",
+ severity="high", mitre=["t1021.002"], product="windows", service="services",
+ when={"event_id": 7045, "service_name_endswith": "psexesvc", "service_image_path_contains": "psexec"},
+ fp=["IT remote support tooling (allow-listed)"], playbook="tpl-lateral-movement"),
+ S(slug="win-paexec-service-create", name="PAExec Service Created",
+ severity="high", mitre=["t1021.002"], product="windows", service="services",
+ when={"event_id": 7045, "service_name_contains": "paexec"},
+ fp=["IT remote support tooling (allow-listed)"], playbook="tpl-lateral-movement"),
+ S(slug="win-winrm-shell-from-workstation", name="WinRM Shell From Workstation To DC",
+ severity="high", mitre=["t1021.006"], product="windows", service="sysmon",
+ when={"event_id": 1, "process_command_line_contains": "enter-pssession", "destination_role": "domain-controller"},
+ fp=["Authorised AD admin from PAW"], playbook="tpl-lateral-movement"),
+
+ # ---- Process injection / impact (10) ----
+ S(slug="win-process-hollowing-marker", name="Process Hollowing Marker (CreateProcess Suspended + Unmapped)",
+ severity="high", mitre=["t1055.012"], product="windows", service="sysmon",
+ when={"event_id": 8, "create_remote_thread_target_process_endswith_any": ["explorer.exe", "svchost.exe", "lsass.exe"]},
+ fp=["EDR injection for protection (allow-listed)"], playbook="tpl-defense-evasion"),
+ S(slug="win-create-remote-thread-lsass", name="CreateRemoteThread Targeting lsass.exe",
+ severity="critical", mitre=["t1055.001"], product="windows", service="sysmon",
+ when={"event_id": 8, "target_image_endswith": "lsass.exe"},
+ fp=["EDR-allowed process injection"], playbook="tpl-credential-access"),
+ S(slug="win-suspicious-thread-into-explorer", name="Suspicious CreateRemoteThread Into explorer.exe",
+ severity="high", mitre=["t1055"], product="windows", service="sysmon",
+ when={"event_id": 8, "target_image_endswith": "explorer.exe", "source_image_path_contains_any": ["\\temp\\", "\\appdata\\"]},
+ fp=["EDR-allowed process injection"], playbook="tpl-defense-evasion"),
+ S(slug="win-cipher-w-secure-delete", name="cipher.exe /w Used (Secure Delete)",
+ severity="medium", mitre=["t1485"], product="windows", service="sysmon",
+ when={"event_id": 1, "process_name_endswith": "cipher.exe", "process_command_line_contains": "/w"},
+ fp=["Decommission / disposal procedure"], playbook="tpl-impact"),
+ S(slug="win-format-com-quick", name="format Command Used Against Drive",
+ severity="critical", mitre=["t1485"], product="windows", service="sysmon",
+ when={"event_id": 1, "process_name_endswith": "format.com", "process_command_line_contains_any": ["/q", "/p:0"]},
+ fp=["Asset disposal workflow"], playbook="tpl-impact"),
+ S(slug="win-icacls-deny-readonly", name="icacls Used To Deny Access On System Path",
+ severity="high", mitre=["t1222.001"], product="windows", service="sysmon",
+ when={"event_id": 1, "process_name_endswith": "icacls.exe", "process_command_line_contains_all": ["/deny", "everyone"]},
+ fp=[FP_BREAK_GLASS], playbook="tpl-impact"),
+ S(slug="win-takeown-system-path", name="takeown.exe Used Against System Path",
+ severity="medium", mitre=["t1222.001"], product="windows", service="sysmon",
+ when={"event_id": 1, "process_name_endswith": "takeown.exe", "process_command_line_contains_any": ["c:\\windows\\", "system32"]},
+ fp=[FP_PATCH], playbook="tpl-defense-evasion"),
+ S(slug="win-rundll32-shell32-controlrunDLL", name="rundll32.exe shell32 Control_RunDLL Used Suspiciously",
+ severity="medium", mitre=["t1218.011"], product="windows", service="sysmon",
+ when={"event_id": 1, "process_name_endswith": "rundll32.exe", "process_command_line_contains_any": ["shell32.dll,control_rundll", "shell32.dll, control_rundll"]},
+ fp=["Control panel applet legitimately invoked"], playbook="tpl-execution"),
+ S(slug="win-ransomware-ext-rename-burst", name="Burst Of File Extension Renames To Common Ransom Markers",
+ severity="critical", mitre=["t1486"], product="windows", service="sysmon",
+ when={"event_id": 11, "target_filename_endswith_any": [".locked", ".enc", ".crypt", ".lockbit", ".conti", ".royal"]},
+ fp=[FP_PENTEST], playbook="tpl-impact"),
+ S(slug="win-shadow-copy-mass-delete", name="Mass Shadow Copy Deletion Via WMI",
+ severity="critical", mitre=["t1490"], product="windows", service="sysmon",
+ when={"event_id": 1, "process_name_endswith": "wmic.exe", "process_command_line_contains_all": ["shadowcopy", "delete"]},
+ fp=[FP_BACKUP], playbook="tpl-impact"),
+
+ # ---- Office & living-off-the-land (6) ----
+ S(slug="win-office-spawn-mshta", name="Office Application Spawned mshta.exe",
+ severity="high", mitre=["t1218.005"], product="windows", service="sysmon",
+ when={"event_id": 1, "parent_process_endswith_any": ["winword.exe", "excel.exe", "powerpnt.exe"], "process_name_endswith": "mshta.exe"},
+ fp=["Macro-enabled enterprise template (allow-listed)"], playbook="tpl-execution"),
+ S(slug="win-office-spawn-rundll32", name="Office Application Spawned rundll32.exe",
+ severity="high", mitre=["t1218.011"], product="windows", service="sysmon",
+ when={"event_id": 1, "parent_process_endswith_any": ["winword.exe", "excel.exe", "powerpnt.exe"], "process_name_endswith": "rundll32.exe"},
+ fp=["Sanctioned add-in"], playbook="tpl-execution"),
+ S(slug="win-onenote-spawn-cmd", name="OneNote Spawned cmd.exe",
+ severity="high", mitre=["t1204.002"], product="windows", service="sysmon",
+ when={"event_id": 1, "parent_process_endswith": "onenote.exe", "process_name_endswith_any": ["cmd.exe", "powershell.exe", "wscript.exe"]},
+ fp=["Sanctioned macro-enabled OneNote (rare)"], playbook="tpl-execution"),
+ S(slug="win-pdfreader-spawn-shell", name="PDF Reader Spawned Shell",
+ severity="high", mitre=["t1204.002"], product="windows", service="sysmon",
+ when={"event_id": 1, "parent_process_endswith_any": ["acrord32.exe", "acrobat.exe", "foxitreader.exe"], "process_name_endswith_any": ["cmd.exe", "powershell.exe"]},
+ fp=["PDF embedding signed plug-in"], playbook="tpl-execution"),
+ S(slug="win-iso-mount-from-temp", name="ISO File Mounted From User Temp",
+ severity="medium", mitre=["t1204.002"], product="windows", service="sysmon",
+ when={"event_id": 11, "target_filename_endswith": ".iso", "target_filename_contains_any": ["\\temp\\", "\\downloads\\"]},
+ fp=["Software install workflow"], playbook="tpl-execution"),
+ S(slug="win-lnk-file-from-removable", name="LNK File Executed From Removable Media",
+ severity="medium", mitre=["t1204.002"], product="windows", service="sysmon",
+ when={"event_id": 1, "process_command_line_contains_any": ["e:\\", "f:\\"], "parent_image_endswith": "explorer.exe"},
+ fp=["Approved kiosk workflow"], playbook="tpl-execution"),
+]
+
+
+# ---------------------------------------------------------------------------
+# Linux / Unix (60 rules)
+# ---------------------------------------------------------------------------
+LINUX_RULES: list[dict] = [
+ # ---- Persistence (15) ----
+ S(slug="linux-systemd-service-create-untrusted", name="Systemd Unit File Written By Non-Package Process",
+ severity="high", mitre=["t1543.002"], product="linux", service="auditd",
+ when={"syscall": "openat", "path_contains": "/etc/systemd/system/", "exe_not_endswith_any": ["/dpkg", "/rpm", "/yum", "/apt-get", "/zypper"]},
+ fp=[FP_AUTOMATION, "Configuration management agent"], playbook="tpl-persistence"),
+ S(slug="linux-systemd-timer-create", name="Systemd Timer Unit Created",
+ severity="medium", mitre=["t1053.006"], product="linux", service="auditd",
+ when={"syscall": "openat", "path_contains": "/etc/systemd/system/", "path_endswith": ".timer"},
+ fp=[FP_AUTOMATION], playbook="tpl-persistence"),
+ S(slug="linux-cron-d-write", name="File Written Into /etc/cron.d Outside Package Mgr",
+ severity="high", mitre=["t1053.003"], product="linux", service="auditd",
+ when={"syscall": "openat", "path_contains": "/etc/cron.d/", "exe_not_endswith_any": ["/dpkg", "/rpm", "/apt-get", "/yum", "/dnf"]},
+ fp=[FP_AUTOMATION], playbook="tpl-persistence"),
+ S(slug="linux-anacron-job-add", name="Anacron Job File Added",
+ severity="medium", mitre=["t1053.003"], product="linux", service="auditd",
+ when={"syscall": "openat", "path_contains_any": ["/etc/anacrontab", "/etc/cron.daily/", "/etc/cron.weekly/"], "exe_not_endswith_any": ["/dpkg", "/rpm"]},
+ fp=[FP_AUTOMATION], playbook="tpl-persistence"),
+ S(slug="linux-at-job-create", name="at Job Created",
+ severity="medium", mitre=["t1053.001"], product="linux", service="auditd",
+ when={"syscall": "execve", "exe_endswith": "/at"},
+ fp=["IT scheduled task workflow"], playbook="tpl-persistence"),
+ S(slug="linux-rclocal-modified", name="/etc/rc.local Modified",
+ severity="high", mitre=["t1037.004"], product="linux", service="auditd",
+ when={"syscall": "openat", "path": "/etc/rc.local"},
+ fp=["Legacy boot workflow refresh"], playbook="tpl-persistence"),
+ S(slug="linux-initd-script-add", name="/etc/init.d/ Script Added By Non-Pkg Process",
+ severity="high", mitre=["t1037.004"], product="linux", service="auditd",
+ when={"syscall": "openat", "path_contains": "/etc/init.d/", "exe_not_endswith_any": ["/dpkg", "/rpm"]},
+ fp=[FP_AUTOMATION], playbook="tpl-persistence"),
+ S(slug="linux-bashrc-modified-by-other-user", name="~/.bashrc Modified By Other User",
+ severity="medium", mitre=["t1546.004"], product="linux", service="auditd",
+ when={"syscall": "openat", "path_endswith": "/.bashrc", "actor_uid_neq_owner_uid": True},
+ fp=[FP_AUTOMATION, "Configuration mgmt managed dotfiles"], playbook="tpl-persistence"),
+ S(slug="linux-zshrc-modified-by-other-user", name="~/.zshrc Modified By Other User",
+ severity="medium", mitre=["t1546.004"], product="linux", service="auditd",
+ when={"syscall": "openat", "path_endswith": "/.zshrc", "actor_uid_neq_owner_uid": True},
+ fp=[FP_AUTOMATION], playbook="tpl-persistence"),
+ S(slug="linux-pam-d-modified", name="/etc/pam.d/ Configuration Modified",
+ severity="high", mitre=["t1556.003"], product="linux", service="auditd",
+ when={"syscall": "openat", "path_contains": "/etc/pam.d/", "exe_not_endswith_any": ["/dpkg", "/rpm", "/yum"]},
+ fp=[FP_AUTOMATION], playbook="tpl-credential-access"),
+ S(slug="linux-nss-module-installed", name="NSS Module Installed In /usr/lib",
+ severity="high", mitre=["t1556"], product="linux", service="auditd",
+ when={"syscall": "openat", "path_startswith": "/usr/lib", "path_contains": "libnss_", "exe_not_endswith_any": ["/dpkg", "/rpm"]},
+ fp=[FP_AUTOMATION], playbook="tpl-credential-access"),
+ S(slug="linux-sudoers-d-add", name="New File Added Under /etc/sudoers.d/",
+ severity="high", mitre=["t1098"], product="linux", service="auditd",
+ when={"syscall": "openat", "path_contains": "/etc/sudoers.d/", "exe_not_endswith_any": ["/visudo", "/dpkg", "/rpm"]},
+ fp=[FP_AUTOMATION], playbook="tpl-privilege-escalation"),
+ S(slug="linux-nopasswd-sudo-line", name="Sudoers File Granted NOPASSWD Privilege",
+ severity="high", mitre=["t1548.003"], product="linux", service="auditd",
+ when={"syscall": "openat", "path_contains_any": ["/etc/sudoers", "/etc/sudoers.d/"], "file_content_contains": "NOPASSWD"},
+ fp=[FP_AUTOMATION], playbook="tpl-privilege-escalation"),
+ S(slug="linux-authorized-keys-bulk-append", name="Multiple Authorized Keys Appended In Short Window",
+ severity="high", mitre=["t1098.004"], product="linux", service="auditd",
+ when={"syscall": "openat", "path_endswith": "/.ssh/authorized_keys", "append_count_5min_gt": 3},
+ fp=["Bulk team onboarding via Ansible"], playbook="tpl-persistence"),
+ S(slug="linux-ssh-config-permitrootlogin-yes", name="sshd_config PermitRootLogin Set To Yes",
+ severity="high", mitre=["t1556.004"], product="linux", service="auditd",
+ when={"syscall": "openat", "path": "/etc/ssh/sshd_config", "value_contains": "PermitRootLogin yes"},
+ fp=[FP_BREAK_GLASS], playbook="tpl-credential-access"),
+
+ # ---- Defense evasion / log tampering (10) ----
+ S(slug="linux-auditd-stopped", name="auditd Service Stopped",
+ severity="high", mitre=["t1562.012"], product="linux", service="syslog",
+ when={"unit": "auditd", "active_state": "inactive"},
+ fp=[FP_PATCH], playbook="tpl-defense-evasion"),
+ S(slug="linux-auditctl-disable", name="auditctl Used To Disable Audit Rules",
+ severity="high", mitre=["t1562.012"], product="linux", service="auditd",
+ when={"syscall": "execve", "exe_endswith": "/auditctl", "argv_contains_any": ["-D", "-e 0"]},
+ fp=[FP_TUNING, FP_FORENSIC], playbook="tpl-defense-evasion"),
+ S(slug="linux-syslog-config-removed", name="rsyslog Configuration File Removed",
+ severity="high", mitre=["t1562.001"], product="linux", service="auditd",
+ when={"syscall": "unlinkat", "path_contains_any": ["/etc/rsyslog.d/", "/etc/rsyslog.conf"]},
+ fp=[FP_PATCH], playbook="tpl-defense-evasion"),
+ S(slug="linux-utmp-tampering", name="/var/log/wtmp Or /var/log/btmp Modified Suspiciously",
+ severity="high", mitre=["t1070.002"], product="linux", service="auditd",
+ when={"syscall": "openat", "path_contains_any": ["/var/log/wtmp", "/var/log/btmp"], "exe_not_endswith_any": ["/login", "/sshd", "/init"]},
+ fp=[FP_FORENSIC], playbook="tpl-defense-evasion"),
+ S(slug="linux-history-cleared", name="Bash History File Truncated Or Removed",
+ severity="medium", mitre=["t1070.003"], product="linux", service="auditd",
+ when={"syscall": "openat", "path_endswith": "/.bash_history", "flags_contains": "O_TRUNC"},
+ fp=[FP_FORENSIC, "User cleared their own history (educate)"], playbook="tpl-defense-evasion"),
+ S(slug="linux-history-disabled-export", name="HISTFILE Set To /dev/null",
+ severity="medium", mitre=["t1070.003"], product="linux", service="auditd",
+ when={"syscall": "execve", "argv_contains_any": ["histfile=/dev/null", "set +o history"]},
+ fp=[FP_FORENSIC], playbook="tpl-defense-evasion"),
+ S(slug="linux-selinux-permissive", name="SELinux Set To Permissive",
+ severity="high", mitre=["t1562.001"], product="linux", service="auditd",
+ when={"syscall": "execve", "exe_endswith": "/setenforce", "argv_contains_any": ["0", "permissive"]},
+ fp=[FP_BREAK_GLASS], playbook="tpl-defense-evasion"),
+ S(slug="linux-apparmor-disabled", name="AppArmor Profile Disabled",
+ severity="high", mitre=["t1562.001"], product="linux", service="auditd",
+ when={"syscall": "execve", "exe_endswith_any": ["/aa-disable", "/apparmor_parser"], "argv_contains": "-R"},
+ fp=[FP_TUNING], playbook="tpl-defense-evasion"),
+ S(slug="linux-iptables-flush", name="iptables -F Used To Flush Rules",
+ severity="high", mitre=["t1562.004"], product="linux", service="auditd",
+ when={"syscall": "execve", "exe_endswith": "/iptables", "argv_contains_any": ["-F", "--flush"]},
+ fp=[FP_TUNING], playbook="tpl-defense-evasion"),
+ S(slug="linux-ufw-disable", name="ufw Firewall Disabled",
+ severity="medium", mitre=["t1562.004"], product="linux", service="auditd",
+ when={"syscall": "execve", "exe_endswith": "/ufw", "argv_contains": "disable"},
+ fp=[FP_TUNING], playbook="tpl-defense-evasion"),
+
+ # ---- Discovery / privilege (8) ----
+ S(slug="linux-shadow-read", name="/etc/shadow Read By Non-Root Process",
+ severity="high", mitre=["t1003.008"], product="linux", service="auditd",
+ when={"syscall": "openat", "path": "/etc/shadow", "actor_uid_neq": 0},
+ fp=["Approved security scanner running with sudo"], playbook="tpl-credential-access"),
+ S(slug="linux-passwd-modified", name="/etc/passwd Modified By Non-Pkg Process",
+ severity="high", mitre=["t1136.001"], product="linux", service="auditd",
+ when={"syscall": "openat", "path": "/etc/passwd", "exe_not_endswith_any": ["/useradd", "/usermod", "/groupadd", "/userdel"]},
+ fp=[FP_AUTOMATION], playbook="tpl-persistence"),
+ S(slug="linux-suid-binary-create", name="SUID Bit Set On Newly Created Binary",
+ severity="high", mitre=["t1548.001"], product="linux", service="auditd",
+ when={"syscall": "fchmod", "mode_octal_contains": "4", "path_not_startswith_any": ["/usr/bin", "/usr/sbin", "/bin", "/sbin"]},
+ fp=["Approved deploy of internal tool"], playbook="tpl-privilege-escalation"),
+ S(slug="linux-guid-binary-create", name="SGID Bit Set On Newly Created Binary",
+ severity="medium", mitre=["t1548.001"], product="linux", service="auditd",
+ when={"syscall": "fchmod", "mode_octal_contains": "2", "path_not_startswith_any": ["/usr/bin", "/usr/sbin", "/bin", "/sbin"]},
+ fp=["Approved deploy"], playbook="tpl-privilege-escalation"),
+ S(slug="linux-cap-setuid-binary", name="setuid Capability Granted To New Binary",
+ severity="high", mitre=["t1548.001"], product="linux", service="auditd",
+ when={"syscall": "execve", "exe_endswith": "/setcap", "argv_contains": "cap_setuid"},
+ fp=[FP_AUTOMATION], playbook="tpl-privilege-escalation"),
+ S(slug="linux-mass-userlist-read", name="/etc/passwd Read By Many Processes In Short Window",
+ severity="low", mitre=["t1087.001"], product="linux", service="auditd",
+ when={"syscall": "openat", "path": "/etc/passwd", "distinct_pid_5min_gt": 50},
+ fp=["Container fleet startup (allow-listed)"], playbook="tpl-discovery"),
+ S(slug="linux-netcat-listen", name="netcat Listening Mode Detected",
+ severity="medium", mitre=["t1059.004"], product="linux", service="auditd",
+ when={"syscall": "execve", "exe_endswith_any": ["/nc", "/ncat", "/netcat"], "argv_contains_any": ["-l", "-lvp", "--listen"]},
+ fp=["Lab / test exercise"], playbook="tpl-command-and-control"),
+ S(slug="linux-curl-piped-bash", name="curl/wget Piped Directly To Shell",
+ severity="medium", mitre=["t1059.004"], product="linux", service="auditd",
+ when={"syscall": "execve", "argv_contains_any": ["curl | bash", "curl | sh", "wget -O- | bash", "wget -qO- | sh"]},
+ fp=["Vendor install script (allow-listed)"], playbook="tpl-execution"),
+
+ # ---- Container escape & kernel (10) ----
+ S(slug="linux-docker-socket-read-non-root", name="Docker Socket Accessed By Non-Root User",
+ severity="high", mitre=["t1611"], product="linux", service="auditd",
+ when={"syscall": "connect", "path": "/var/run/docker.sock", "actor_uid_neq": 0},
+ fp=["docker group user (deprecated, must be ticketed)"], playbook="tpl-privilege-escalation"),
+ S(slug="linux-docker-socket-mounted-into-container", name="Docker Socket Mounted Into Container",
+ severity="critical", mitre=["t1611"], product="linux", service="docker",
+ when={"event_type": "container_create", "host_path": "/var/run/docker.sock"},
+ fp=["Authorised CI runner pattern"], playbook="tpl-privilege-escalation"),
+ S(slug="linux-host-pid-namespace", name="Container Started With --pid=host",
+ severity="high", mitre=["t1611"], product="linux", service="docker",
+ when={"event_type": "container_create", "pid_mode": "host"},
+ fp=["Performance-monitoring agent (allow-listed)"], playbook="tpl-privilege-escalation"),
+ S(slug="linux-host-network-namespace", name="Container Started With --network=host",
+ severity="medium", mitre=["t1611"], product="linux", service="docker",
+ when={"event_type": "container_create", "network_mode": "host"},
+ fp=["Approved CNI sidecar"], playbook="tpl-privilege-escalation"),
+ S(slug="linux-cap-sys-admin-add", name="Container Granted CAP_SYS_ADMIN",
+ severity="high", mitre=["t1611"], product="linux", service="docker",
+ when={"event_type": "container_create", "added_caps_has_any": ["CAP_SYS_ADMIN", "ALL"]},
+ fp=["Documented container with documented exception"], playbook="tpl-privilege-escalation"),
+ S(slug="linux-mount-procfs-rw", name="/proc Re-Mounted With Read-Write",
+ severity="high", mitre=["t1611"], product="linux", service="auditd",
+ when={"syscall": "mount", "target_startswith": "/proc", "options_contains": "rw"},
+ fp=["Container debugging procedure"], playbook="tpl-privilege-escalation"),
+ S(slug="linux-kernel-module-load-insmod", name="Kernel Module Loaded With insmod",
+ severity="high", mitre=["t1547.006"], product="linux", service="auditd",
+ when={"syscall": "execve", "exe_endswith": "/insmod"},
+ fp=[FP_PATCH], playbook="tpl-persistence"),
+ S(slug="linux-ebpf-prog-load-non-root", name="eBPF Program Loaded By Non-Root",
+ severity="high", mitre=["t1547"], product="linux", service="auditd",
+ when={"syscall": "bpf", "cmd": "BPF_PROG_LOAD", "actor_uid_neq": 0},
+ fp=["Sanctioned observability agent"], playbook="tpl-defense-evasion"),
+ S(slug="linux-ptrace-pid1", name="ptrace Attached To PID 1",
+ severity="high", mitre=["t1611"], product="linux", service="auditd",
+ when={"syscall": "ptrace", "target_pid": 1},
+ fp=[FP_FORENSIC], playbook="tpl-privilege-escalation"),
+ S(slug="linux-memfd-create-then-execve", name="memfd_create Then Executed Anonymous Memory Region",
+ severity="high", mitre=["t1620"], product="linux", service="auditd",
+ when={"syscall": "execveat", "fd_path_startswith": "/memfd:"},
+ fp=["Sanctioned packer / runtime that uses memfd"], playbook="tpl-defense-evasion"),
+
+ # ---- Exfil / staging / impact (10) ----
+ S(slug="linux-tar-pipe-curl", name="tar Output Piped To curl Upload",
+ severity="high", mitre=["t1041"], product="linux", service="auditd",
+ when={"syscall": "execve", "argv_contains_all": ["tar", "curl"]},
+ fp=["Sanctioned backup script (allow-listed)"], playbook="tpl-exfiltration"),
+ S(slug="linux-rclone-process", name="rclone Binary Run On Non-Backup Host",
+ severity="medium", mitre=["t1041"], product="linux", service="auditd",
+ when={"syscall": "execve", "exe_endswith": "/rclone"},
+ fp=[FP_BACKUP], playbook="tpl-exfiltration"),
+ S(slug="linux-large-stage-tmp", name="Large Archive Created In /tmp",
+ severity="medium", mitre=["t1074.001"], product="linux", service="auditd",
+ when={"syscall": "openat", "path_startswith": "/tmp/", "path_endswith_any": [".tar", ".tar.gz", ".zip", ".7z"], "size_bytes_gt": 524288000},
+ fp=["Sanctioned local backup"], playbook="tpl-collection"),
+ S(slug="linux-base64-decode-then-execve", name="base64 Decoded Then Executed In Shell",
+ severity="medium", mitre=["t1027"], product="linux", service="auditd",
+ when={"syscall": "execve", "argv_contains_any": ["base64 -d | bash", "base64 -d | sh", "echo | base64 -d | sh"]},
+ fp=[FP_PENTEST], playbook="tpl-execution"),
+ S(slug="linux-cryptominer-process", name="Likely Cryptominer Process Detected",
+ severity="critical", mitre=["t1496"], product="linux", service="auditd",
+ when={"syscall": "execve", "exe_endswith_any": ["/xmrig", "/minerd", "/cpuminer"]},
+ fp=[FP_PENTEST, "Authorized stress-test"], playbook="tpl-impact"),
+ S(slug="linux-shred-on-prod-data", name="shred Used Against Production Data Path",
+ severity="high", mitre=["t1485"], product="linux", service="auditd",
+ when={"syscall": "execve", "exe_endswith": "/shred", "argv_contains_any": ["/var/lib", "/data", "/srv"]},
+ fp=["Decommission workflow"], playbook="tpl-impact"),
+ S(slug="linux-wipe-disk-dd", name="dd Writing /dev/zero To Block Device",
+ severity="critical", mitre=["t1561.002"], product="linux", service="auditd",
+ when={"syscall": "execve", "exe_endswith": "/dd", "argv_contains_all": ["if=/dev/zero", "of=/dev/"]},
+ fp=["Authorised disk wipe"], playbook="tpl-impact"),
+ S(slug="linux-systemctl-mass-stop", name="Multiple Critical Services Stopped In Quick Burst",
+ severity="high", mitre=["t1489"], product="linux", service="auditd",
+ when={"syscall": "execve", "exe_endswith": "/systemctl", "argv_contains_any": ["stop", "disable"], "stops_5min_gt": 5},
+ fp=[FP_PATCH], playbook="tpl-impact"),
+ S(slug="linux-mass-rename-suspicious-ext", name="Mass File Rename To Ransom Marker Extension",
+ severity="critical", mitre=["t1486"], product="linux", service="auditd",
+ when={"syscall": "renameat2", "new_name_endswith_any": [".locked", ".enc", ".ryuk", ".lockbit"], "rename_count_60s_gt": 50},
+ fp=[FP_PENTEST], playbook="tpl-impact"),
+ S(slug="linux-fileless-via-procfd", name="Process Executed From /proc/self/fd Anonymous Inode",
+ severity="high", mitre=["t1620"], product="linux", service="auditd",
+ when={"syscall": "execveat", "fd_path_startswith": "/proc/self/fd/"},
+ fp=["Sanctioned interpreter pattern"], playbook="tpl-defense-evasion"),
+
+ # ---- Ingress / loaders (7) ----
+ S(slug="linux-wget-suspicious-tld", name="wget Pulling From Newly Registered TLD",
+ severity="medium", mitre=["t1105"], product="linux", service="auditd",
+ when={"syscall": "execve", "exe_endswith_any": ["/wget", "/curl"], "argv_contains_any": [".xyz", ".top", ".click", ".support"]},
+ fp=[FP_PATCH], playbook="tpl-command-and-control"),
+ S(slug="linux-chmod-plus-x-tmp", name="chmod +x Applied To File In /tmp",
+ severity="medium", mitre=["t1222.002"], product="linux", service="auditd",
+ when={"syscall": "execve", "exe_endswith": "/chmod", "argv_contains_all": ["+x", "/tmp/"]},
+ fp=["Test/CI ephemeral helpers"], playbook="tpl-execution"),
+ S(slug="linux-execve-from-dev-shm", name="execve From /dev/shm",
+ severity="high", mitre=["t1059.004"], product="linux", service="auditd",
+ when={"syscall": "execve", "exe_startswith": "/dev/shm/"},
+ fp=["Sanctioned cluster init"], playbook="tpl-execution"),
+ S(slug="linux-systemd-portable-attach", name="systemd-portable Image Attached",
+ severity="medium", mitre=["t1543.002"], product="linux", service="auditd",
+ when={"syscall": "execve", "exe_endswith": "/portablectl", "argv_contains": "attach"},
+ fp=["Authorised platform engineering"], playbook="tpl-persistence"),
+ S(slug="linux-modprobe-suspicious", name="modprobe Loaded Module From /tmp",
+ severity="high", mitre=["t1547.006"], product="linux", service="auditd",
+ when={"syscall": "execve", "exe_endswith": "/modprobe", "argv_contains_any": ["/tmp/", "/dev/shm/"]},
+ fp=["Diagnostic kernel debug"], playbook="tpl-persistence"),
+ S(slug="linux-ld-preload-set-tmp", name="LD_PRELOAD Pointing To /tmp",
+ severity="high", mitre=["t1574.006"], product="linux", service="auditd",
+ when={"syscall": "execve", "env_ld_preload_startswith": "/tmp/"},
+ fp=[FP_AUTOMATION], playbook="tpl-defense-evasion"),
+ S(slug="linux-yum-add-untrusted-repo", name="yum/dnf Added Repo From Untrusted Domain",
+ severity="medium", mitre=["t1195.002"], product="linux", service="auditd",
+ when={"syscall": "openat", "path_startswith": "/etc/yum.repos.d/", "value_contains": "baseurl=http://"},
+ fp=[FP_AUTOMATION, FP_PATCH], playbook="tpl-supply-chain"),
+]
+
+
+# ---------------------------------------------------------------------------
+# macOS (40 rules)
+# ---------------------------------------------------------------------------
+MACOS_RULES: list[dict] = [
+ # ---- Persistence (12) ----
+ S(slug="macos-launchdaemon-write-system", name="LaunchDaemon Plist Written To /Library/LaunchDaemons",
+ severity="high", mitre=["t1543.001"], product="macos", service="endpointsecurity",
+ when={"event_type": "ES_EVENT_TYPE_NOTIFY_WRITE", "path_contains": "/Library/LaunchDaemons/", "creator_signing_id_not_in": ["com.apple.installer", "com.apple.softwareupdated"]},
+ fp=["Vendor pkg install (allow-listed)"], playbook="tpl-persistence"),
+ S(slug="macos-launchagent-write-user", name="User LaunchAgent Plist Created",
+ severity="medium", mitre=["t1543.004"], product="macos", service="endpointsecurity",
+ when={"event_type": "ES_EVENT_TYPE_NOTIFY_WRITE", "path_contains_any": ["/Users/", "/Library/LaunchAgents/"], "path_endswith": ".plist"},
+ fp=["IDE / sync utility installer"], playbook="tpl-persistence"),
+ S(slug="macos-loginitem-add", name="Login Item Added Via osascript",
+ severity="medium", mitre=["t1547.015"], product="macos", service="endpointsecurity",
+ when={"event_type": "exec", "process_path_endswith": "/osascript", "argv_contains": "login items"},
+ fp=["IT helpdesk onboarding script"], playbook="tpl-persistence"),
+ S(slug="macos-plistbuddy-from-non-system", name="PlistBuddy Used By Non-System Process",
+ severity="medium", mitre=["t1547"], product="macos", service="endpointsecurity",
+ when={"event_type": "exec", "process_path_endswith": "/PlistBuddy", "responsible_signing_id_not_startswith": "com.apple."},
+ fp=["Approved homebrew formula"], playbook="tpl-persistence"),
+ S(slug="macos-emond-installed", name="Apple emond Rule Installed",
+ severity="high", mitre=["t1546.014"], product="macos", service="endpointsecurity",
+ when={"event_type": "ES_EVENT_TYPE_NOTIFY_WRITE", "path_contains": "/etc/emond.d/rules/"},
+ fp=[FP_PATCH], playbook="tpl-persistence"),
+ S(slug="macos-periodic-script-modified", name="/private/etc/periodic Script Modified",
+ severity="medium", mitre=["t1037"], product="macos", service="endpointsecurity",
+ when={"event_type": "ES_EVENT_TYPE_NOTIFY_WRITE", "path_contains": "/private/etc/periodic/"},
+ fp=[FP_PATCH], playbook="tpl-persistence"),
+ S(slug="macos-cron-tab-create", name="User crontab Created (Rare On macOS)",
+ severity="medium", mitre=["t1053.003"], product="macos", service="endpointsecurity",
+ when={"event_type": "exec", "process_path_endswith": "/crontab", "argv_contains": "-l"},
+ fp=["Migration from Linux"], playbook="tpl-persistence"),
+ S(slug="macos-ssh-authorized-keys-append", name="~/.ssh/authorized_keys Modified",
+ severity="medium", mitre=["t1098.004"], product="macos", service="endpointsecurity",
+ when={"event_type": "ES_EVENT_TYPE_NOTIFY_WRITE", "path_endswith": "/.ssh/authorized_keys"},
+ fp=[FP_AUTOMATION], playbook="tpl-persistence"),
+ S(slug="macos-mdm-enrollment-removed", name="MDM Enrollment Profile Removed",
+ severity="high", mitre=["t1562.001"], product="macos", service="endpointsecurity",
+ when={"event_type": "exec", "process_path_endswith": "/profiles", "argv_contains": "remove"},
+ fp=["Approved decommission of asset"], playbook="tpl-defense-evasion"),
+ S(slug="macos-config-profile-installed", name="Configuration Profile Installed",
+ severity="medium", mitre=["t1078.003"], product="macos", service="endpointsecurity",
+ when={"event_type": "exec", "process_path_endswith": "/profiles", "argv_contains": "install"},
+ fp=["MDM rollout"], playbook="tpl-persistence"),
+ S(slug="macos-com-apple-loginitems-modified", name="com.apple.loginitems Modified",
+ severity="medium", mitre=["t1547.015"], product="macos", service="endpointsecurity",
+ when={"event_type": "ES_EVENT_TYPE_NOTIFY_WRITE", "path_endswith": "com.apple.backgroundtaskmanagement.plist"},
+ fp=["Apple OS update"], playbook="tpl-persistence"),
+ S(slug="macos-app-bundle-shared", name="Custom .app Bundle Written To /Users/Shared",
+ severity="medium", mitre=["t1574.002"], product="macos", service="endpointsecurity",
+ when={"event_type": "ES_EVENT_TYPE_NOTIFY_WRITE", "path_startswith": "/Users/Shared/", "path_endswith": ".app/Contents/MacOS/main"},
+ fp=["Multi-user enterprise app"], playbook="tpl-persistence"),
+
+ # ---- Defense evasion (10) ----
+ S(slug="macos-spctl-master-disable", name="spctl --master-disable (Gatekeeper Off)",
+ severity="high", mitre=["t1553.001"], product="macos", service="endpointsecurity",
+ when={"event_type": "exec", "process_path_endswith": "/spctl", "argv_contains": "--master-disable"},
+ fp=["Engineer running unsigned dev build (educate)"], playbook="tpl-defense-evasion"),
+ S(slug="macos-csrutil-disable", name="csrutil disable (SIP Off)",
+ severity="critical", mitre=["t1553"], product="macos", service="endpointsecurity",
+ when={"event_type": "exec", "process_path_endswith": "/csrutil", "argv_contains": "disable"},
+ fp=["Approved kernel-driver development workstation"], playbook="tpl-defense-evasion"),
+ S(slug="macos-nvram-boot-args", name="nvram boot-args Modified",
+ severity="critical", mitre=["t1542.001"], product="macos", service="endpointsecurity",
+ when={"event_type": "exec", "process_path_endswith": "/nvram", "argv_contains": "boot-args="},
+ fp=["Kernel driver development"], playbook="tpl-defense-evasion"),
+ S(slug="macos-quarantine-attribute-removed", name="com.apple.quarantine xattr Stripped",
+ severity="medium", mitre=["t1553.001"], product="macos", service="endpointsecurity",
+ when={"event_type": "exec", "process_path_endswith": "/xattr", "argv_contains_all": ["-d", "com.apple.quarantine"]},
+ fp=["Sanctioned dev workflow"], playbook="tpl-defense-evasion"),
+ S(slug="macos-tcc-db-direct-write", name="TCC Database Modified Outside tccd",
+ severity="high", mitre=["t1562.001"], product="macos", service="endpointsecurity",
+ when={"event_type": "ES_EVENT_TYPE_NOTIFY_WRITE", "path_endswith": "/Library/Application Support/com.apple.TCC/TCC.db"},
+ fp=["Apple OS update"], playbook="tpl-defense-evasion"),
+ S(slug="macos-kextload-unsigned", name="kextload Of Unsigned Kernel Extension",
+ severity="critical", mitre=["t1547.006"], product="macos", service="endpointsecurity",
+ when={"event_type": "exec", "process_path_endswith": "/kextload", "kext_signed": False},
+ fp=["Approved hardware vendor (allow-listed)"], playbook="tpl-persistence"),
+ S(slug="macos-xprotect-disabled", name="XProtect Updates Disabled",
+ severity="high", mitre=["t1562.001"], product="macos", service="endpointsecurity",
+ when={"event_type": "exec", "process_path_endswith": "/defaults", "argv_contains_all": ["com.apple.MRT", "DisableMRTShim"]},
+ fp=[FP_PENTEST], playbook="tpl-defense-evasion"),
+ S(slug="macos-firewall-disabled", name="Application Firewall Disabled",
+ severity="medium", mitre=["t1562.004"], product="macos", service="endpointsecurity",
+ when={"event_type": "exec", "process_path_endswith": "/socketfilterfw", "argv_contains_any": ["--setglobalstate off", "--setblockall off"]},
+ fp=[FP_TUNING], playbook="tpl-defense-evasion"),
+ S(slug="macos-mas-receipt-tamper", name="App Store Receipt File Tampered",
+ severity="medium", mitre=["t1562"], product="macos", service="endpointsecurity",
+ when={"event_type": "ES_EVENT_TYPE_NOTIFY_WRITE", "path_endswith": "_MASReceipt/receipt"},
+ fp=["MAS app reinstall"], playbook="tpl-defense-evasion"),
+ S(slug="macos-codesign-force-bypass", name="codesign --force --deep Used By User",
+ severity="medium", mitre=["t1553.002"], product="macos", service="endpointsecurity",
+ when={"event_type": "exec", "process_path_endswith": "/codesign", "argv_contains_all": ["--force", "--deep"]},
+ fp=["Engineer signing personal build"], playbook="tpl-defense-evasion"),
+
+ # ---- Credential / data access (8) ----
+ S(slug="macos-security-export-keychain", name="security export Used Against Login Keychain",
+ severity="high", mitre=["t1555.001"], product="macos", service="endpointsecurity",
+ when={"event_type": "exec", "process_path_endswith": "/security", "argv_contains": "export"},
+ fp=[FP_FORENSIC], playbook="tpl-credential-access"),
+ S(slug="macos-security-find-generic-password", name="security find-generic-password Used",
+ severity="medium", mitre=["t1555.001"], product="macos", service="endpointsecurity",
+ when={"event_type": "exec", "process_path_endswith": "/security", "argv_contains": "find-generic-password"},
+ fp=["Sanctioned helper tool"], playbook="tpl-credential-access"),
+ S(slug="macos-keychain-db-read-by-other-uid", name="login.keychain-db Read By Non-Owner UID",
+ severity="high", mitre=["t1555.001"], product="macos", service="endpointsecurity",
+ when={"event_type": "ES_EVENT_TYPE_NOTIFY_OPEN", "path_endswith": "/Keychains/login.keychain-db", "actor_uid_neq_owner_uid": True},
+ fp=[FP_FORENSIC], playbook="tpl-credential-access"),
+ S(slug="macos-screencapture-binary", name="screencapture Binary Used",
+ severity="low", mitre=["t1113"], product="macos", service="endpointsecurity",
+ when={"event_type": "exec", "process_path_endswith": "/screencapture"},
+ fp=["User-driven screenshot (very common)"], playbook="tpl-collection"),
+ S(slug="macos-osascript-keychain-access", name="osascript Used To Read Keychain",
+ severity="high", mitre=["t1555.001"], product="macos", service="endpointsecurity",
+ when={"event_type": "exec", "process_path_endswith": "/osascript", "argv_contains_any": ["security 2>&1", "find-generic-password"]},
+ fp=[FP_AUTOMATION], playbook="tpl-credential-access"),
+ S(slug="macos-defaults-com-apple-loginwindow", name="defaults Wrote To com.apple.loginwindow",
+ severity="medium", mitre=["t1547.005"], product="macos", service="endpointsecurity",
+ when={"event_type": "exec", "process_path_endswith": "/defaults", "argv_contains_all": ["write", "com.apple.loginwindow"]},
+ fp=["MDM rollout"], playbook="tpl-persistence"),
+ S(slug="macos-icloud-keychain-toggle", name="iCloud Keychain Sync Toggled Off",
+ severity="medium", mitre=["t1562"], product="macos", service="endpointsecurity",
+ when={"event_type": "exec", "process_path_endswith": "/defaults", "argv_contains_all": ["com.apple.security", "AccountSettings", "Keychain"]},
+ fp=["Privacy compliance preference"], playbook="tpl-defense-evasion"),
+ S(slug="macos-systemextension-load-non-apple", name="SystemExtension Loaded From Non-Apple Bundle",
+ severity="high", mitre=["t1547.006"], product="macos", service="endpointsecurity",
+ when={"event_type": "exec", "process_path_endswith": "/systemextensionsctl", "argv_contains": "install"},
+ fp=["Approved security vendor agent"], playbook="tpl-persistence"),
+
+ # ---- Execution / loaders (10) ----
+ S(slug="macos-osascript-do-shell-script", name="osascript do shell script with administrator privileges",
+ severity="high", mitre=["t1059.002", "t1548.004"], product="macos", service="endpointsecurity",
+ when={"event_type": "exec", "process_path_endswith": "/osascript", "argv_contains": "do shell script"},
+ fp=[FP_AUTOMATION], playbook="tpl-execution"),
+ S(slug="macos-launchctl-load-from-tmp", name="launchctl Loading Plist From /tmp",
+ severity="high", mitre=["t1543.001"], product="macos", service="endpointsecurity",
+ when={"event_type": "exec", "process_path_endswith": "/launchctl", "argv_contains_any": ["/tmp/", "/private/tmp/"]},
+ fp=["Test workflow on dev machine"], playbook="tpl-persistence"),
+ S(slug="macos-curl-pipe-shell", name="curl Output Piped To Shell",
+ severity="medium", mitre=["t1105"], product="macos", service="endpointsecurity",
+ when={"event_type": "exec", "process_path_endswith": "/sh", "argv_contains_any": ["curl | sh", "curl | bash"]},
+ fp=["Sanctioned install scripts"], playbook="tpl-execution"),
+ S(slug="macos-dyld-insert-libraries", name="DYLD_INSERT_LIBRARIES Set To /tmp Or User Path",
+ severity="high", mitre=["t1574.006"], product="macos", service="endpointsecurity",
+ when={"event_type": "exec", "env_dyld_insert_libraries_startswith_any": ["/tmp/", "/Users/"]},
+ fp=["Sanctioned dev workflow"], playbook="tpl-defense-evasion"),
+ S(slug="macos-dock-modified", name="com.apple.dock Modified By Non-System Process",
+ severity="low", mitre=["t1547.005"], product="macos", service="endpointsecurity",
+ when={"event_type": "ES_EVENT_TYPE_NOTIFY_WRITE", "path_endswith": "/Preferences/com.apple.dock.plist"},
+ fp=["MDM workflow"], playbook="tpl-persistence"),
+ S(slug="macos-systemsetup-remote-login", name="systemsetup Enabled Remote Login (SSH)",
+ severity="medium", mitre=["t1021.004"], product="macos", service="endpointsecurity",
+ when={"event_type": "exec", "process_path_endswith": "/systemsetup", "argv_contains_all": ["-setremotelogin", "on"]},
+ fp=["IT remote support"], playbook="tpl-lateral-movement"),
+ S(slug="macos-hyperkit-launch-untrusted", name="hyperkit Launched From Non-Standard Path",
+ severity="medium", mitre=["t1610"], product="macos", service="endpointsecurity",
+ when={"event_type": "exec", "process_path_contains": "/hyperkit", "process_path_not_startswith_any": ["/Applications/", "/usr/local/bin/"]},
+ fp=["Custom virtualisation tooling"], playbook="tpl-execution"),
+ S(slug="macos-binary-from-shared", name="Mach-O Binary Executed From /Users/Shared",
+ severity="medium", mitre=["t1059.004"], product="macos", service="endpointsecurity",
+ when={"event_type": "exec", "process_path_startswith": "/Users/Shared/"},
+ fp=["Multi-user enterprise tool"], playbook="tpl-execution"),
+ S(slug="macos-tccutil-reset-all", name="tccutil reset All Subsystems",
+ severity="medium", mitre=["t1562.001"], product="macos", service="endpointsecurity",
+ when={"event_type": "exec", "process_path_endswith": "/tccutil", "argv_contains_all": ["reset", "All"]},
+ fp=["Privacy reset workflow"], playbook="tpl-defense-evasion"),
+ S(slug="macos-find-iphone-disabled", name="Find My Mac Disabled",
+ severity="medium", mitre=["t1562"], product="macos", service="endpointsecurity",
+ when={"event_type": "exec", "process_path_endswith": "/defaults", "argv_contains_all": ["com.apple.icloud", "FindMyMacEnabled", "0"]},
+ fp=["Asset offboarding"], playbook="tpl-defense-evasion"),
+]
+
+
+# ---------------------------------------------------------------------------
+# Container / Kubernetes host (25 rules)
+# ---------------------------------------------------------------------------
+CONTAINER_RULES: list[dict] = [
+ S(slug="container-docker-tcp-listening", name="Docker Daemon Listening On TCP Socket",
+ severity="critical", mitre=["t1610"], product="docker", service="dockerd",
+ when={"event_type": "daemon_listening", "address_contains": "tcp://0.0.0.0"},
+ fp=["Approved CI runner pattern (must require mTLS)"], playbook="tpl-privilege-escalation"),
+ S(slug="container-image-from-public-registry", name="Production Container Pulled From Public Registry",
+ severity="medium", mitre=["t1525"], product="docker", service="dockerd",
+ when={"event_type": "image_pull", "image_registry_in": ["docker.io", "ghcr.io"], "environment": "prod"},
+ fp=[FP_AUTOMATION], playbook="tpl-supply-chain"),
+ S(slug="container-image-tag-latest-prod", name="Container Pulled With :latest Tag In Production",
+ severity="medium", mitre=["t1525"], product="docker", service="dockerd",
+ when={"event_type": "image_pull", "image_tag": "latest", "environment": "prod"},
+ fp=[FP_AUTOMATION], playbook="tpl-supply-chain"),
+ S(slug="container-running-as-root-prod", name="Container Started As UID 0 In Production",
+ severity="medium", mitre=["t1611"], product="docker", service="dockerd",
+ when={"event_type": "container_start", "user_uid": 0, "environment": "prod"},
+ fp=["Approved root-required workload (allow-listed)"], playbook="tpl-privilege-escalation"),
+ S(slug="container-hostpath-mount-root", name="Container Mounted Host Root Filesystem",
+ severity="critical", mitre=["t1611"], product="docker", service="dockerd",
+ when={"event_type": "container_create", "host_mount_path": "/"},
+ fp=["Sanctioned node-agent (allow-listed)"], playbook="tpl-privilege-escalation"),
+ S(slug="container-mount-etc", name="Container Mounted /etc From Host",
+ severity="high", mitre=["t1611"], product="docker", service="dockerd",
+ when={"event_type": "container_create", "host_mount_path_contains": "/etc"},
+ fp=["Configuration injection pattern"], playbook="tpl-privilege-escalation"),
+ S(slug="container-readonly-fs-disabled", name="Container Created With ReadOnlyRootFilesystem False",
+ severity="low", mitre=["t1611"], product="docker", service="dockerd",
+ when={"event_type": "container_create", "readonly_root_fs": False, "environment": "prod"},
+ fp=["Workload requires writable rootfs (allow-listed)"], playbook="tpl-defense-evasion"),
+ S(slug="container-build-on-host", name="docker build Run On Production Host",
+ severity="medium", mitre=["t1612"], product="docker", service="dockerd",
+ when={"event_type": "image_build", "host_role": "production"},
+ fp=["Documented bake host"], playbook="tpl-execution"),
+ S(slug="container-dind-detected", name="Docker-In-Docker Pattern Detected",
+ severity="medium", mitre=["t1611"], product="docker", service="dockerd",
+ when={"event_type": "container_create", "image_name_contains": "docker:dind"},
+ fp=["Sanctioned CI runner"], playbook="tpl-privilege-escalation"),
+ S(slug="k8s-pod-hostnetwork-true", name="Pod Created With hostNetwork: true",
+ severity="high", mitre=["t1611"], product="kubernetes", service="audit",
+ when={"event_type": "create_pod", "host_network": True},
+ fp=["Sanctioned CNI plugin"], playbook="tpl-privilege-escalation"),
+ S(slug="k8s-pod-hostpid-true", name="Pod Created With hostPID: true",
+ severity="high", mitre=["t1611"], product="kubernetes", service="audit",
+ when={"event_type": "create_pod", "host_pid": True},
+ fp=["Sanctioned monitoring agent"], playbook="tpl-privilege-escalation"),
+ S(slug="k8s-pod-hostipc-true", name="Pod Created With hostIPC: true",
+ severity="medium", mitre=["t1611"], product="kubernetes", service="audit",
+ when={"event_type": "create_pod", "host_ipc": True},
+ fp=["Specialised workload"], playbook="tpl-privilege-escalation"),
+ S(slug="k8s-pod-privileged", name="Pod Created With privileged Security Context",
+ severity="critical", mitre=["t1611"], product="kubernetes", service="audit",
+ when={"event_type": "create_pod", "container_privileged": True},
+ fp=["Documented system DaemonSet"], playbook="tpl-privilege-escalation"),
+ S(slug="k8s-pod-allow-priv-esc", name="Pod Allows Privilege Escalation",
+ severity="medium", mitre=["t1611"], product="kubernetes", service="audit",
+ when={"event_type": "create_pod", "allow_privilege_escalation": True, "environment": "prod"},
+ fp=["Workload that needs setuid binaries (rare)"], playbook="tpl-privilege-escalation"),
+ S(slug="k8s-rolebinding-cluster-admin", name="RoleBinding Created Bound To cluster-admin ClusterRole",
+ severity="critical", mitre=["t1098.003"], product="kubernetes", service="audit",
+ when={"event_type": "create_rolebinding", "role_ref_name": "cluster-admin"},
+ fp=["Initial cluster bootstrap"], playbook="tpl-privilege-escalation"),
+ S(slug="k8s-clusterrolebinding-system-masters", name="ClusterRoleBinding To system:masters",
+ severity="critical", mitre=["t1098.003"], product="kubernetes", service="audit",
+ when={"event_type": "create_clusterrolebinding", "subject_group": "system:masters"},
+ fp=["Initial cluster bootstrap"], playbook="tpl-privilege-escalation"),
+ S(slug="k8s-impersonate-verb", name="Kubernetes Verb 'impersonate' Used",
+ severity="high", mitre=["t1078.004"], product="kubernetes", service="audit",
+ when={"event_type": "audit", "verb": "impersonate"},
+ fp=["Operator framework using impersonation"], playbook="tpl-privilege-escalation"),
+ S(slug="k8s-mutating-webhook-changed", name="MutatingWebhookConfiguration Modified",
+ severity="high", mitre=["t1098"], product="kubernetes", service="audit",
+ when={"event_type_in": ["create_mutatingwebhookconfiguration", "update_mutatingwebhookconfiguration"]},
+ fp=["Approved admission controller upgrade"], playbook="tpl-defense-evasion"),
+ S(slug="k8s-validating-webhook-changed", name="ValidatingWebhookConfiguration Modified",
+ severity="high", mitre=["t1098"], product="kubernetes", service="audit",
+ when={"event_type_in": ["create_validatingwebhookconfiguration", "update_validatingwebhookconfiguration"]},
+ fp=["Approved admission controller upgrade"], playbook="tpl-defense-evasion"),
+ S(slug="k8s-pod-security-disabled-namespace", name="Pod Security Admission Mode Disabled For Namespace",
+ severity="high", mitre=["t1562.001"], product="kubernetes", service="audit",
+ when={"event_type": "label_namespace", "label_key": "pod-security.kubernetes.io/enforce", "label_value": "privileged"},
+ fp=["Sandbox namespace"], playbook="tpl-defense-evasion"),
+ S(slug="k8s-anonymous-auth-enabled", name="kube-apiserver Started With --anonymous-auth=true",
+ severity="critical", mitre=["t1078.004"], product="kubernetes", service="apiserver",
+ when={"event_type": "apiserver_start", "flag_anonymous_auth": True},
+ fp=["Lab cluster"], playbook="tpl-initial-access"),
+ S(slug="k8s-exec-into-kube-system", name="Exec Into Pod In kube-system Namespace",
+ severity="high", mitre=["t1611"], product="kubernetes", service="audit",
+ when={"event_type": "pod_exec", "namespace": "kube-system"},
+ fp=[FP_BREAK_GLASS], playbook="tpl-defense-evasion"),
+ S(slug="k8s-secret-mass-read", name="Many Secrets Read From Single Service Account",
+ severity="high", mitre=["t1552.007"], product="kubernetes", service="audit",
+ when={"event_type": "audit", "verb": "get", "resource": "secrets", "events_5min_gt": 30},
+ fp=["Sanctioned controller (allow-listed)"], playbook="tpl-credential-access"),
+ S(slug="k8s-networkpolicy-deleted-restricted-ns", name="NetworkPolicy Deleted In Restricted Namespace",
+ severity="high", mitre=["t1562.004"], product="kubernetes", service="audit",
+ when={"event_type": "delete_networkpolicy", "namespace_in": ["prod", "production", "default"]},
+ fp=[FP_BREAK_GLASS], playbook="tpl-defense-evasion"),
+ S(slug="k8s-pod-runs-cryptominer-image", name="Pod Created From Known Cryptominer Image Family",
+ severity="critical", mitre=["t1496"], product="kubernetes", service="audit",
+ when={"event_type": "create_pod", "image_contains_any": ["xmrig", "monero", "minerd"]},
+ fp=[FP_PENTEST], playbook="tpl-impact"),
+]
+
+
+# ---------------------------------------------------------------------------
+# Mobile / EDR posture (15 rules)
+# ---------------------------------------------------------------------------
+MOBILE_RULES: list[dict] = [
+ S(slug="mobile-ios-jailbreak-detected", name="iOS Jailbreak Detected By MDM",
+ severity="critical", mitre=["t1404"], product="ios", service="mdm",
+ when={"event_type": "compliance", "jailbroken": True},
+ fp=["Decommissioned dev device"], playbook="tpl-impact"),
+ S(slug="mobile-android-root-detected", name="Android Root Detected By MDM",
+ severity="critical", mitre=["t1404"], product="android", service="mdm",
+ when={"event_type": "compliance", "rooted": True},
+ fp=["Decommissioned dev device"], playbook="tpl-impact"),
+ S(slug="mobile-mdm-out-of-compliance", name="Device Marked Out Of MDM Compliance",
+ severity="medium", mitre=["t1078"], product="mdm", service="compliance",
+ when={"event_type": "compliance", "compliant": False},
+ fp=["Pending OS patch window"], playbook="tpl-credential-access"),
+ S(slug="mobile-app-sideloaded", name="App Sideloaded Outside Of Managed Store",
+ severity="high", mitre=["t1659"], product="mobile", service="mdm",
+ when={"event_type": "app_install", "source_in": ["unknown", "sideload", "adb"]},
+ fp=["Internal beta tester"], playbook="tpl-execution"),
+ S(slug="mobile-mdm-removal-attempt", name="MDM Profile Removal Attempted",
+ severity="critical", mitre=["t1562"], product="mdm", service="compliance",
+ when={"event_type": "profile_remove_attempt"},
+ fp=["Authorised offboarding"], playbook="tpl-defense-evasion"),
+ S(slug="mobile-vpn-app-installed", name="VPN App Installed On Managed Device",
+ severity="medium", mitre=["t1572"], product="mobile", service="mdm",
+ when={"event_type": "app_install", "category": "vpn"},
+ fp=["Approved corporate VPN"], playbook="tpl-command-and-control"),
+ S(slug="mobile-find-device-disabled", name="Find My Device Disabled",
+ severity="high", mitre=["t1562"], product="mobile", service="mdm",
+ when={"event_type": "compliance", "find_device_enabled": False},
+ fp=["Privacy compliance setting (educate)"], playbook="tpl-defense-evasion"),
+ S(slug="mobile-screen-lock-disabled", name="Screen Lock Disabled On Managed Device",
+ severity="high", mitre=["t1078"], product="mobile", service="mdm",
+ when={"event_type": "compliance", "screen_lock_enabled": False},
+ fp=["Decommissioned device pending wipe"], playbook="tpl-credential-access"),
+ S(slug="mobile-icloud-account-swap", name="iCloud Account Changed On Managed iOS Device",
+ severity="high", mitre=["t1078"], product="ios", service="mdm",
+ when={"event_type": "account_change", "service": "icloud"},
+ fp=["Reassigned device"], playbook="tpl-credential-access"),
+ S(slug="mobile-google-account-swap", name="Google Account Changed On Managed Android Device",
+ severity="high", mitre=["t1078"], product="android", service="mdm",
+ when={"event_type": "account_change", "service": "google"},
+ fp=["Reassigned device"], playbook="tpl-credential-access"),
+ S(slug="mobile-accessibility-permission-granted", name="Accessibility Permission Granted To Untrusted App",
+ severity="high", mitre=["t1530"], product="android", service="mdm",
+ when={"event_type": "permission_grant", "permission": "ACCESSIBILITY", "app_signed_by_known_publisher": False},
+ fp=["Approved screen-reader app"], playbook="tpl-collection"),
+ S(slug="mobile-network-proxy-configured", name="Network Proxy Configured On Managed Device",
+ severity="medium", mitre=["t1556"], product="mobile", service="mdm",
+ when={"event_type": "config_change", "key": "http_proxy"},
+ fp=["Corporate proxy rollout"], playbook="tpl-command-and-control"),
+ S(slug="mobile-developer-mode-enabled", name="Developer Mode Enabled On Managed Device",
+ severity="medium", mitre=["t1078"], product="mobile", service="mdm",
+ when={"event_type": "compliance", "developer_mode": True},
+ fp=["Approved engineering device"], playbook="tpl-defense-evasion"),
+ S(slug="mobile-mdm-cert-untrusted", name="Untrusted Root Certificate Installed On Device",
+ severity="high", mitre=["t1553.004"], product="mobile", service="mdm",
+ when={"event_type": "cert_install", "trust_level": "user_trusted"},
+ fp=["Corporate proxy CA install"], playbook="tpl-defense-evasion"),
+ S(slug="mobile-bluetooth-tethering-public", name="Personal Hotspot Or Bluetooth Tethering Enabled In Restricted Site",
+ severity="low", mitre=["t1011"], product="mobile", service="mdm",
+ when={"event_type": "compliance", "tethering_enabled": True, "geofence_in_restricted_zone": True},
+ fp=["Field engineer in approved zone"], playbook="tpl-exfiltration"),
+]
+
+
+# ---------------------------------------------------------------------------
+# Host network / posture (10 rules)
+# ---------------------------------------------------------------------------
+HOST_NETWORK_RULES: list[dict] = [
+ S(slug="host-firewall-disabled-managed", name="Host Firewall Disabled On Managed Endpoint",
+ severity="high", mitre=["t1562.004"], product="endpoint", service="firewall",
+ when={"event_type": "firewall_state_change", "state": "disabled"},
+ fp=[FP_TUNING, FP_BREAK_GLASS], playbook="tpl-defense-evasion"),
+ S(slug="host-promiscuous-interface", name="Network Interface Set To Promiscuous Mode",
+ severity="high", mitre=["t1040"], product="endpoint", service="agent",
+ when={"event_type": "interface_state", "promiscuous": True},
+ fp=["Sanctioned packet capture"], playbook="tpl-collection"),
+ S(slug="host-arp-poison-detected", name="ARP Cache Poisoning Indicators On Host",
+ severity="high", mitre=["t1557.002"], product="endpoint", service="agent",
+ when={"event_type": "arp_anomaly", "duplicate_macs_for_gateway": True},
+ fp=["Failover NIC"], playbook="tpl-credential-access"),
+ S(slug="host-llmnr-replies-spoofed", name="Suspicious LLMNR Reply Pattern (Responder-Like)",
+ severity="high", mitre=["t1557.001"], product="endpoint", service="agent",
+ when={"event_type": "llmnr", "self_response_for_external_query": True},
+ fp=["Lab environment"], playbook="tpl-credential-access"),
+ S(slug="host-wpad-probe", name="WPAD Probe Reaching External Resolver",
+ severity="medium", mitre=["t1557.002"], product="endpoint", service="dns",
+ when={"event_type": "dns_query", "query": "wpad.local", "external_resolver": True},
+ fp=["Misconfigured DHCP"], playbook="tpl-defense-evasion"),
+ S(slug="host-rogue-dhcp-host", name="Host Advertising As DHCP Server",
+ severity="critical", mitre=["t1557"], product="endpoint", service="agent",
+ when={"event_type": "dhcp_offer_outbound"},
+ fp=["Approved DHCP failover"], playbook="tpl-defense-evasion"),
+ S(slug="host-mdns-suspicious-tld", name="mDNS Query For Non-.local Suffix",
+ severity="low", mitre=["t1018"], product="endpoint", service="dns",
+ when={"event_type": "mdns_query", "query_endswith_any": [".com", ".net", ".io"]},
+ fp=["Misbehaving consumer-grade IoT device"], playbook="tpl-discovery"),
+ S(slug="host-upnp-from-server", name="UPnP/SSDP Beacons From Server Subnet",
+ severity="medium", mitre=["t1018"], product="endpoint", service="agent",
+ when={"event_type": "ssdp_egress", "source_subnet_role": "server"},
+ fp=["Approved IoT lab"], playbook="tpl-discovery"),
+ S(slug="host-rdp-mitm-cert-mismatch", name="RDP Client Saw Certificate Mismatch",
+ severity="high", mitre=["t1557.002"], product="endpoint", service="rdp",
+ when={"event_type": "rdp_cert_mismatch"},
+ fp=["Newly imaged target machine"], playbook="tpl-credential-access"),
+ S(slug="host-sccm-client-untrusted", name="SCCM Client Installed From Untrusted Source",
+ severity="medium", mitre=["t1195.002"], product="endpoint", service="agent",
+ when={"event_type": "agent_install", "agent": "sccm", "source_signed_by_known_publisher": False},
+ fp=["Migration to new MECM tenant"], playbook="tpl-supply-chain"),
+]
+
+
+# ---------------------------------------------------------------------------
+# Aggregate
+# ---------------------------------------------------------------------------
+ENDPOINT_EXTRA: list[dict] = (
+ WINDOWS_RULES
+ + LINUX_RULES
+ + MACOS_RULES
+ + CONTAINER_RULES
+ + MOBILE_RULES
+ + HOST_NETWORK_RULES
+)
+
+
+__all__ = [
+ "ENDPOINT_EXTRA",
+ "WINDOWS_RULES",
+ "LINUX_RULES",
+ "MACOS_RULES",
+ "CONTAINER_RULES",
+ "MOBILE_RULES",
+ "HOST_NETWORK_RULES",
+]
diff --git a/scripts/detection_specs_part3_helpers.py b/scripts/detection_specs_part3_helpers.py
new file mode 100644
index 000000000..7185b24cc
--- /dev/null
+++ b/scripts/detection_specs_part3_helpers.py
@@ -0,0 +1,442 @@
+"""
+Detection Pack v1 - Part 3 Helpers
+==================================
+
+Shared helpers for the 600 new native specs that scale the pack from
+200 to 800 rules. Builds positive/negative fixtures from a single
+``match_when`` clause so each spec stays compact.
+
+Auto-fixture rules
+------------------
+* Auto-generation only handles flat clauses (no ``any_of`` / ``all_of``).
+ Specs with nested clauses must pass explicit ``positive=`` / ``negative=``
+ fixtures.
+* The negative is the positive with one chosen field flipped to break the
+ clause. By default we flip the first non-compound clause; pass
+ ``neg_field=`` to override.
+* ``pattern_match`` / ``pattern_match_any`` clauses must supply a positive
+ sample because regex inversion is undecidable in general.
+"""
+
+from __future__ import annotations
+
+from typing import Any, Iterable
+
+# Operator suffixes - kept in sync with scripts/generate_detections.py.
+# We don't import OPERATORS to avoid bootstrapping yaml at module import time
+# (the spec files are loaded by the validator before yaml is available in
+# some CI shells).
+_OP_SUFFIXES: tuple[tuple[str, str], ...] = tuple(
+ sorted(
+ [
+ ("_pattern_match_any", "pattern_match_any"),
+ ("_not_endswith_any", "not_endswith_any"),
+ ("_not_contains_any", "not_contains_any"),
+ ("_pattern_match", "pattern_match"),
+ ("_not_startswith", "not_startswith"),
+ ("_startswith_any", "startswith_any"),
+ ("_endswith_any", "endswith_any"),
+ ("_contains_any", "contains_any"),
+ ("_contains_all", "contains_all"),
+ ("_startswith", "startswith"),
+ ("_match_any", "match_any"),
+ ("_endswith", "endswith"),
+ ("_contains", "contains"),
+ ("_has_any", "has_any"),
+ ("_not_in", "not_in"),
+ ("_match", "match"),
+ ("_gte", "gte"),
+ ("_lte", "lte"),
+ ("_in", "in"),
+ ("_gt", "gt"),
+ ("_lt", "lt"),
+ ],
+ key=lambda x: -len(x[0]),
+ )
+)
+
+
+def split_op(key: str) -> tuple[str, str]:
+ """Split a match_when key into (field, op_name). Plain key ⇒ op == 'eq'."""
+ for suffix, op_name in _OP_SUFFIXES:
+ if key.endswith(suffix):
+ return key[: -len(suffix)], op_name
+ return key, "eq"
+
+
+# Sample value pool for negation. Uses values unlikely to collide with
+# realistic field domains.
+_SENTINEL_STR = "__benign__"
+_SENTINEL_NUM = 0
+_SENTINEL_BOOL = False
+
+
+def _pos_for(op: str, expected: Any) -> Any:
+ """Return a value satisfying the (op, expected) clause."""
+ if op == "eq":
+ return expected
+ if op == "in":
+ return expected[0] if isinstance(expected, list) and expected else None
+ if op == "not_in":
+ return _SENTINEL_STR
+ if op == "match_any":
+ if isinstance(expected, list) and expected:
+ sample = str(expected[0])
+ return sample.replace("*", "x")
+ return _SENTINEL_STR
+ if op == "contains_any":
+ if isinstance(expected, list) and expected:
+ return f"prefix-{expected[0]}-suffix"
+ return _SENTINEL_STR
+ if op == "contains_all":
+ if isinstance(expected, list) and expected:
+ return " ".join(str(e) for e in expected)
+ return _SENTINEL_STR
+ if op == "contains":
+ return f"prefix-{expected}-suffix"
+ if op == "startswith":
+ return f"{expected}-tail"
+ if op == "startswith_any":
+ if isinstance(expected, list) and expected:
+ return f"{expected[0]}-tail"
+ return _SENTINEL_STR
+ if op == "endswith":
+ return f"head-{expected}"
+ if op == "endswith_any":
+ if isinstance(expected, list) and expected:
+ return f"head-{expected[0]}"
+ return _SENTINEL_STR
+ if op == "not_endswith_any":
+ return _SENTINEL_STR
+ if op == "not_contains_any":
+ return _SENTINEL_STR
+ if op == "not_startswith":
+ return _SENTINEL_STR
+ if op == "has_any":
+ if isinstance(expected, list) and expected:
+ return list(expected[:1])
+ return [_SENTINEL_STR]
+ if op == "match" or op == "pattern_match":
+ # Cannot reliably synthesise regex match. Caller must supply pos= override.
+ return _SENTINEL_STR
+ if op == "pattern_match_any":
+ return _SENTINEL_STR
+ if op in {"gt", "gte"}:
+ return float(expected) + 100 if isinstance(expected, (int, float)) else 100
+ if op in {"lt", "lte"}:
+ return float(expected) - 100 if isinstance(expected, (int, float)) else -100
+ return expected
+
+
+def _neg_for(op: str, expected: Any) -> Any:
+ """Return a value that breaks the (op, expected) clause."""
+ if op == "eq":
+ if expected is None:
+ return _SENTINEL_STR
+ if isinstance(expected, bool):
+ return not expected
+ if isinstance(expected, (int, float)):
+ return float(expected) + 1
+ return f"not-{expected}"
+ if op == "in":
+ return _SENTINEL_STR
+ if op == "not_in":
+ return expected[0] if isinstance(expected, list) and expected else _SENTINEL_STR
+ if op == "match_any":
+ return _SENTINEL_STR
+ if op == "contains_any":
+ return _SENTINEL_STR
+ if op == "contains_all":
+ return _SENTINEL_STR
+ if op == "contains":
+ return _SENTINEL_STR
+ if op == "startswith":
+ return f"x-{expected}"
+ if op == "startswith_any":
+ return _SENTINEL_STR
+ if op == "endswith":
+ return f"{expected}-x"
+ if op == "endswith_any":
+ return _SENTINEL_STR
+ if op == "not_endswith_any":
+ if isinstance(expected, list) and expected:
+ return f"head{expected[0]}"
+ return _SENTINEL_STR
+ if op == "not_contains_any":
+ if isinstance(expected, list) and expected:
+ return f"prefix-{expected[0]}-suffix"
+ return _SENTINEL_STR
+ if op == "not_startswith":
+ return f"{expected}-tail"
+ if op == "has_any":
+ return [_SENTINEL_STR]
+ if op == "match" or op == "pattern_match":
+ return _SENTINEL_STR
+ if op == "pattern_match_any":
+ return _SENTINEL_STR
+ if op in {"gt", "gte"}:
+ return float(expected) - 100 if isinstance(expected, (int, float)) else -100
+ if op in {"lt", "lte"}:
+ return float(expected) + 100 if isinstance(expected, (int, float)) else 100
+ return expected
+
+
+def _has_compound(when: dict[str, Any]) -> bool:
+ return any(k in {"any_of", "all_of"} for k in when.keys())
+
+
+def _fields_used(when: dict[str, Any]) -> set[str]:
+ fields: set[str] = set()
+ for key, val in when.items():
+ if key == "any_of" or key == "all_of":
+ if isinstance(val, list):
+ for sub in val:
+ if isinstance(sub, dict):
+ fields.update(_fields_used(sub))
+ continue
+ field, _ = split_op(key)
+ fields.add(field)
+ return fields
+
+
+def _compose_field_value(constraints: list[tuple[str, Any]]) -> Any:
+ """Compose a single value satisfying all (op, expected) constraints on one field.
+
+ Behaviour:
+ * Numeric ops (gt/gte/lt/lte) collapse to a value strictly inside the
+ intersected interval.
+ * `eq` and `in` short-circuit (the value must equal the expected literal).
+ * `has_any` returns a list containing the first allowed element.
+ * String ops compose ``startswith * contains * endswith``: the result
+ starts with any ``startswith[_any]`` value, ends with any
+ ``endswith[_any]`` value, and includes every ``contains*`` substring
+ in between. This lets a single value satisfy clauses like
+ ``path_startswith='/tmp/' + path_endswith_any=['.tar']``.
+ * Negation ops (``not_*``) and regex ops (``match*``, ``pattern_match*``)
+ are not actively enforced — the synthetic sentinel parts we glue in
+ won't accidentally match common deny-list values, so the engine sees
+ them as benign.
+ """
+ if not constraints:
+ return _SENTINEL_STR
+
+ # Numeric ops: compute the open intersection (lo, hi) and pick a midpoint.
+ nums = [(op, exp) for op, exp in constraints if op in {"gt", "gte", "lt", "lte"}]
+ if nums and all(isinstance(exp, (int, float)) for _, exp in nums):
+ lo: float = float("-inf")
+ hi: float = float("inf")
+ for op, exp in nums:
+ if op == "gt":
+ lo = max(lo, float(exp) + 1)
+ elif op == "gte":
+ lo = max(lo, float(exp))
+ elif op == "lt":
+ hi = min(hi, float(exp) - 1)
+ elif op == "lte":
+ hi = min(hi, float(exp))
+ if lo == float("-inf") and hi == float("inf"):
+ return 0
+ if lo == float("-inf"):
+ return hi - 1
+ if hi == float("inf"):
+ return lo + 1
+ # Pick midpoint within (lo, hi). Using floats keeps the math simple.
+ mid = (lo + hi) / 2.0
+ return mid
+
+ # eq / in short-circuit
+ eqs = [exp for op, exp in constraints if op == "eq"]
+ if eqs:
+ return eqs[0]
+ ins = [exp for op, exp in constraints if op == "in"]
+ if ins:
+ first = ins[0]
+ if isinstance(first, list) and first:
+ return first[0]
+ return first
+
+ has_anys = [exp for op, exp in constraints if op == "has_any"]
+ if has_anys:
+ first = has_anys[0]
+ if isinstance(first, list) and first:
+ return list(first[:1])
+ return [_SENTINEL_STR]
+
+ # String composition: collect prefix, suffix, and "contains" parts.
+ prefix = ""
+ suffix = ""
+ middle_parts: list[str] = []
+ for op, exp in constraints:
+ if op == "startswith":
+ prefix = str(exp)
+ elif op == "startswith_any":
+ if isinstance(exp, list) and exp:
+ prefix = str(exp[0])
+ elif op == "endswith":
+ suffix = str(exp)
+ elif op == "endswith_any":
+ if isinstance(exp, list) and exp:
+ suffix = str(exp[0])
+ elif op == "contains":
+ middle_parts.append(str(exp))
+ elif op == "contains_any":
+ if isinstance(exp, list) and exp:
+ middle_parts.append(str(exp[0]))
+ elif op == "contains_all":
+ if isinstance(exp, list):
+ middle_parts.extend(str(e) for e in exp)
+ elif op == "match_any":
+ if isinstance(exp, list) and exp:
+ middle_parts.append(str(exp[0]).replace("*", "x"))
+ # All other ops (not_in, not_contains_any, not_endswith_any, not_startswith,
+ # match, pattern_match, pattern_match_any) intentionally fall through —
+ # the sentinel parts above are unlikely to satisfy a deny-pattern.
+
+ if not (prefix or suffix or middle_parts):
+ return _SENTINEL_STR
+
+ middle = "".join(middle_parts)
+ if not middle and (prefix or suffix):
+ # When there's no required substring, glue prefix+suffix directly.
+ return f"{prefix}{suffix}"
+ return f"{prefix}{middle}{suffix}"
+
+
+def build_positive(when: dict[str, Any]) -> dict[str, Any]:
+ """Build a synthetic positive fixture from a flat match_when.
+
+ Multiple operators on the same field are composed into a single value.
+ For example, ``path_startswith='/tmp/'`` plus ``path_endswith_any=['.tar']``
+ yield ``path='/tmp/.tar'`` — satisfying both clauses.
+ """
+ if _has_compound(when):
+ raise ValueError(
+ "build_positive cannot auto-generate fixtures for any_of/all_of clauses. "
+ "Pass an explicit positive= to S()."
+ )
+ by_field: dict[str, list[tuple[str, Any]]] = {}
+ for key, val in when.items():
+ field, op = split_op(key)
+ by_field.setdefault(field, []).append((op, val))
+ pos: dict[str, Any] = {}
+ for field, constraints in by_field.items():
+ if len(constraints) == 1:
+ op, exp = constraints[0]
+ pos[field] = _pos_for(op, exp)
+ else:
+ pos[field] = _compose_field_value(constraints)
+ return pos
+
+
+def build_negative(
+ when: dict[str, Any],
+ *,
+ neg_field: str | None = None,
+) -> dict[str, Any]:
+ """Build a synthetic negative by flipping one clause of a flat match_when."""
+ if _has_compound(when):
+ raise ValueError(
+ "build_negative cannot auto-generate fixtures for any_of/all_of clauses. "
+ "Pass an explicit negative= to S()."
+ )
+ neg = build_positive(when)
+ target_key: str | None = None
+ target_op: str | None = None
+ target_expected: Any = None
+ if neg_field is not None:
+ for key in when.keys():
+ field, op = split_op(key)
+ if field == neg_field:
+ target_key, target_op, target_expected = key, op, when[key]
+ break
+ if target_key is None:
+ raise ValueError(
+ f"neg_field={neg_field!r} not found in match_when keys: {list(when.keys())}"
+ )
+ else:
+ first_key = next(iter(when.keys()))
+ target_key = first_key
+ target_field_name, target_op = split_op(first_key)
+ target_expected = when[first_key]
+ neg_field = target_field_name
+
+ neg[neg_field] = _neg_for(target_op, target_expected)
+ return neg
+
+
+# Re-usable false-positive snippets to keep specs concise.
+FP_TUNING = "Confirmed test/tuning activity"
+FP_AUTOMATION = "Sanctioned automation/IaC pipeline"
+FP_BREAK_GLASS = "Documented break-glass procedure"
+FP_PENTEST = "Authorised red-team or penetration test"
+FP_BACKUP = "Routine backup/disaster-recovery exercise"
+FP_FORENSIC = "DFIR responder running a documented playbook"
+FP_PATCH = "Approved patch / maintenance window activity"
+FP_ONBOARD = "First-time provisioning / new-user onboarding"
+
+
+def S(
+ *,
+ slug: str,
+ name: str,
+ severity: str,
+ mitre: Iterable[str],
+ product: str,
+ service: str,
+ when: dict[str, Any],
+ fp: Iterable[str],
+ playbook: str = "tpl-triage",
+ description: str | None = None,
+ positive: dict[str, Any] | None = None,
+ negative: dict[str, Any] | None = None,
+ pos_extra: dict[str, Any] | None = None,
+ neg_extra: dict[str, Any] | None = None,
+ neg_field: str | None = None,
+) -> dict[str, Any]:
+ """Build a detection spec entry with auto-generated fixtures.
+
+ Parameters
+ ----------
+ slug : Filesystem slug (must be unique within the category).
+ name : Human-readable rule name.
+ severity : low | medium | high | critical.
+ mitre : Iterable of MITRE technique IDs (lowercased dotted form, e.g. "t1078.004").
+ product, service : log_source keys.
+ when : The match_when dict (flat for auto-fixtures, nested for explicit).
+ fp : Iterable of false-positive bullets (≥1 strongly recommended).
+ playbook : Template playbook ID (`tpl-...`).
+ description : Optional long description (otherwise auto-generated by the renderer).
+ positive, negative : Override fixtures (skip auto-gen).
+ pos_extra, neg_extra : Extra context fields appended to fixtures.
+ neg_field : Override the default flip target when auto-generating negative.
+ """
+ if positive is None:
+ pos = build_positive(when)
+ else:
+ pos = dict(positive)
+ if pos_extra:
+ pos.update(pos_extra)
+
+ if negative is None:
+ neg = build_negative(when, neg_field=neg_field)
+ else:
+ neg = dict(negative)
+ if neg_extra:
+ neg.update(neg_extra)
+
+ spec: dict[str, Any] = {
+ "slug": slug,
+ "name": name,
+ "severity": severity,
+ "mitre": [t.lower() for t in mitre],
+ "log_source": {"product": product, "service": service},
+ "fields": _fields_used(when),
+ "match_when": when,
+ "fp": list(fp),
+ "playbook": playbook,
+ "positive": pos,
+ "negative": neg,
+ }
+ if description:
+ spec["description"] = description
+ return spec
diff --git a/scripts/detection_specs_part3_identity.py b/scripts/detection_specs_part3_identity.py
new file mode 100644
index 000000000..ce379f48c
--- /dev/null
+++ b/scripts/detection_specs_part3_identity.py
@@ -0,0 +1,568 @@
+"""
+Detection Pack v1 - Part 3 / Identity (120 new specs)
+=====================================================
+
+Native identity-and-access detection rules covering Okta, Auth0, Duo, Ping,
+generic SAML/OIDC IdPs, AD/Kerberos, password-attack telemetry, and SaaS-side
+identity events. Extends ``detection_specs.IDENTITY`` from 35 to ~155 native
+identity detections.
+
+These rules complement the cloud IAM detections in part3-cloud — anything that
+is *exclusively* about an IdP (Okta admin events, AD audit log, generic
+sign-in telemetry) lives here; cloud-provider IAM (AWS IAM, Entra audit,
+GCP IAM) lives in cloud.
+"""
+
+from __future__ import annotations
+
+from detection_specs_part3_helpers import ( # type: ignore[import-not-found]
+ FP_AUTOMATION,
+ FP_BREAK_GLASS,
+ FP_FORENSIC,
+ FP_ONBOARD,
+ FP_PATCH,
+ FP_PENTEST,
+ FP_TUNING,
+ S,
+)
+
+
+# ---------------------------------------------------------------------------
+# Authentication failures / brute force / credential stuffing (25)
+# ---------------------------------------------------------------------------
+AUTH_RULES: list[dict] = [
+ S(slug="ident-password-spray-many-targets", name="Password Spray: Single IP, Many Targets, Few Tries Each",
+ severity="high", mitre=["t1110.003"], product="identity", service="auth",
+ when={"event_type": "auth_failure", "distinct_users_per_minute_gt": 30, "tries_per_user_lte": 5},
+ fp=["VPN concentrator with shared egress"], playbook="tpl-credential-access"),
+ S(slug="ident-password-spray-distributed", name="Distributed Password Spray From Many IPs",
+ severity="high", mitre=["t1110.003"], product="identity", service="auth",
+ when={"event_type": "auth_failure", "distinct_ips_per_user_per_hour_gt": 30},
+ fp=["Mobile-app users with rotating cellular IPs"], playbook="tpl-credential-access"),
+ S(slug="ident-credstuffing-known-breached-list", name="Credential Stuffing Pattern Against Login Endpoint",
+ severity="high", mitre=["t1110.004"], product="identity", service="auth",
+ when={"event_type": "auth_failure", "user_agent_in_known_botnet_list": True, "tries_per_minute_gt": 50},
+ fp=["Load test (must be ticketed)"], playbook="tpl-credential-access"),
+ S(slug="ident-bruteforce-success-after-failures", name="Successful Login After 50+ Recent Failures",
+ severity="high", mitre=["t1110.001"], product="identity", service="auth",
+ when={"event_type": "auth_success", "user_failures_last_15m_gt": 50},
+ fp=["Forgot-password flow", "Helpdesk reset"], playbook="tpl-credential-access"),
+ S(slug="ident-impossible-travel-15m", name="Impossible Travel: Two Successful Logins <15m, >1000km",
+ severity="high", mitre=["t1078"], product="identity", service="auth",
+ when={"event_type": "auth_success", "geo_distance_km_gt": 1000, "minutes_between_lt": 15},
+ fp=["Corporate VPN (egress IP changes)", "Mobile-data roaming"], playbook="tpl-credential-access"),
+ S(slug="ident-tor-exit-login-success", name="Successful Login From Tor Exit Node",
+ severity="high", mitre=["t1090.003"], product="identity", service="auth",
+ when={"event_type": "auth_success", "src_ip_tor_exit": True},
+ fp=["Privacy-conscious researcher (must be ticketed)"], playbook="tpl-initial-access"),
+ S(slug="ident-anon-vpn-login-priv-user", name="Privileged User Login From Anonymising VPN",
+ severity="high", mitre=["t1090.003"], product="identity", service="auth",
+ when={"event_type": "auth_success", "src_ip_anonymous_vpn": True, "user_priv": True},
+ fp=["Approved BYOD-VPN policy"], playbook="tpl-initial-access"),
+ S(slug="ident-mfa-fatigue-burst", name="MFA Fatigue Burst Against Single User",
+ severity="high", mitre=["t1621"], product="identity", service="auth",
+ when={"event_type": "mfa_challenge", "user_challenges_per_minute_gt": 5},
+ fp=["Genuine push-loop after device swap"], playbook="tpl-credential-access"),
+ S(slug="ident-mfa-deny-then-success", name="User Denied Push Then Approved Within 60s",
+ severity="medium", mitre=["t1621"], product="identity", service="auth",
+ when={"event_type": "mfa_state_change", "previous_state": "deny", "current_state": "approve", "seconds_between_lt": 60},
+ fp=["Misclick on first prompt"], playbook="tpl-credential-access"),
+ S(slug="ident-account-locked-many-times", name="Account Locked Out 3+ Times In 1 Hour",
+ severity="medium", mitre=["t1110"], product="identity", service="auth",
+ when={"event_type": "account_locked", "lockouts_per_hour_gte": 3},
+ fp=["Stuck mobile credential", FP_TUNING], playbook="tpl-credential-access"),
+ S(slug="ident-disabled-user-auth-attempt", name="Authentication Attempt Against Disabled User",
+ severity="high", mitre=["t1078"], product="identity", service="auth",
+ when={"event_type": "auth_failure", "result": "user_disabled"},
+ fp=["Lingering session token", "Failed deprovision"], playbook="tpl-persistence"),
+ S(slug="ident-deleted-user-auth-success", name="Authentication Success For Recently Deleted User",
+ severity="critical", mitre=["t1078"], product="identity", service="auth",
+ when={"event_type": "auth_success", "user_state": "deleted"},
+ fp=[], playbook="tpl-credential-access"),
+ S(slug="ident-mfa-bypassed-via-emergency-code", name="MFA Bypass Via Emergency / Backup Code",
+ severity="high", mitre=["t1556.006"], product="identity", service="auth",
+ when={"event_type": "auth_success", "mfa_factor": "backup_code"},
+ fp=[FP_BREAK_GLASS], playbook="tpl-credential-access"),
+ S(slug="ident-fido2-key-removed-priv", name="FIDO2 Hardware Key Removed From Privileged User",
+ severity="high", mitre=["t1556.006"], product="identity", service="mfa",
+ when={"event_type": "factor_remove", "factor_type": "fido2", "user_priv": True},
+ fp=[FP_BREAK_GLASS], playbook="tpl-defense-evasion"),
+ S(slug="ident-fido2-key-added-then-removed-old", name="FIDO2 Key Added And Old Key Removed In Same Session",
+ severity="high", mitre=["t1556.006"], product="identity", service="mfa",
+ when={"event_type": "factor_swap", "old_factor_age_days_gt": 30, "session_seconds_lt": 600},
+ fp=[FP_BREAK_GLASS], playbook="tpl-persistence"),
+ S(slug="ident-totp-secret-revealed", name="TOTP Secret QR-Code Re-Issued Without Old Factor Removal",
+ severity="medium", mitre=["t1556"], product="identity", service="mfa",
+ when={"event_type": "factor_create", "factor_type": "totp", "old_factor_removed": False},
+ fp=["Helpdesk-driven recovery"], playbook="tpl-credential-access"),
+ S(slug="ident-static-password-policy-loosened", name="Password Policy Min-Length / Complexity Loosened",
+ severity="high", mitre=["t1556"], product="identity", service="policy",
+ when={"event_type": "policy_update", "min_length_decreased": True},
+ fp=[FP_TUNING], playbook="tpl-defense-evasion"),
+ S(slug="ident-password-policy-history-reduced", name="Password History Length Reduced",
+ severity="medium", mitre=["t1556"], product="identity", service="policy",
+ when={"event_type": "policy_update", "history_length_decreased": True},
+ fp=[FP_TUNING], playbook="tpl-defense-evasion"),
+ S(slug="ident-session-timeout-extended-priv", name="Session Timeout Extended For Privileged Group",
+ severity="medium", mitre=["t1556"], product="identity", service="policy",
+ when={"event_type": "policy_update", "session_timeout_minutes_increased": True, "scope_priv": True},
+ fp=[FP_TUNING], playbook="tpl-defense-evasion"),
+ S(slug="ident-suspicious-user-agent-login", name="Login With Headless / Bot User Agent",
+ severity="medium", mitre=["t1078"], product="identity", service="auth",
+ when={"event_type": "auth_success", "user_agent_contains_any": ["python-requests", "curl/", "headless", "phantomjs", "selenium"]},
+ fp=["Internal API client (must be ticketed)"], playbook="tpl-credential-access"),
+ S(slug="ident-login-from-known-asn-ddos", name="Login From ASN Recently Seen In Credential-Stuffing Activity",
+ severity="medium", mitre=["t1110.004"], product="identity", service="auth",
+ when={"event_type": "auth_success", "src_asn_recent_credstuffing": True},
+ fp=["Mobile carrier shared NAT"], playbook="tpl-credential-access"),
+ S(slug="ident-new-country-priv-user", name="Privileged User Login From New Country",
+ severity="medium", mitre=["t1078"], product="identity", service="auth",
+ when={"event_type": "auth_success", "user_priv": True, "country_first_seen_for_user": True},
+ fp=["Authorised travel"], playbook="tpl-credential-access"),
+ S(slug="ident-rapid-language-change", name="User Login Locale Switched Rapidly",
+ severity="low", mitre=["t1078"], product="identity", service="auth",
+ when={"event_type": "auth_success", "locale_changes_in_session_gt": 2},
+ fp=["Shared/kiosk machine"], playbook="tpl-discovery"),
+ S(slug="ident-empty-useragent-login", name="Login With Empty User-Agent",
+ severity="medium", mitre=["t1078"], product="identity", service="auth",
+ when={"event_type": "auth_success", "user_agent": ""},
+ fp=["Custom internal client"], playbook="tpl-credential-access"),
+ S(slug="ident-totp-skewed-clock", name="TOTP Verification Repeatedly Skews Clock",
+ severity="low", mitre=["t1110"], product="identity", service="mfa",
+ when={"event_type": "mfa_challenge", "totp_clock_skew_seconds_gt": 60, "events_per_minute_gt": 5},
+ fp=["Phone clock drift"], playbook="tpl-credential-access"),
+]
+
+
+# ---------------------------------------------------------------------------
+# Privileged-account events / role assignment / persistence (25)
+# ---------------------------------------------------------------------------
+PRIV_RULES: list[dict] = [
+ S(slug="ident-priv-role-grant-out-of-hours", name="Privileged Role Granted Outside Business Hours",
+ severity="high", mitre=["t1078"], product="identity", service="audit",
+ when={"event_type": "role_grant", "role_priv": True, "is_business_hours": False},
+ fp=[FP_BREAK_GLASS, "On-call rotation"], playbook="tpl-privilege-escalation"),
+ S(slug="ident-self-grant-priv-role", name="User Granted Privileged Role To Themselves",
+ severity="critical", mitre=["t1098"], product="identity", service="audit",
+ when={"event_type": "role_grant", "role_priv": True, "actor_eq_target": True},
+ fp=[FP_BREAK_GLASS], playbook="tpl-privilege-escalation"),
+ S(slug="ident-priv-role-grant-to-svc-account", name="Privileged Role Granted To Service Account",
+ severity="high", mitre=["t1078.004"], product="identity", service="audit",
+ when={"event_type": "role_grant", "role_priv": True, "target_user_type": "service_account"},
+ fp=["IaC pipeline"], playbook="tpl-privilege-escalation"),
+ S(slug="ident-pim-activation-self-approval", name="JIT/PIM Privileged Activation Self-Approved",
+ severity="high", mitre=["t1078"], product="identity", service="pim",
+ when={"event_type": "pim_activation", "approver_eq_actor": True},
+ fp=[FP_BREAK_GLASS], playbook="tpl-privilege-escalation"),
+ S(slug="ident-pim-activation-anomalous-time", name="JIT/PIM Activation At Unusual Hour For User",
+ severity="medium", mitre=["t1078"], product="identity", service="pim",
+ when={"event_type": "pim_activation", "hour_unusual_for_user": True},
+ fp=[FP_BREAK_GLASS], playbook="tpl-privilege-escalation"),
+ S(slug="ident-priv-role-burst-granted", name="Privileged Role Grant Burst Across Many Users",
+ severity="high", mitre=["t1098"], product="identity", service="audit",
+ when={"event_type": "role_grant", "role_priv": True, "events_per_minute_gt": 10},
+ fp=["Bulk reorg (must be ticketed)"], playbook="tpl-privilege-escalation"),
+ S(slug="ident-svc-account-interactive-login", name="Service Account Used For Interactive Login",
+ severity="high", mitre=["t1078.004"], product="identity", service="auth",
+ when={"event_type": "auth_success", "user_type": "service_account", "is_interactive": True},
+ fp=["Approved automation runner using human UI"], playbook="tpl-credential-access"),
+ S(slug="ident-svc-account-mfa-skipped", name="Service Account Login Without MFA In Region That Requires It",
+ severity="medium", mitre=["t1078.004"], product="identity", service="auth",
+ when={"event_type": "auth_success", "user_type": "service_account", "mfa_used": False, "policy_requires_mfa": True},
+ fp=[FP_TUNING], playbook="tpl-defense-evasion"),
+ S(slug="ident-onboard-priv-roles-immediate", name="New User Granted Privileged Role <24h After Creation",
+ severity="high", mitre=["t1098"], product="identity", service="audit",
+ when={"event_type": "role_grant", "role_priv": True, "user_age_minutes_lt": 1440},
+ fp=[FP_ONBOARD], playbook="tpl-privilege-escalation"),
+ S(slug="ident-app-impersonation-priv", name="OAuth App Acting As Privileged User",
+ severity="high", mitre=["t1528"], product="identity", service="oauth",
+ when={"event_type": "oauth_action", "act_as_user_priv": True, "scope_contains_any": ["full_access", "admin", "*.write"]},
+ fp=["Approved IaaS automation"], playbook="tpl-credential-access"),
+ S(slug="ident-priv-role-removed-bulk", name="Privileged Role Removed From Many Users In Burst",
+ severity="medium", mitre=["t1531"], product="identity", service="audit",
+ when={"event_type": "role_revoke", "role_priv": True, "events_per_minute_gt": 10},
+ fp=["Approved cleanup project"], playbook="tpl-impact"),
+ S(slug="ident-orphan-svc-acct-many-keys", name="Service Account With 5+ Active API Keys",
+ severity="medium", mitre=["t1098.001"], product="identity", service="audit",
+ when={"event_type": "key_inventory", "active_keys_per_account_gt": 5},
+ fp=[FP_AUTOMATION], playbook="tpl-credential-access"),
+ S(slug="ident-svc-account-key-from-non-pipeline", name="Service Account Key Used From Non-Pipeline IP",
+ severity="high", mitre=["t1078.004"], product="identity", service="auth",
+ when={"event_type": "auth_success", "user_type": "service_account", "src_in_pipeline_cidr": False},
+ fp=["Approved migration"], playbook="tpl-credential-access"),
+ S(slug="ident-domain-admin-added", name="Domain Admin Group Membership Added (AD)",
+ severity="critical", mitre=["t1098.007"], product="active-directory", service="audit",
+ when={"event_id": 4728, "group_name_in": ["Domain Admins", "Enterprise Admins", "Schema Admins"]},
+ fp=[FP_BREAK_GLASS], playbook="tpl-privilege-escalation"),
+ S(slug="ident-ad-acl-sensitive-changed", name="ACL On Sensitive AD Object Modified",
+ severity="high", mitre=["t1484.002"], product="active-directory", service="audit",
+ when={"event_id": 4670, "object_class_in": ["domainDNS", "groupPolicyContainer"]},
+ fp=["Approved AD reorg"], playbook="tpl-privilege-escalation"),
+ S(slug="ident-ad-dcsync-rights-granted", name="DCSync Rights Granted Outside Domain Controllers",
+ severity="critical", mitre=["t1003.006"], product="active-directory", service="audit",
+ when={"event_id": 5136, "rights_added_contains_any": ["DS-Replication-Get-Changes", "DS-Replication-Get-Changes-All"]},
+ fp=["Approved Azure AD Connect / sync engine"], playbook="tpl-credential-access"),
+ S(slug="ident-ad-gpo-modified-priv", name="Privileged GPO Modified",
+ severity="high", mitre=["t1484.001"], product="active-directory", service="audit",
+ when={"event_id": 5136, "gpo_link_priv": True},
+ fp=["Approved GPO refactor"], playbook="tpl-defense-evasion"),
+ S(slug="ident-ad-trust-modified", name="AD Domain Trust Modified",
+ severity="critical", mitre=["t1484.002"], product="active-directory", service="audit",
+ when={"event_id_in": [4716, 4865, 4867]},
+ fp=["Approved forest merger"], playbook="tpl-privilege-escalation"),
+ S(slug="ident-ad-userauth-anonymous-named-pipe", name="AD Anonymous Logon Allowed Via Null Session",
+ severity="high", mitre=["t1078.001"], product="active-directory", service="auth",
+ when={"event_id": 4624, "logon_type": 3, "user_name": "ANONYMOUS LOGON"},
+ fp=["Legacy app (must be ticketed)"], playbook="tpl-initial-access"),
+ S(slug="ident-ad-pwd-not-required", name="AD Account Set With PASSWD_NOTREQD",
+ severity="high", mitre=["t1098"], product="active-directory", service="audit",
+ when={"event_id": 4738, "useraccountcontrol_flag_passwd_notreqd": True},
+ fp=[FP_TUNING], playbook="tpl-credential-access"),
+ S(slug="ident-ad-pwd-never-expires-priv", name="Privileged AD Account Set With DONT_EXPIRE_PASSWORD",
+ severity="medium", mitre=["t1098"], product="active-directory", service="audit",
+ when={"event_id": 4738, "useraccountcontrol_flag_dont_expire": True, "user_priv": True},
+ fp=["Service account by design"], playbook="tpl-credential-access"),
+ S(slug="ident-ad-machine-account-quota-abuse", name="Machine Account Quota Exhausted By Single User",
+ severity="high", mitre=["t1136.001"], product="active-directory", service="audit",
+ when={"event_id": 4741, "machines_created_per_user_per_day_gt": 5},
+ fp=["Approved imaging pipeline"], playbook="tpl-persistence"),
+ S(slug="ident-ad-protected-users-removed", name="User Removed From Protected Users Group",
+ severity="high", mitre=["t1556"], product="active-directory", service="audit",
+ when={"event_id": 4729, "group_name": "Protected Users"},
+ fp=[FP_BREAK_GLASS], playbook="tpl-defense-evasion"),
+ S(slug="ident-ad-sidhistory-modified", name="AD sIDHistory Attribute Modified",
+ severity="high", mitre=["t1078.002"], product="active-directory", service="audit",
+ when={"event_id": 4738, "attribute_modified": "sIDHistory"},
+ fp=["Approved domain migration"], playbook="tpl-privilege-escalation"),
+ S(slug="ident-ad-userlogon-disabled-account", name="Disabled AD Account Authenticated Successfully",
+ severity="high", mitre=["t1078.002"], product="active-directory", service="auth",
+ when={"event_id": 4624, "account_disabled": True},
+ fp=["Stale ticket cache"], playbook="tpl-initial-access"),
+]
+
+
+# ---------------------------------------------------------------------------
+# Kerberos / NTLM / token-theft (15)
+# ---------------------------------------------------------------------------
+KERB_RULES: list[dict] = [
+ S(slug="ident-kerberoasting-tgs-rc4", name="Kerberoasting: TGS Request With RC4_HMAC",
+ severity="high", mitre=["t1558.003"], product="active-directory", service="kerberos",
+ when={"event_id": 4769, "ticket_encryption_type": "0x17"},
+ fp=["Legacy app (must be ticketed)"], playbook="tpl-credential-access"),
+ S(slug="ident-asreproast-no-preauth", name="AS-REP Roasting: TGT Without Pre-Auth",
+ severity="high", mitre=["t1558.004"], product="active-directory", service="kerberos",
+ when={"event_id": 4768, "preauth_required": False},
+ fp=["Approved scanner / vuln check"], playbook="tpl-credential-access"),
+ S(slug="ident-golden-ticket-anomalous-tgt-lifetime", name="Golden Ticket Indicator: TGT Lifetime > 10h",
+ severity="critical", mitre=["t1558.001"], product="active-directory", service="kerberos",
+ when={"event_id": 4768, "ticket_lifetime_hours_gt": 10},
+ fp=["Approved long-life ticket policy"], playbook="tpl-persistence"),
+ S(slug="ident-silver-ticket-anomalous-spn", name="Silver Ticket Indicator: TGS Without Matching TGT",
+ severity="high", mitre=["t1558.002"], product="active-directory", service="kerberos",
+ when={"event_id": 4769, "tgt_seen_for_user_in_window": False},
+ fp=["Logging gap"], playbook="tpl-persistence"),
+ S(slug="ident-skeleton-key-encryption-downgrade", name="Skeleton Key Indicator: Forced Downgrade To DES/RC4",
+ severity="critical", mitre=["t1556.001"], product="active-directory", service="kerberos",
+ when={"event_id": 4624, "logon_type": 3, "encryption_type_in": ["DES", "RC4"], "domain_controller": True},
+ fp=["Legacy app integration"], playbook="tpl-credential-access"),
+ S(slug="ident-kerberos-failure-spike-from-host", name="Kerberos Pre-Auth Failure Spike From Host",
+ severity="medium", mitre=["t1110"], product="active-directory", service="kerberos",
+ when={"event_id": 4771, "failures_per_host_per_minute_gt": 50},
+ fp=["Misconfigured app"], playbook="tpl-credential-access"),
+ S(slug="ident-ntlm-relay-indicator", name="NTLM Authentication With Mismatched WorkstationName",
+ severity="high", mitre=["t1557.001"], product="active-directory", service="ntlm",
+ when={"event_id": 8004, "auth_type": "NTLMv2", "workstation_neq_source_address": True},
+ fp=[FP_PENTEST], playbook="tpl-credential-access"),
+ S(slug="ident-ntlm-priv-account-from-untrusted", name="Privileged Account NTLM Logon From Untrusted Host",
+ severity="high", mitre=["t1078.002"], product="active-directory", service="ntlm",
+ when={"event_id": 4624, "auth_type": "NTLMv2", "user_priv": True, "src_host_trusted": False},
+ fp=[FP_BREAK_GLASS], playbook="tpl-credential-access"),
+ S(slug="ident-pass-the-hash-anomalous-logon", name="Pass-The-Hash Indicator: NTLMv2 With NewCredentials",
+ severity="high", mitre=["t1550.002"], product="active-directory", service="auth",
+ when={"event_id": 4624, "logon_type": 9, "auth_type": "NTLMv2"},
+ fp=["RunAs /netonly use"], playbook="tpl-lateral-movement"),
+ S(slug="ident-pass-the-ticket-anomalous-tgt-source", name="Pass-The-Ticket Indicator: TGT Source IP Mismatch",
+ severity="high", mitre=["t1550.003"], product="active-directory", service="kerberos",
+ when={"event_id": 4624, "logon_type": 3, "ticket_source_ip_neq_session_ip": True},
+ fp=["NAT / proxy environment"], playbook="tpl-lateral-movement"),
+ S(slug="ident-token-theft-cookie-replay", name="Session Cookie Replayed From New Geo Within 1h",
+ severity="critical", mitre=["t1539"], product="identity", service="session",
+ when={"event_type": "session_continuation", "geo_changed": True, "minutes_between_lt": 60},
+ fp=["Mobile-tethering carrier IP change"], playbook="tpl-credential-access"),
+ S(slug="ident-oauth-refresh-token-replay", name="OAuth Refresh Token Replayed From Different IP",
+ severity="high", mitre=["t1550"], product="identity", service="oauth",
+ when={"event_type": "token_refresh", "src_ip_changed": True, "geo_distance_km_gt": 500},
+ fp=["Roaming user"], playbook="tpl-credential-access"),
+ S(slug="ident-oauth-token-theft-impossible-time", name="OAuth Access Token Used Before Issue +1s",
+ severity="high", mitre=["t1550"], product="identity", service="oauth",
+ when={"event_type": "token_use", "seconds_after_issue_lt": 1, "ip_changed": True},
+ fp=["Clock skew"], playbook="tpl-credential-access"),
+ S(slug="ident-saml-assertion-replay", name="SAML Assertion Replayed Within Window",
+ severity="high", mitre=["t1550"], product="identity", service="saml",
+ when={"event_type": "saml_consume", "assertion_id_seen_recently": True},
+ fp=["IdP retry due to relay-state confusion"], playbook="tpl-credential-access"),
+ S(slug="ident-saml-issuer-mismatch", name="SAML Assertion Issuer Mismatched",
+ severity="critical", mitre=["t1556"], product="identity", service="saml",
+ when={"event_type": "saml_consume", "issuer_in_trusted_list": False},
+ fp=["IdP migration window"], playbook="tpl-defense-evasion"),
+]
+
+
+# ---------------------------------------------------------------------------
+# IdP admin events (Okta, Auth0, Duo, Ping, Keycloak) (35)
+# ---------------------------------------------------------------------------
+IDP_RULES: list[dict] = [
+ # Okta (12)
+ S(slug="ident-okta-admin-app-assigned-many-users", name="Okta Admin App Assigned To Many Users In Burst",
+ severity="medium", mitre=["t1098"], product="okta", service="audit",
+ when={"event_type": "application.user_membership.add", "events_per_minute_gt": 25},
+ fp=["Bulk app rollout"], playbook="tpl-discovery"),
+ S(slug="ident-okta-policy-everyone-bypass-mfa", name="Okta Policy Allows 'Everyone' Without MFA",
+ severity="high", mitre=["t1556"], product="okta", service="audit",
+ when={"event_type_in": ["policy.lifecycle.activate", "policy.rule.update"], "factor_required": False, "applies_to_everyone": True},
+ fp=[FP_TUNING], playbook="tpl-defense-evasion"),
+ S(slug="ident-okta-network-zone-modified-trusted", name="Okta Trusted Network Zone Modified",
+ severity="medium", mitre=["t1556"], product="okta", service="audit",
+ when={"event_type": "zone.update", "zone_type": "IP", "trusted": True},
+ fp=["Office relocation"], playbook="tpl-defense-evasion"),
+ S(slug="ident-okta-superadmin-added", name="Okta Super Administrator Role Granted",
+ severity="critical", mitre=["t1098"], product="okta", service="audit",
+ when={"event_type": "user.account.privilege.grant", "role": "SUPER_ADMIN"},
+ fp=[FP_BREAK_GLASS], playbook="tpl-privilege-escalation"),
+ S(slug="ident-okta-suspicious-login-bot", name="Okta Login Marked Suspicious-Activity Behaviour",
+ severity="medium", mitre=["t1078"], product="okta", service="auth",
+ when={"event_type": "user.session.start", "behaviors_contains_any": ["new_device", "new_geolocation", "velocity"]},
+ fp=["Mobile user travel"], playbook="tpl-credential-access"),
+ S(slug="ident-okta-app-secret-rotated-priv", name="Okta App Sign-On Secret Rotated By Non-Admin",
+ severity="high", mitre=["t1098.001"], product="okta", service="audit",
+ when={"event_type": "application.lifecycle.update", "actor_role_priv": False, "secret_rotated": True},
+ fp=[FP_TUNING], playbook="tpl-persistence"),
+ S(slug="ident-okta-mfa-factor-reset-priv", name="Okta MFA Factor Reset For Privileged User",
+ severity="high", mitre=["t1556.006"], product="okta", service="audit",
+ when={"event_type": "user.mfa.factor.reset_all", "target_user_priv": True},
+ fp=[FP_BREAK_GLASS], playbook="tpl-defense-evasion"),
+ S(slug="ident-okta-policy-deactivated", name="Okta Sign-On Policy Deactivated",
+ severity="high", mitre=["t1562.001"], product="okta", service="audit",
+ when={"event_type": "policy.lifecycle.deactivate"},
+ fp=[FP_TUNING], playbook="tpl-defense-evasion"),
+ S(slug="ident-okta-app-assigned-foreign-domain", name="Okta App Assigned With Federated External Domain",
+ severity="high", mitre=["t1199"], product="okta", service="audit",
+ when={"event_type": "application.federated.user.assign", "external_domain": True},
+ fp=["Approved partner integration"], playbook="tpl-initial-access"),
+ S(slug="ident-okta-api-token-created-priv", name="Okta API Token Created With Admin Role",
+ severity="high", mitre=["t1098.001"], product="okta", service="audit",
+ when={"event_type": "system.api_token.create", "scope_contains": "admin"},
+ fp=["Approved automation"], playbook="tpl-persistence"),
+ S(slug="ident-okta-radius-app-added", name="Okta RADIUS Application Added",
+ severity="medium", mitre=["t1133"], product="okta", service="audit",
+ when={"event_type": "application.lifecycle.create", "app_type": "radius"},
+ fp=["Approved network gear"], playbook="tpl-initial-access"),
+ S(slug="ident-okta-mass-deactivate-users", name="Okta Mass User Deactivation",
+ severity="high", mitre=["t1531"], product="okta", service="audit",
+ when={"event_type": "user.lifecycle.deactivate", "events_per_minute_gt": 25},
+ fp=["Bulk offboarding"], playbook="tpl-impact"),
+ # Auth0 (5)
+ S(slug="ident-auth0-rule-added", name="Auth0 Rule Added (Custom Code In Login Pipeline)",
+ severity="high", mitre=["t1556"], product="auth0", service="audit",
+ when={"event_type": "Successful API Operation", "operation": "rules.create"},
+ fp=["Approved tenant config"], playbook="tpl-persistence"),
+ S(slug="ident-auth0-action-deployed", name="Auth0 Action Deployed",
+ severity="high", mitre=["t1556"], product="auth0", service="audit",
+ when={"event_type": "Successful API Operation", "operation": "actions.deploy"},
+ fp=["Approved tenant config"], playbook="tpl-persistence"),
+ S(slug="ident-auth0-management-api-key-created", name="Auth0 Management API Key Created",
+ severity="high", mitre=["t1098.001"], product="auth0", service="audit",
+ when={"event_type": "Successful API Operation", "operation": "client_grants.create", "scope_contains": "manage"},
+ fp=["Approved automation"], playbook="tpl-persistence"),
+ S(slug="ident-auth0-connection-deleted", name="Auth0 Connection Deleted",
+ severity="medium", mitre=["t1485"], product="auth0", service="audit",
+ when={"event_type": "Successful API Operation", "operation": "connections.delete"},
+ fp=["Tenant cleanup"], playbook="tpl-impact"),
+ S(slug="ident-auth0-anomaly-detection-disabled", name="Auth0 Anomaly Detection Disabled",
+ severity="high", mitre=["t1562.001"], product="auth0", service="audit",
+ when={"event_type": "Successful API Operation", "operation": "anomaly.disable"},
+ fp=[FP_TUNING], playbook="tpl-defense-evasion"),
+ # Duo (5)
+ S(slug="ident-duo-bypass-code-generated", name="Duo Bypass Code Generated",
+ severity="high", mitre=["t1556.006"], product="duo", service="admin",
+ when={"event_type": "user_create_bypass_code"},
+ fp=[FP_BREAK_GLASS], playbook="tpl-credential-access"),
+ S(slug="ident-duo-policy-changed-mfa-removed", name="Duo Policy Changed: MFA Requirement Removed",
+ severity="high", mitre=["t1556"], product="duo", service="admin",
+ when={"event_type": "policy_update", "auth_required": False},
+ fp=[FP_TUNING], playbook="tpl-defense-evasion"),
+ S(slug="ident-duo-admin-added-from-self", name="Duo Admin Created Via Self-Service Activation",
+ severity="critical", mitre=["t1098"], product="duo", service="admin",
+ when={"event_type": "admin_create", "actor_eq_target": True},
+ fp=[FP_BREAK_GLASS], playbook="tpl-privilege-escalation"),
+ S(slug="ident-duo-fraud-reported", name="Duo Push Marked As Fraud By User",
+ severity="medium", mitre=["t1621"], product="duo", service="auth",
+ when={"event_type": "auth", "result": "fraud"},
+ fp=["Misclick / training"], playbook="tpl-credential-access"),
+ S(slug="ident-duo-application-bypass-policy", name="Duo Application Set To Bypass Policy",
+ severity="high", mitre=["t1556"], product="duo", service="admin",
+ when={"event_type": "integration_update", "policy_assigned": "bypass"},
+ fp=[FP_TUNING], playbook="tpl-defense-evasion"),
+ # Ping (5)
+ S(slug="ident-ping-policy-mfa-removed", name="PingOne MFA Policy Removed",
+ severity="high", mitre=["t1556"], product="ping", service="audit",
+ when={"event_type": "MFA_POLICY_DELETED"},
+ fp=[FP_TUNING], playbook="tpl-defense-evasion"),
+ S(slug="ident-ping-admin-role-burst", name="PingOne Admin Role Burst Granted",
+ severity="high", mitre=["t1098"], product="ping", service="audit",
+ when={"event_type": "ADMIN_ROLE_GRANT", "events_per_minute_gt": 5},
+ fp=["Bulk admin onboarding"], playbook="tpl-privilege-escalation"),
+ S(slug="ident-ping-pingid-device-removed", name="PingID Device Removed From Privileged User",
+ severity="high", mitre=["t1556.006"], product="ping", service="audit",
+ when={"event_type": "DEVICE_DELETED", "target_user_priv": True},
+ fp=[FP_BREAK_GLASS], playbook="tpl-defense-evasion"),
+ S(slug="ident-ping-policy-bypass-everyone", name="PingOne Policy Bypass Applied To 'Everyone'",
+ severity="high", mitre=["t1556"], product="ping", service="audit",
+ when={"event_type": "POLICY_UPDATE", "applies_to_everyone": True, "factor_required": False},
+ fp=[FP_TUNING], playbook="tpl-defense-evasion"),
+ S(slug="ident-ping-trust-store-modified", name="Ping Trust Store Certificate Added",
+ severity="medium", mitre=["t1553.004"], product="ping", service="audit",
+ when={"event_type": "TRUSTED_CERT_ADDED"},
+ fp=["Approved IdP federation"], playbook="tpl-persistence"),
+ # Keycloak / Generic OIDC (8)
+ S(slug="ident-keycloak-master-realm-user-created", name="Keycloak Master Realm User Created",
+ severity="high", mitre=["t1136"], product="keycloak", service="audit",
+ when={"event_type": "USER_CREATE", "realm": "master"},
+ fp=["Bootstrap"], playbook="tpl-persistence"),
+ S(slug="ident-keycloak-admin-realm-role-grant", name="Keycloak realm-admin Role Granted",
+ severity="high", mitre=["t1098"], product="keycloak", service="audit",
+ when={"event_type": "ROLE_ASSIGN", "role": "realm-admin"},
+ fp=["Bootstrap"], playbook="tpl-privilege-escalation"),
+ S(slug="ident-keycloak-client-secret-regen", name="Keycloak Client Secret Regenerated",
+ severity="medium", mitre=["t1098.001"], product="keycloak", service="audit",
+ when={"event_type": "CLIENT_UPDATE", "secret_changed": True},
+ fp=[FP_AUTOMATION], playbook="tpl-persistence"),
+ S(slug="ident-keycloak-impersonation-used", name="Keycloak User Impersonation Used",
+ severity="high", mitre=["t1078"], product="keycloak", service="audit",
+ when={"event_type": "IMPERSONATE"},
+ fp=[FP_FORENSIC], playbook="tpl-privilege-escalation"),
+ S(slug="ident-oidc-issuer-trust-changed", name="Generic OIDC Issuer Trust Modified",
+ severity="high", mitre=["t1556"], product="identity", service="oidc",
+ when={"event_type": "issuer.update", "discovery_url_changed": True},
+ fp=["Approved IdP migration"], playbook="tpl-defense-evasion"),
+ S(slug="ident-oidc-many-clients-from-single-actor", name="OIDC Client Burst Created By Single Actor",
+ severity="medium", mitre=["t1136"], product="identity", service="oidc",
+ when={"event_type": "client.create", "events_per_minute_per_actor_gt": 5},
+ fp=[FP_AUTOMATION], playbook="tpl-persistence"),
+ S(slug="ident-oidc-secret-leaked-pattern", name="OIDC Client Secret Logged In Plaintext",
+ severity="medium", mitre=["t1552.004"], product="identity", service="oidc",
+ when={"event_type": "log_emit", "field_contains_oidc_secret": True},
+ fp=[], playbook="tpl-credential-access"),
+ S(slug="ident-oidc-redirect-uri-wildcard", name="OIDC Client Configured With Wildcard Redirect URI",
+ severity="high", mitre=["t1539"], product="identity", service="oidc",
+ when={"event_type": "client.update", "redirect_uri_contains": "*"},
+ fp=["Approved local-dev client"], playbook="tpl-credential-access"),
+]
+
+
+# ---------------------------------------------------------------------------
+# SaaS-side identity / collaboration (20)
+# ---------------------------------------------------------------------------
+SAAS_RULES: list[dict] = [
+ S(slug="ident-google-workspace-mfa-disabled-priv", name="Google Workspace 2SV Disabled For Admin",
+ severity="critical", mitre=["t1556.006"], product="google-workspace", service="admin",
+ when={"event_name": "ENFORCE_STRONG_AUTHENTICATION", "value": False, "user_priv": True},
+ fp=[FP_BREAK_GLASS], playbook="tpl-defense-evasion"),
+ S(slug="ident-google-workspace-app-pw-issued", name="Google Workspace App Password Issued To Priv User",
+ severity="high", mitre=["t1556.006"], product="google-workspace", service="admin",
+ when={"event_name": "GENERATE_APP_PASSWORD", "user_priv": True},
+ fp=["Legacy MAPI client (must be ticketed)"], playbook="tpl-credential-access"),
+ S(slug="ident-google-workspace-3p-app-data-grant", name="Google Workspace 3rd-Party App Granted Drive Read",
+ severity="high", mitre=["t1528"], product="google-workspace", service="oauth_token",
+ when={"event_name": "AUTHORIZE", "scope_contains": "https://www.googleapis.com/auth/drive"},
+ fp=["Approved SaaS"], playbook="tpl-credential-access"),
+ S(slug="ident-google-workspace-suspicious-login-flag", name="Google Workspace Login Flagged 'Suspicious'",
+ severity="medium", mitre=["t1078"], product="google-workspace", service="login",
+ when={"event_name": "login_failure", "type": "suspicious_login"},
+ fp=["Travel"], playbook="tpl-credential-access"),
+ S(slug="ident-m365-mailbox-rule-forward-external", name="M365 Inbox Rule Forwards To External Address",
+ severity="high", mitre=["t1114.003"], product="m365", service="exchange",
+ when={"operation": "New-InboxRule", "forward_external": True},
+ fp=["Approved alias"], playbook="tpl-collection"),
+ S(slug="ident-m365-mailbox-permission-add-foreign", name="M365 Mailbox Permission Granted To External User",
+ severity="high", mitre=["t1098"], product="m365", service="exchange",
+ when={"operation": "Add-MailboxPermission", "trustee_external": True},
+ fp=["Approved partner integration"], playbook="tpl-collection"),
+ S(slug="ident-m365-app-consent-graph-mail", name="M365 App Granted Mail.Read / Mail.ReadWrite",
+ severity="high", mitre=["t1528"], product="m365", service="azure-ad",
+ when={"operation": "Consent to application", "permissions_contains_any": ["Mail.Read", "Mail.ReadWrite"]},
+ fp=["Approved SaaS integration"], playbook="tpl-credential-access"),
+ S(slug="ident-m365-sharing-policy-anyone", name="M365 SharePoint Sharing Policy 'Anyone' Enabled",
+ severity="high", mitre=["t1530"], product="m365", service="sharepoint",
+ when={"operation": "TenantSettingsModified", "sharing_capability": "ExternalUserAndGuestSharing"},
+ fp=[FP_TUNING], playbook="tpl-data-exposure"),
+ S(slug="ident-m365-tap-removed-priv", name="M365 Temporary Access Pass Generated For Priv",
+ severity="high", mitre=["t1556.006"], product="m365", service="azure-ad",
+ when={"operation": "Add temporary access pass", "target_user_priv": True},
+ fp=[FP_BREAK_GLASS], playbook="tpl-credential-access"),
+ S(slug="ident-slack-workspace-2fa-disabled", name="Slack Workspace 2FA Disabled",
+ severity="high", mitre=["t1556"], product="slack", service="admin",
+ when={"action_in": ["workspace_two_factor_required_disabled"]},
+ fp=[FP_TUNING], playbook="tpl-defense-evasion"),
+ S(slug="ident-slack-app-installed-bot-token", name="Slack App Installed With Bot Scope chat:write.public",
+ severity="medium", mitre=["t1525"], product="slack", service="audit",
+ when={"action": "app_installed", "scopes_contains": "chat:write.public"},
+ fp=["Approved bot"], playbook="tpl-persistence"),
+ S(slug="ident-slack-channel-shared-external", name="Slack Channel Shared Externally",
+ severity="high", mitre=["t1567"], product="slack", service="audit",
+ when={"action_in": ["external_shared_channel_invite_accepted", "shared_channel_external_org_added"]},
+ fp=["Approved partner channel"], playbook="tpl-exfiltration"),
+ S(slug="ident-github-org-2fa-disabled", name="GitHub Org 2FA Requirement Disabled",
+ severity="critical", mitre=["t1556"], product="github", service="audit",
+ when={"action": "org.disable_two_factor_requirement"},
+ fp=["Org transition (must be ticketed)"], playbook="tpl-defense-evasion"),
+ S(slug="ident-github-pat-classic-created-with-broad-scopes", name="GitHub Classic PAT Created With repo+workflow+admin:org",
+ severity="high", mitre=["t1098.001"], product="github", service="audit",
+ when={"action": "personal_access_token.create", "scopes_contains_all": ["repo", "workflow", "admin:org"]},
+ fp=["CI bootstrap (must be ticketed)"], playbook="tpl-persistence"),
+ S(slug="ident-github-org-collaborator-removed-bulk", name="GitHub Org Bulk Member Removed",
+ severity="medium", mitre=["t1531"], product="github", service="audit",
+ when={"action": "org.remove_member", "events_per_minute_gt": 20},
+ fp=["Approved bulk offboarding"], playbook="tpl-impact"),
+ S(slug="ident-github-deploy-key-added-org-wide", name="GitHub Deploy Key Added Across Many Repos",
+ severity="medium", mitre=["t1098.001"], product="github", service="audit",
+ when={"action": "deploy_key.add", "distinct_repos_per_actor_per_hour_gt": 10},
+ fp=[FP_AUTOMATION], playbook="tpl-persistence"),
+ S(slug="ident-zoom-passcode-disabled-meeting-policy", name="Zoom Account Policy Disables Meeting Passcode",
+ severity="medium", mitre=["t1556"], product="zoom", service="admin",
+ when={"action_in": ["update_account_settings", "update_user_settings"], "passcode_required": False},
+ fp=[FP_TUNING], playbook="tpl-defense-evasion"),
+ S(slug="ident-atlassian-org-required-2fa-off", name="Atlassian Org 2FA Requirement Removed",
+ severity="high", mitre=["t1556"], product="atlassian", service="audit",
+ when={"action_in": ["org_security_policy_modified"], "two_step_required": False},
+ fp=[FP_TUNING], playbook="tpl-defense-evasion"),
+ S(slug="ident-atlassian-api-token-created", name="Atlassian Org API Token Created",
+ severity="medium", mitre=["t1098.001"], product="atlassian", service="audit",
+ when={"action": "api_token_created"},
+ fp=[FP_AUTOMATION], playbook="tpl-persistence"),
+ S(slug="ident-jamf-mdm-policy-mfa-removed", name="MDM Policy Removed Requiring Device Compliance",
+ severity="high", mitre=["t1556"], product="mdm", service="audit",
+ when={"action": "compliance_policy_disabled"},
+ fp=[FP_TUNING], playbook="tpl-defense-evasion"),
+]
+
+
+# ---------------------------------------------------------------------------
+# Combined IDENTITY extras
+# ---------------------------------------------------------------------------
+IDENTITY_EXTRA: list[dict] = [
+ *AUTH_RULES,
+ *PRIV_RULES,
+ *KERB_RULES,
+ *IDP_RULES,
+ *SAAS_RULES,
+]
+
+
+if __name__ == "__main__":
+ print(f"Auth/MFA: {len(AUTH_RULES)}")
+ print(f"Priv events: {len(PRIV_RULES)}")
+ print(f"Kerberos: {len(KERB_RULES)}")
+ print(f"IdP admin: {len(IDP_RULES)}")
+ print(f"SaaS: {len(SAAS_RULES)}")
+ print(f"TOTAL: {len(IDENTITY_EXTRA)}")
diff --git a/scripts/detection_specs_part3_network.py b/scripts/detection_specs_part3_network.py
new file mode 100644
index 000000000..613e18046
--- /dev/null
+++ b/scripts/detection_specs_part3_network.py
@@ -0,0 +1,287 @@
+"""
+Detection Pack v1 - Part 3 / Network (50 new specs)
+===================================================
+
+Native network detection rules covering DNS, HTTP/TLS, tunnels, lateral
+movement, authentication-protocol abuse and exfiltration patterns. These
+extend the network rules in ``detection_specs.NETWORK`` (~30 stable rules).
+"""
+
+from __future__ import annotations
+
+from detection_specs_part3_helpers import ( # type: ignore[import-not-found]
+ FP_AUTOMATION,
+ FP_BACKUP,
+ FP_BREAK_GLASS,
+ FP_FORENSIC,
+ FP_PATCH,
+ FP_PENTEST,
+ FP_TUNING,
+ S,
+)
+
+
+# ---------------------------------------------------------------------------
+# DNS (12)
+# ---------------------------------------------------------------------------
+DNS_RULES: list[dict] = [
+ S(slug="net-dns-newly-registered-domain", name="DNS Query For Newly Registered Domain (NRD)",
+ severity="medium", mitre=["t1071.004"], product="dns", service="resolver",
+ when={"event_type": "dns_query", "domain_age_days_lt": 7},
+ fp=["Brand-new SaaS launch (rare; verify business need)"], playbook="tpl-command-and-control"),
+ S(slug="net-dns-idn-homoglyph", name="DNS Query For Homoglyph Of Internal Brand",
+ severity="high", mitre=["t1583.001"], product="dns", service="resolver",
+ when={"event_type": "dns_query", "homoglyph_score_gt": 0.85},
+ fp=["Authorized brand-protection scan"], playbook="tpl-initial-access"),
+ S(slug="net-dns-nxdomain-spike", name="High Volume Of NXDOMAIN Responses From Single Host",
+ severity="medium", mitre=["t1568.002"], product="dns", service="resolver",
+ when={"event_type": "dns_response", "rcode": "NXDOMAIN", "count_5min_gt": 200, "src_role": "endpoint"},
+ fp=["Malformed in-house tooling (educate)"], playbook="tpl-command-and-control"),
+ S(slug="net-dns-any-query-spike", name="DNS Query Type ANY Volume From Single Host",
+ severity="medium", mitre=["t1018"], product="dns", service="resolver",
+ when={"event_type": "dns_query", "qtype": "ANY", "count_5min_gt": 50},
+ fp=["Approved DNS audit run"], playbook="tpl-discovery"),
+ S(slug="net-dns-dga-shannon", name="DNS Query With High-Entropy Subdomain (DGA Indicator)",
+ severity="high", mitre=["t1568.002"], product="dns", service="resolver",
+ when={"event_type": "dns_query", "subdomain_entropy_gt": 4.0, "subdomain_length_gt": 16},
+ fp=["CDN with hashed hostnames (allow-listed)"], playbook="tpl-command-and-control"),
+ S(slug="net-dns-large-txt-response", name="Large DNS TXT Response (Possible C2)",
+ severity="high", mitre=["t1071.004"], product="dns", service="resolver",
+ when={"event_type": "dns_response", "qtype": "TXT", "response_size_bytes_gt": 512},
+ fp=["DKIM/SPF audit"], playbook="tpl-command-and-control"),
+ S(slug="net-dns-tunnel-pattern-len", name="DNS Tunnel Indicator: Long Hex Subdomain Sequence",
+ severity="high", mitre=["t1071.004"], product="dns", service="resolver",
+ when={"event_type": "dns_query", "subdomain_hex_ratio_gt": 0.9, "subdomain_length_gt": 30},
+ fp=["DNSSEC validation lookups"], playbook="tpl-command-and-control"),
+ S(slug="net-dns-doh-non-resolver", name="DNS-Over-HTTPS Egress To Non-Sanctioned Resolver",
+ severity="high", mitre=["t1572"], product="proxy", service="tls",
+ when={"event_type": "tls_session", "destination_port": 443, "sni_endswith_any": ["dns.adguard.com", "cloudflare-dns.com", "dns.google"], "sanctioned_doh": False},
+ fp=["Engineer with personal DoH config (educate)"], playbook="tpl-command-and-control"),
+ S(slug="net-dns-dot-non-resolver", name="DNS-Over-TLS Egress To Public IP",
+ severity="medium", mitre=["t1572"], product="proxy", service="tls",
+ when={"event_type": "tls_session", "destination_port": 853, "destination_is_internal": False},
+ fp=["Approved upstream resolver"], playbook="tpl-command-and-control"),
+ S(slug="net-dns-tor-onion", name="DNS Query For .onion Address",
+ severity="critical", mitre=["t1090.003"], product="dns", service="resolver",
+ when={"event_type": "dns_query", "domain_endswith": ".onion"},
+ fp=["Threat-intel research workstation (allow-listed)"], playbook="tpl-command-and-control"),
+ S(slug="net-dns-fast-flux", name="DNS Fast-Flux Pattern (Many A Records, Short TTL)",
+ severity="medium", mitre=["t1568.001"], product="dns", service="resolver",
+ when={"event_type": "dns_response", "answer_count_gt": 8, "ttl_seconds_lt": 60},
+ fp=["Major CDN edge"], playbook="tpl-command-and-control"),
+ S(slug="net-dns-rebinding", name="DNS Rebinding Indicator (Public→RFC1918 In Same TTL Window)",
+ severity="high", mitre=["t1090"], product="dns", service="resolver",
+ when={"event_type": "dns_response", "rebinding_detected": True},
+ fp=["IPv6 transition technologies"], playbook="tpl-initial-access"),
+]
+
+
+# ---------------------------------------------------------------------------
+# HTTP / TLS (12)
+# ---------------------------------------------------------------------------
+HTTP_TLS_RULES: list[dict] = [
+ S(slug="net-http-connect-public-ip", name="HTTP CONNECT Method Toward Public IP",
+ severity="high", mitre=["t1090"], product="proxy", service="http",
+ when={"event_type": "http_request", "method": "CONNECT", "destination_is_internal": False},
+ fp=["Sanctioned outbound proxy (allow-listed)"], playbook="tpl-command-and-control"),
+ S(slug="net-http-userag-powershell", name="HTTP User-Agent Matches PowerShell Default",
+ severity="high", mitre=["t1071.001"], product="proxy", service="http",
+ when={"event_type": "http_request", "user_agent_contains": "WindowsPowerShell"},
+ fp=[FP_AUTOMATION], playbook="tpl-command-and-control"),
+ S(slug="net-http-userag-curl-internal", name="curl/wget User-Agent From Workstation Subnet",
+ severity="medium", mitre=["t1071.001"], product="proxy", service="http",
+ when={"event_type": "http_request", "user_agent_startswith_any": ["curl/", "Wget/"], "src_role": "workstation"},
+ fp=["Engineer ad-hoc workflow"], playbook="tpl-command-and-control"),
+ S(slug="net-http-host-header-ip", name="HTTP Host Header Is IP Literal",
+ severity="medium", mitre=["t1071.001"], product="proxy", service="http",
+ when={"event_type": "http_request", "host_is_ip_literal": True},
+ fp=["Internal microservice without DNS"], playbook="tpl-command-and-control"),
+ S(slug="net-tls-old-client-version", name="TLS Client Offered TLS 1.0 Or 1.1",
+ severity="medium", mitre=["t1573.002"], product="proxy", service="tls",
+ when={"event_type": "tls_session", "client_version_in": ["TLSv1.0", "TLSv1.1"]},
+ fp=["Legacy line-of-business app (allow-listed)"], playbook="tpl-defense-evasion"),
+ S(slug="net-tls-no-sni", name="HTTPS Connection To IP Without SNI",
+ severity="medium", mitre=["t1573.002"], product="proxy", service="tls",
+ when={"event_type": "tls_session", "sni_present": False, "destination_is_internal": False},
+ fp=["IoT device with broken TLS stack"], playbook="tpl-command-and-control"),
+ S(slug="net-tls-self-signed-egress", name="Self-Signed Certificate Presented On Public IP",
+ severity="high", mitre=["t1573.002"], product="proxy", service="tls",
+ when={"event_type": "tls_session", "cert_self_signed": True, "destination_is_internal": False},
+ fp=["Misconfigured small SaaS vendor"], playbook="tpl-command-and-control"),
+ S(slug="net-tls-suspicious-cipher", name="TLS Negotiated Weak Cipher Suite",
+ severity="medium", mitre=["t1600.001"], product="proxy", service="tls",
+ when={"event_type": "tls_session", "negotiated_cipher_contains_any": ["NULL", "EXPORT", "RC4", "DES"]},
+ fp=["Legacy device support"], playbook="tpl-defense-evasion"),
+ S(slug="net-jarm-cobalt-strike", name="JARM Fingerprint Matches Known Cobalt Strike Profile",
+ severity="critical", mitre=["t1573.002"], product="proxy", service="tls",
+ when={"event_type": "tls_session", "jarm_in": ["07d14d16d21d21d07c42d41d00041d24a458a375eef0c576d23a7bab9a9fb1", "07d19d12d21d21d00042d43d00043d4f51b7c8b9af6b1c7c2a3d4e5f6a7b8c9"]},
+ fp=[FP_PENTEST], playbook="tpl-command-and-control"),
+ S(slug="net-jarm-sliver", name="JARM Fingerprint Matches Known Sliver Profile",
+ severity="critical", mitre=["t1573.002"], product="proxy", service="tls",
+ when={"event_type": "tls_session", "jarm_in": ["3fd3fd0003fd3fd03fd3fd3fd3fd3fd3a458a375eef0c576d23a7bab9a9fb1"]},
+ fp=[FP_PENTEST], playbook="tpl-command-and-control"),
+ S(slug="net-http-gzip-mime-mismatch", name="HTTP Response MIME And Content-Encoding Mismatch",
+ severity="medium", mitre=["t1027"], product="proxy", service="http",
+ when={"event_type": "http_response", "mime_type_in": ["application/octet-stream"], "content_encoding": "gzip", "filename_endswith_any": [".jpg", ".png", ".gif"]},
+ fp=["Misconfigured CDN"], playbook="tpl-command-and-control"),
+ S(slug="net-http-large-post-from-workstation", name="Large HTTP POST From Workstation To Public IP",
+ severity="medium", mitre=["t1041"], product="proxy", service="http",
+ when={"event_type": "http_request", "method": "POST", "request_size_bytes_gt": 50000000, "src_role": "workstation", "destination_is_internal": False},
+ fp=["Sanctioned cloud upload"], playbook="tpl-exfiltration"),
+]
+
+
+# ---------------------------------------------------------------------------
+# Tunnels / proxy (8)
+# ---------------------------------------------------------------------------
+TUNNEL_RULES: list[dict] = [
+ S(slug="net-ssh-reverse-tunnel", name="Outbound SSH With -R Reverse-Tunnel Flag",
+ severity="high", mitre=["t1572"], product="proxy", service="ssh",
+ when={"event_type": "ssh_command", "argv_contains": "-R"},
+ fp=["Engineer working with vendor"], playbook="tpl-command-and-control"),
+ S(slug="net-tor-egress-corp", name="Tor Connection From Corporate Workstation",
+ severity="high", mitre=["t1090.003"], product="proxy", service="tls",
+ when={"event_type": "tls_session", "destination_in_known_tor_relay": True, "src_role": "workstation"},
+ fp=["Threat-intel research workstation"], playbook="tpl-command-and-control"),
+ S(slug="net-icmp-large-payload", name="ICMP Echo With Unusually Large Payload",
+ severity="medium", mitre=["t1095"], product="proxy", service="icmp",
+ when={"event_type": "icmp", "payload_size_bytes_gt": 1024},
+ fp=["MTU diagnostic"], playbook="tpl-command-and-control"),
+ S(slug="net-gre-from-non-network-device", name="GRE Tunnel Initiated By Non-Network Host",
+ severity="medium", mitre=["t1572"], product="proxy", service="netflow",
+ when={"event_type": "flow", "protocol_number": 47, "src_role_in": ["workstation", "server"]},
+ fp=["Approved overlay agent"], playbook="tpl-command-and-control"),
+ S(slug="net-wireguard-handshake-from-user", name="WireGuard Handshake From User Workstation",
+ severity="medium", mitre=["t1572"], product="proxy", service="netflow",
+ when={"event_type": "flow", "destination_port": 51820, "src_role": "workstation"},
+ fp=["Approved corporate VPN tier"], playbook="tpl-command-and-control"),
+ S(slug="net-vpn-from-datacenter", name="Corporate VPN Login Originating From Datacenter ASN",
+ severity="medium", mitre=["t1078.004"], product="vpn", service="auth",
+ when={"event_type": "vpn_auth", "src_asn_type": "hosting"},
+ fp=["Mobile carrier identified as hosting (false positive)"], playbook="tpl-credential-access"),
+ S(slug="net-tor-introduction-onion", name="Tor Introduction To Hidden Service From Corp Host",
+ severity="critical", mitre=["t1090.003"], product="proxy", service="tls",
+ when={"event_type": "tor_circuit_intro", "circuit_purpose": "HS_CLIENT_INTRO"},
+ fp=[FP_PENTEST], playbook="tpl-command-and-control"),
+ S(slug="net-cloudflared-tunnel-egress", name="Cloudflared Tunnel Started From Workstation",
+ severity="medium", mitre=["t1572"], product="proxy", service="netflow",
+ when={"event_type": "tls_session", "sni_endswith_any": ["argotunnel.com", "tcp.cfargotunnel.com"], "src_role": "workstation"},
+ fp=["Authorized engineering tunnel"], playbook="tpl-command-and-control"),
+]
+
+
+# ---------------------------------------------------------------------------
+# Lateral / SMB / RPC (10)
+# ---------------------------------------------------------------------------
+LATERAL_RULES: list[dict] = [
+ S(slug="net-smbv1-egress", name="SMB Version 1 Negotiated In Network Flow",
+ severity="high", mitre=["t1021.002"], product="firewall", service="netflow",
+ when={"event_type": "smb_negotiate", "dialect": "SMB 1.0"},
+ fp=["Legacy printer / NAS (allow-listed)"], playbook="tpl-defense-evasion"),
+ S(slug="net-smb-write-netlogon", name="SMB Write To NETLOGON Share",
+ severity="critical", mitre=["t1570"], product="firewall", service="netflow",
+ when={"event_type": "smb_write", "share_name": "NETLOGON"},
+ fp=["AD admin GPO push from PAW"], playbook="tpl-lateral-movement"),
+ S(slug="net-smb-write-sysvol", name="SMB Write To SYSVOL Share From Non-DC",
+ severity="high", mitre=["t1570"], product="firewall", service="netflow",
+ when={"event_type": "smb_write", "share_name": "SYSVOL", "src_role_neq": "domain-controller"},
+ fp=["Authorised AD migration tool"], playbook="tpl-lateral-movement"),
+ S(slug="net-ntlm-relay-pattern", name="NTLM Relay Indicator (Same Challenge Reused Across Hosts)",
+ severity="critical", mitre=["t1557.001"], product="firewall", service="netflow",
+ when={"event_type": "ntlm_auth", "challenge_reused_across_hosts": True},
+ fp=["NTLM relay tested in lab"], playbook="tpl-credential-access"),
+ S(slug="net-rpc-remote-registry", name="RPC Remote Registry Write From Workstation Subnet",
+ severity="high", mitre=["t1112"], product="firewall", service="rpc",
+ when={"event_type": "rpc_call", "interface": "winreg", "operation": "BaseRegSetValue", "src_role": "workstation"},
+ fp=["IT remote support tool"], playbook="tpl-lateral-movement"),
+ S(slug="net-rpc-task-scheduler-remote", name="RPC Task Scheduler Create From Workstation",
+ severity="high", mitre=["t1053.005"], product="firewall", service="rpc",
+ when={"event_type": "rpc_call", "interface": "atsvc", "src_role": "workstation"},
+ fp=["IT remote support tool"], playbook="tpl-persistence"),
+ S(slug="net-winrm-ssl-from-workstation", name="WinRM HTTPS From Workstation To DC",
+ severity="high", mitre=["t1021.006"], product="firewall", service="netflow",
+ when={"event_type": "flow", "destination_port_in": [5985, 5986], "src_role": "workstation", "destination_role": "domain-controller"},
+ fp=["Authorised AD admin from PAW"], playbook="tpl-lateral-movement"),
+ S(slug="net-cobalt-strike-named-pipe", name="Cobalt Strike Default Named Pipe Pattern",
+ severity="critical", mitre=["t1573.002"], product="firewall", service="netflow",
+ when={"event_type": "smb_pipe", "pipe_name_in": ["msagent_", "MSSE-", "postex_", "status_"]},
+ fp=[FP_PENTEST], playbook="tpl-command-and-control"),
+ S(slug="net-sliver-named-pipe", name="Sliver Default Named Pipe Pattern",
+ severity="critical", mitre=["t1573"], product="firewall", service="netflow",
+ when={"event_type": "smb_pipe", "pipe_name_startswith": "sliver_"},
+ fp=[FP_PENTEST], playbook="tpl-command-and-control"),
+ S(slug="net-empire-default-uri", name="Empire C2 Default URI Pattern Observed",
+ severity="critical", mitre=["t1071.001"], product="proxy", service="http",
+ when={"event_type": "http_request", "uri_endswith_any": ["/admin/get.php", "/news.php", "/login/process.php"]},
+ fp=[FP_PENTEST], playbook="tpl-command-and-control"),
+]
+
+
+# ---------------------------------------------------------------------------
+# Auth / protocol abuse (5)
+# ---------------------------------------------------------------------------
+AUTH_RULES: list[dict] = [
+ S(slug="net-kerberos-rc4-ticket", name="Kerberos Service Ticket Issued With RC4 Encryption",
+ severity="high", mitre=["t1558.003"], product="windows", service="kerberos",
+ when={"event_id": 4769, "ticket_encryption_type": "0x17"},
+ fp=["Legacy app forced RC4 (allow-listed)"], playbook="tpl-credential-access"),
+ S(slug="net-kerberos-pre-auth-disabled", name="Kerberos Account With Pre-Auth Disabled Used",
+ severity="high", mitre=["t1558.004"], product="windows", service="kerberos",
+ when={"event_id": 4768, "preauth_required": False},
+ fp=["Legacy SCM service account (must be ticketed)"], playbook="tpl-credential-access"),
+ S(slug="net-radius-pap-clear", name="RADIUS Authentication Used PAP (Cleartext Password)",
+ severity="high", mitre=["t1110"], product="radius", service="auth",
+ when={"event_type": "radius_auth", "auth_method": "PAP"},
+ fp=["Legacy device that only supports PAP (must be ticketed)"], playbook="tpl-credential-access"),
+ S(slug="net-ldap-signing-disabled", name="LDAP Signing Disabled On Domain Controller",
+ severity="high", mitre=["t1557.001"], product="windows", service="ldap",
+ when={"event_id": 2889, "ldap_signing_required": False},
+ fp=["Vendor agent that doesn't sign (deprecated)"], playbook="tpl-credential-access"),
+ S(slug="net-ldap-bloodhound-pattern", name="LDAP Search Pattern Matches BloodHound Collection",
+ severity="high", mitre=["t1087.002"], product="windows", service="ldap",
+ when={"event_type": "ldap_search", "filter_contains_any": ["objectCategory=group", "objectClass=user", "trustedDomain"], "search_count_5min_gt": 100},
+ fp=[FP_PENTEST], playbook="tpl-discovery"),
+]
+
+
+# ---------------------------------------------------------------------------
+# Exfil / wireless / misc (3)
+# ---------------------------------------------------------------------------
+EXFIL_WIRELESS_RULES: list[dict] = [
+ S(slug="net-icmp-high-entropy-payload", name="ICMP Echo With High-Entropy Payload",
+ severity="high", mitre=["t1095"], product="firewall", service="netflow",
+ when={"event_type": "icmp", "payload_entropy_gt": 7.5, "payload_size_bytes_gt": 64},
+ fp=["MTU diagnostic"], playbook="tpl-exfiltration"),
+ S(slug="net-dhcp-starvation", name="DHCP Starvation: Rapid Lease Churn From Single MAC Range",
+ severity="high", mitre=["t1498"], product="firewall", service="dhcp",
+ when={"event_type": "dhcp", "leases_per_minute_per_relay_gt": 200},
+ fp=["Conference / event Wi-Fi"], playbook="tpl-impact"),
+ S(slug="net-stp-topology-change-from-edge", name="STP Topology Change Advertised By Edge Port",
+ severity="medium", mitre=["t1498"], product="switch", service="stp",
+ when={"event_type": "stp_tcn", "ingress_port_role": "edge"},
+ fp=["Approved network change"], playbook="tpl-impact"),
+]
+
+
+# ---------------------------------------------------------------------------
+# Aggregate
+# ---------------------------------------------------------------------------
+NETWORK_EXTRA: list[dict] = (
+ DNS_RULES
+ + HTTP_TLS_RULES
+ + TUNNEL_RULES
+ + LATERAL_RULES
+ + AUTH_RULES
+ + EXFIL_WIRELESS_RULES
+)
+
+
+__all__ = [
+ "NETWORK_EXTRA",
+ "DNS_RULES",
+ "HTTP_TLS_RULES",
+ "TUNNEL_RULES",
+ "LATERAL_RULES",
+ "AUTH_RULES",
+ "EXFIL_WIRELESS_RULES",
+]