Box 'Abnormal user activity' rule (1139230c) can never raise an alert

オープン 初心者向け
#15,664 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 2 日以内に返信

まだ誰も着手していません。

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
70/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
yaml
領域
security

調査の方向性

query: ブロックを Solutions/Box/Analytic Rules/BoxAbnormalUserActivity.yaml(id 1139230c)内で読み、列挙されている 4 つの不具合と比較してください。issue で提案されている KQL は、14 日間のベースラインを持つ SrcUserUpn をキーにしたドロップイン置換です。レポートの合成 BoxEvents スニペットを再生して、バースト ユーザーが返され、安定して高負荷のユーザーは返されないことを確認してください。完了とは、更新されたルールがリポジトリの KQL 検証と検出スキーマのチェックをローカルで通過することです。報告者が PR を開くことを申し出ているので、開始前にその人と確認してください。

索引モデルが issue の本文から書いたものです。

説明

Describe the bug

The analytic rule Solutions/Box/Analytic Rules/BoxAbnormalUserActivity.yaml (id 1139230c-cf10-45db-b616-fed0d1415c05) can't raise an alert on any data:

  • The baseline counts rows after the union (1 or 2 per user) instead of adding up events, then divides by 29 using whole numbers. The daily average is always 0, so where EventsPerDay > TotalEventsH is never true.
  • The "last hour" parts have no time filter, so they count all 14 days. Both use SourceName, which is the file or folder acted on, not the user.
  • join ... on k with k = 1 on every row keeps only one user from the left side.
  • The comparison points the wrong way. With the counting fixed, it would alert on users who are quieter than usual, not on spikes.

To Reproduce

Paste this in front of the rule query in Log Analytics. It's one user with one event an hour for two weeks, then 500 events in the last hour. The rule returns nothing.

let BoxEvents = union
    (range h from 2 to 335 step 1
     | project EventEndTime = ago(1h * h), SrcUserName = 'Alice', SrcUserUpn = '[email protected]', SourceName = 'Roadmap.docx'),
    (range i from 1 to 500 step 1
     | project EventEndTime = ago(1m * (i % 50)), SrcUserName = 'Alice', SrcUserUpn = '[email protected]', SourceName = strcat('export-', i, '.csv'));

Expected behavior

An alert when a user's activity in the last hour is far above their usual level.

Suggested fix

This version compares each user's events in the last hour with their average over the previous 14 days, counting only hours in which they were active. It alerts when the last hour has at least 50 events and is more than three standard deviations above that average. It identifies the account by login rather than display name.

let lookback = 14d;
let recent = 1h;
let min_events = 50;
let baseline = BoxEvents
| where EventEndTime between (ago(lookback) .. ago(recent))
| where isnotempty(SrcUserUpn)
| summarize Events = count() by SrcUserUpn, bin(EventEndTime, 1h)
| summarize BaseAvg = avg(Events), BaseStdev = stdev(Events) by SrcUserUpn;
BoxEvents
| where EventEndTime > ago(recent)
| where isnotempty(SrcUserUpn)
| summarize EventsLastHour = count(), SrcUserName = take_any(SrcUserName) by SrcUserUpn
| join kind=leftouter baseline on SrcUserUpn
| extend BaseAvg = coalesce(BaseAvg, 0.0), BaseStdev = coalesce(BaseStdev, 0.0)
| where EventsLastHour >= min_events and EventsLastHour > BaseAvg + 3 * BaseStdev
| extend AccountName = tostring(split(SrcUserUpn, '@')[0]), UPNSuffix = tostring(split(SrcUserUpn, '@')[1])
| project SrcUserUpn, SrcUserName, AccountName, UPNSuffix, EventsLastHour, AvgEventsActiveHour = round(BaseAvg, 2)

I don't have a Sentinel workspace with Box data, so I tested it on the Kusto emulator with the solution's BoxEvents parser, using synthetic events:

  • With the snippet above, it returns the user.
  • A user with a normal baseline who downloads 500 files in an hour gets an alert.
  • Three heavy users (40 to 200 events an hour, varying between half and one and a half times their usual rate), replayed at each hourly run over a week, got no alerts, both with a full 14 days of history and with less.
  • It gives the same results whether the data is in BoxEventsV2_CL, BoxEvents_CL, or both.
  • It passes the repo's KQL validation, detection schema and non-ASCII checks locally.

Expect some alerts for legitimate bulk activity: a first Box Drive sync, migrations, integration or service accounts, and new users with no history. The thresholds are a best guess without real Box data.

Happy to open a PR with this change if that would help.

主要言語
HTML
スター
6.3k
フォーク
3.9k
平均マージ
2日 10時間
マージ済み PR(30日)
190

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

Azure/Azure-Sentinel のほかの issue

Azure/Azure-Sentinel の issue をすべて見る

似ている issue

Security の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。