Live detections from your audit logs¶
With a live detection feed, untrust reads your cloud audit events as they arrive and runs the
detection rules on each one. A detection is recorded minutes
after the event, with no scheduled untrust detect run. You set up the feed once per
connection; after that, events flow continuously.
Live detection feeds work on two kinds of connection:
| Cloud | What untrust reads | Where it reads it |
|---|---|---|
| AWS | Your CloudTrail trail's log files | A queue in your account that CloudTrail notifies for each new log file |
| Azure (early access) | Your subscription's Activity Log | An Event Hub in your subscription that a diagnostic setting sends the log to |
Google Cloud connections don't offer a feed yet. Run untrust detect there.
Before you start¶
- Server scans must be on. The feed needs server scans turned on, with a verified scan grant, for the same connection: the feed's heartbeat comes from the scan. See Scan cloud accounts from the console.
- Only administrators can set up, turn on and turn off a feed.
The feed lives on the connection: Environments › Cloud accounts, in the connection's Live detection feed panel, under its Server scan panel. You can configure a feed at any time, but Turn on feed appears only once server scans are on.
AWS: the CloudTrail feed¶
How it works¶
- Your trail writes log files to its S3 bucket, as it already does.
- The trail sends a notification for each new log file to an SNS topic, which delivers it to an SQS queue in your account. If the trail already notifies a topic, the queue subscribes to that one and the trail is left as it is.
- untrust reads the queue with a read-only role you create,
UntrustEventReader. It then reads each log file and runs every detection rule on each event. - Matches become detections in the console and go to your alert destinations straight away.
Latency is CloudTrail's own delivery time to S3.
What the reader role can read¶
The reader role can read your whole trail while the feed is on
An organization trail holds the management events of every account in the organization, and data events if you log them. While the feed is on, the reader role can read all of it, not only the events the rules need.
- It's separate from the scan role. A separate untrust role assumes it, in sessions named
untrust-feed-*, with your connection's external ID. - It can't write. An explicit Deny refuses S3 writes and deletes, sending to, purging or changing the queue, and KMS encryption.
- It can read only:
- the trail's log files under its prefix (
s3:GetObject). An explicit Deny refuses every other object; - your queue (
sqs:ReceiveMessage,sqs:DeleteMessage,sqs:GetQueueAttributesandsqs:ChangeMessageVisibility), and the depth of its dead-letter queue; - if the trail is encrypted with KMS, decryption of that trail's logs only, and only through S3.
- the trail's log files under its prefix (
- Your queue holds the backlog. The queue lives in your account and keeps messages for 14 days. If untrust falls behind, nothing is lost. A message that fails 5 times moves to the dead-letter queue, and the feed reads degraded.
Hosted connection grants lists every action the stack grants and denies.
Set it up¶
Deploy the reader stack in the connected account, in the trail's home region. The queue and the reader role must be in the connection's own account; the trail bucket and its key can be elsewhere.
- On the connection's Live detection feed panel, choose Configure feed. The panel
names the template,
aws-event-reader.cfn.json, and untrust's feed broker role. - Deploy
aws-event-reader.cfn.jsonwith CloudFormation. You give it:- your connection's external ID and untrust's feed broker role, as the panel shows them;
- the trail ARN, its bucket and its log prefix. The prefix must end in
AWSLogs/(optionallyAWSLogs/<organization id>/) and can't contain wildcards; - the trail's KMS key ARN, if the trail uses SSE-KMS;
- the SNS topic the trail already notifies, if it has one.
The stack creates the UntrustEventReader role, the untrust-cloudtrail-feed queue and
its dead-letter queue, and, unless you named an existing topic, an SNS topic for the
trail's notifications.
3. If the stack created the topic, run the command from its PointTheTrailAtTheTopic output
once. It points the trail at the topic, and refuses to replace a topic the trail already
notifies. If the bucket or the key is in another account, add the statement from the
stack's BucketPolicyStatementIfBucketIsElsewhere or KeyPolicyStatementIfKeyIsElsewhere
output to that bucket's or key's policy.
4. Back on the panel, enter Queue URL (the stack's QueueUrl output), Trail bucket,
Trail key prefix and Reader role (the stack's RoleArn output). Choose
Save feed.
5. Choose Turn on feed.
The heartbeat¶
A quiet trail could mean nothing happened, or that the trail stopped. To tell the two apart,
untrust looks for its own server scan in the feed. A server scan of the connection reads the
trail's status (cloudtrail:GetTrailStatus) in its untrust-scan-<job id> session. When that
call arrives through the feed, matched to a scan job this connection ran, the panel's
Heartbeat reads scan canary received. Until then it reads no scan canary yet.
An AWS feed reads stale when no event or no heartbeat has arrived for 2 hours. The heartbeat comes only from server scans, so keep Hours between server scans at 1 or 2 for the feed to stay healthy between scans.
Azure: the Event Hub feed¶
Early access
The Azure Event Hub feed is in early access.
How it works¶
A diagnostic setting on your subscription sends the Activity Log to an Event Hub in that subscription. untrust listens to the hub with a second app registration you create, separate from the scan app, and runs every detection rule on each event.
What you create¶
There is no template. You create these in the connection's subscription:
| What | Details |
|---|---|
| Event Hubs namespace and hub | In the connection's own subscription. A hub in another subscription is refused. |
| Consumer group | untrust, a group nothing else reads (Standard tier or higher). On the Basic tier, $Default, and nothing else may read it: another reader would take events that are then never evaluated. |
| Feed app | A second single-tenant app registration with no secrets or certificates. It must not be the scan app. |
| Federated credential on the feed app | It trusts only your connection's untrust feed delegate, a different delegate from the scan's. |
| Role assignment | Azure Event Hubs Data Receiver for the feed app, on the hub only. It can receive from that hub and nothing else: no send, no manage, no other hub. |
| Diagnostic setting | On the subscription, sending the Activity Log's Administrative category to the hub. Optionally, send the gated Key Vault's AuditEvent logs to the same hub, so key deletes, purges and release-policy changes are detected too. |
untrust requests a token for Event Hubs only and uses each for at most 15 minutes. Hosted connection grants has the full grant.
Set it up¶
- On the connection's Live detection feed panel, choose Configure feed.
- Enter the Event Hubs namespace resource ID, the Event Hub and the Feed app client ID, and pick the Consumer group. Choose Save feed.
- Choose Turn on feed.
The heartbeat¶
Each server scan checks that the subscription's diagnostic setting still sends the Activity Log to this hub. When it does, the panel's Heartbeat reads route verified, delivery unproven: the route is proven, but that doesn't prove every event arrives. Until a scan has checked it, the heartbeat reads route not verified.
An Azure feed reads stale when no event or no route check has arrived for 8 hours. The default 6-hour server scan schedule fits inside that window.
Feed health¶
A quiet feed is never treated as good news. When the feed is on, the panel shows one state, checked in this order:
| State | Meaning |
|---|---|
| down | The queue or hub couldn't be reached. |
| missing-permission | The reader role or the feed app was refused. |
| stale | No event arrived within the window (2 hours on AWS, 8 hours on Azure). The trail or diagnostic setting may have stopped. |
| heartbeat-unavailable | Events arrive, but server scans are off, so no heartbeat can be produced. |
| stale | Events arrive, but no heartbeat arrived within the window. |
| degraded | In the last 24 hours, some events weren't evaluated: log files were skipped (over a size limit, or unreadable) or dead-lettered, events were rejected, or a rule failed on one. |
| lagging | The backlog is more than an hour behind. Nothing is lost: an AWS queue keeps 14 days of messages. |
| healthy | An event and a heartbeat both arrived within the window, nothing went unevaluated in the last 24 hours, and the backlog is less than an hour behind. |
An event or heartbeat stamped more than a minute in the future isn't trusted, so a skewed or planted timestamp can't keep a feed healthy.
The panel also shows Last event, Lag, and, when they apply, Last error, Not evaluated (events skipped in the last 24 hours) and Dropped (events for accounts or subscriptions without a connection).
How each event is evaluated¶
- Only against its own account. An event is evaluated only against the connection whose verified account or subscription matches the event's. An event for an account or subscription you haven't connected is dropped and counted, never stored or evaluated.
- Nothing is dropped silently. Every event is either evaluated or rejected with a reason: malformed, unsupported, or no matching connection. If a rule fails on an event, the other rules still run, and the failure counts toward degraded.
- One event, one detection. A redelivered event finds its existing detection instead of
creating another. A detection from
untrust detector an upload is recorded separately, so an event both paths see can appear twice. - Raw events are never stored. Each event exists in memory only while it's checked. Only the fields a detection keeps as evidence are saved.
- Bursts don't flood your alerts. Each organization gets at most 50 individual critical alerts an hour from live feeds; after that, one summary alert says more were recorded. Every detection is still recorded.
Cost¶
The queue, topic, Event Hub and diagnostic setting run in your account, and your cloud provider bills them to you as usual: on AWS, S3 reads of the log files and SQS requests; on Azure, the Event Hubs namespace. untrust adds no other resources.
Turn it off¶
- Pause: choose Turn off on the Live detection feed panel. untrust stops reading.
- Change the trail or hub: Change trail or Change hub saves a new configuration and turns the feed off until you turn it on again.
- Revoke on AWS: delete the
UntrustEventReaderrole or the reader stack. If you pointed the trail at a new topic, you can remove that too. - Revoke on Azure: delete the feed app's role assignment or federated credential, or the diagnostic setting. A token already issued is used for at most 15 minutes.
Revoking needs nothing from untrust. Turning a feed off or revoking it doesn't change your trail or delete any detections already recorded. Your organization's audit log records each feed configuration change and each time a feed is turned on or off.