File Nº 0x6D / Subject: m0rgxn
Local --:--:--
← All notesExhibit N · Filed 16 Nov 2026 · Azure Security · 27 min read

Building Huginn: Detection Rules That Have to Prove Themselves Every Night

Filed

The problem, the decisions, the pipelines and the bugs, explained simply


Exhibit N — cover
Everything here runs in my own lab subscription, against resources created for this purpose. Fenrir is an authorized assessment tool that I only run in isolated lab tenants, and the nightly tests in this post never run Fenrir at all. They perform harmless look-alike actions and throw the results away.
A few months ago I wrote Fenrir, a tool that automates the Azure managed-identity attack path. It signs in, maps the tenant, steals a managed identity's token through a host it controls, and then acts as that identity.
Fenrir in one picture: authenticate, enumerate, exploit, post-exploit, each phase talking to a different part of Azure
After building the attack, the obvious next question was the defender's one: would anyone notice? The usual answer is a detection rule. In Microsoft Sentinel, that is a query that runs on a schedule over your logs and raises an alert when it finds something. Writing one in the portal is quick. The trouble starts after that:
  • Nobody knows if the rule actually fires on the real attack. It was written from documentation and never tried.
  • Nobody knows if it still fires next month. Someone edits it in the portal, a log field changes, a licence expires, and the rule quietly stops working. A broken rule looks exactly like a quiet night.
  • There is no history. No review, no diff, no way to tell who changed what.
We solved this for normal software a long time ago. Code lives in git, every change is reviewed, and tests run on every push. A detection rule is code too, but most are treated like settings in a web page. Huginn is my attempt to treat detections the way we treat software. The whole project comes down to one promise:
For every step Fenrir takes that Azure writes to a log, there is a rule in git, and every night a job performs that step for real and fails the build if the alert does not show up.
The name comes from Norse mythology, like Fenrir. Fenrir is the wolf. Huginn is one of Odin's two ravens, who fly out every day and report back what they saw.
Huginn in Azure: GitHub Actions signs in as a lab attacker, acts on lab resources, the Activity log flows to Log Analytics, and Sentinel raises alerts that the workflow reads back
Follow the blue path. A GitHub Actions job signs in to Azure as a dedicated "lab attacker" identity. It performs a harmless version of something Fenrir does, for example listing the keys of a storage account. Azure records that action in the subscription's Activity log. The log flows into a Log Analytics workspace, where Sentinel's rules run every five minutes. The same workflow then waits and checks that the right alert appeared. If the alert shows up, the rule is proven for tonight. If it does not, the build goes red and I know before an attacker does. The rest of this post is how each piece of that loop was built, and why. I did not start with rules. I started by reading Fenrir's source code and listing every single request it makes to Azure. That came to 66 operations, each with an ID: A- for authentication, E- for enumeration, X- for exploitation, P- for post-exploitation. Then for each one I asked a simple question: does this leave a row in any log? The answer was humbling. Out of 66 operations, only six appear in AzureActivity, the free log every subscription has:
  • X-08: running a command on a VM (Run Command)
  • X-10: listing an App Service's publishing credentials
  • X-13: listing a Logic App's callback URL
  • X-14: opening a shell in a container (exec)
  • P-12: listing a storage account's keys
  • P-13: listing a container registry's admin credentials
The reason is one rule of Azure logging that shapes this whole project: the Activity log records writes and actions, never reads. Fenrir's entire reconnaissance phase is read requests, so it leaves no trace there at all. That gave me the blind spots, and I decided to put them at the top of the README instead of hiding them:
  • Reads are invisible. All of fenrir enumerate produces zero rows.
  • Directory reconnaissance needs a paid licence. Microsoft Graph activity logs require Entra ID P1 or P2. My student tenant has neither.
  • The log says a command ran, not which command. After a Run Command, the command text is not recorded.
I think this is the most important decision in the project, and it is not a technical one. A detection project that only lists what it catches gives defenders false confidence. Knowing exactly where you are blind is worth as much as the rules themselves. My first drafts of the rules were written from Microsoft's documentation. They were full of comments saying "verify in lab", because documentation tells you what a log row should look like, not what it does look like. So before deploying any rule, I built a small workflow whose only job is to collect the truth.
evidence.yml: perform each chosen operation once as the lab attacker, then capture and redact the resulting rows
evidence.yml is started by hand with a list of operations, for example X-13,P-12. It performs each one once as the lab attacker. A few minutes later, a script reads the rows that landed in the workspace, removes anything sensitive, and saves one JSON file per operation in lab-evidence/. Those files are committed. The raw rows never are. Each rule is then written against a real row. The evidence corrected several things I had assumed:
  • For a service principal, the Caller field holds the object ID, not the app ID. A rule that compared it against an app ID would never match.
  • The status values in the workspace are Start, Success and Failure. The raw Activity log API says Started, Succeeded and Failed for the same events.
  • One Run Command call does not create one row. It creates three (Start, Accept, Success), and they arrive minutes apart. This mattered a lot later.
  • Rows arrive 3 to 10 minutes after the action. That number decides how long the test must wait before calling a rule broken.
One small design detail here: the ops input has no default value. An early run was meant to capture X-08 but silently ran the default list instead. Now you have to type what you want every time. Every rule is a folder with the same four files:
Text
detections/core/storage-keys-listed/
  rule.kql      the query
  rule.yaml     the settings: schedule, severity, entities, MITRE, status
  README.md     what it catches, known false positives, validation log
  replay.sh     the harmless action that must trigger it
The rule.yaml is short and readable:
Text
id: storage-keys-listed
name: "Huginn - Storage account keys listed in a suspicious pattern"
tier: core
fenrir_ops: [P-12]
status: validated
validation: ci
deployable: true
frequency: PT5M
lookback: P1DT23H
alert_name_format: "Huginn: storage account keys listed by {{Caller}}"
mitre:
  tactics: [CredentialAccess]
  techniques: [T1552]
Two fields carry the honesty of the project. fenrir_ops ties the rule to the exact attacker operations it covers. status can only say validated after a lab run produced the alert, with the run recorded in a status file. Until then it says draft, and the query file itself starts with the line "Draft, not yet validated." Terraform is the tool that describes cloud resources in files and makes Azure match them. Instead of writing one Terraform block per rule, a small loop discovers every rule folder:
Text
rules_all = {
  for f in fileset(local.detections_dir, "*/*/rule.yaml") :
  yamldecode(file("${local.detections_dir}/${f}")).id => merge(
    yamldecode(file("${local.detections_dir}/${f}")),
    { dir = dirname(f) }
  )
}

rules = {
  for id, r in local.rules_all : id => r
  if r.deployable && contains(var.enabled_rules, id)
}
In plain words: find every rule.yaml, read it, and deploy the ones that are marked deployable and listed as enabled. Adding a new detection means adding a folder. Nobody touches Terraform.
Four Huginn rules enabled in Defender, all deployed from git
Two smaller choices are worth explaining:
  • Stable IDs. Each rule's ID in Sentinel is a GUID computed from the rule's name in git. Renaming the display title never deletes and recreates the rule. This once saved me: I renamed the repository, and because the seed text was frozen, not a single rule was touched.
  • Traceability. The description of each deployed rule links back to its folder in git, so an analyst looking at an alert can find the source and its documentation.
Rule details in Sentinel: the description links back to the source folder
One consequence is intentional: if someone edits a rule in the portal, the next Terraform apply overwrites it. Git is the only source of truth. Bicep is Microsoft's own tool for this, and it has no state file to look after, which is attractive. I still chose Terraform, for three reasons:
  1. Huginn needs both Azure resources and Entra ID objects (app registrations with federated credentials). Terraform does both in one tool. Bicep needs extensions or scripts for the second part.
  2. The folder-discovery loop above is natural in Terraform.
  3. terraform plan shows exactly what would change before anything changes. That fits my rule of never touching Azure without reading the diff first, and it later became a test of its own.
The cost is that Terraform keeps a state file that must be stored and protected. More on that below. Every rule needs the same boring preparation: find the caller's real ID, work out whether the caller is a user, a service principal or a managed identity, check whether the action was part of a deployment, and check whether it is approved automation. Rather than copy that into fourteen queries, it lives once in a saved workspace function called HuginnActivity. Each rule calls it with the operations it cares about. When lab evidence shows that a field behaves differently than expected, I fix one file and every rule benefits. Every detection needs some way to ignore legitimate activity, otherwise analysts drown. The tempting shortcut is to exclude trusted tools: "ignore anything done by the Azure CLI or the portal". That shortcut would make Huginn useless. Fenrir signs in using the Azure CLI's own public client ID by default. To the log, Fenrir and a real admin typing az commands look like the same application. Excluding the CLI would exclude the attacker. So Huginn excludes identities, never tools. Exclusions live in a Sentinel watchlist where each row is a narrow triple:
  • who (one principal's object ID),
  • where (a resource scope prefix),
  • what (one operation),
plus an owner, a reason and an expiry date. Expired rows stop working by themselves. A static test rejects any row that tries to exclude a whole application. The lab proved the need for this on day one. Terraform itself reads storage keys when it refreshes its state, so the very first run of my storage rule flagged me, running Terraform on my laptop. That is a real false positive, the kind every company has. One narrow watchlist row (me, on Huginn's own resource groups, for two operations, expiring in 90 days) removed it without touching the query. The lab attacker identity is never added to the watchlist. Everything it does must alert. Most of the core rules share one idea: alert on a new pair. Listing storage keys is normal for the backup tool that does it every night. It is not normal for a caller who has never touched that storage account before. So the rule keeps a short memory of (caller, resource) pairs and alerts only on pairs it has not seen. The storage rule has three branches, each a different shape of suspicious:
  • A: a managed identity acting from an IP address it has never used. This is the stolen-token case, the heart of what Fenrir does.
  • B: one caller listing keys on three or more accounts within an hour.
  • C: a new (caller, account) pair, outside deployments and outside approved automation.
There is also a rule that connects the dots. fenrir-chain maps each of the six visible operations to a stage (host execution, secret listing, and so on) and fires when one caller performs two or more different stages, or touches three or more targets, within four hours. A single action can be an admin doing their job. Several different credential-grabbing actions in a row from one caller is a pattern. Entities are mapped in each rule, so an alert is not just text. The case view links the caller to the resource it touched.
Defender case for a VM Run Command: the lab attacker linked to the replay VM
The four Terraform stacks: bootstrap, sentinel, lab and purple
I split the infrastructure into four separate stacks. The split is not for tidiness. Each stack has a different level of risk and a different person or machine that is allowed to apply it.
infra/bootstrap: two app registrations with OIDC trust, the deploy identity, and the attacker identity whose only role is Contributor on the lab resource group
The bootstrap stack creates the foundations: the resource groups, the storage account that holds Terraform's state, and the two identities GitHub Actions will use. It is applied once, by me, from my laptop. Why not let CI do it? Because creating identities and granting roles requires very powerful rights. If CI could do that, then anyone who compromised the pipeline could give themselves access to anything. By keeping this step manual, the pipeline never holds the rights to grow its own power. No secrets anywhere. GitHub Actions signs in to Azure with OIDC. Put simply: GitHub gives each job a signed note that says "I am a job from this repository, on this branch". Azure is configured to trust notes with exactly that description. There is no password or key stored in GitHub, so there is nothing to leak or rotate. Two identities with two very different jobs:
  • huginn-github-deploy is trusted only for the main branch. It can run terraform plan and read alerts. It is in the watchlist for Terraform's refresh operations.
  • huginn-lab-attacker is the one that plays the attacker. It is Contributor on the lab resource group and nothing else. It is trusted only for jobs that run in a GitHub environment called lab-replay, not for a branch. Only a job that explicitly declares that environment can become the attacker, and environments can carry their own protection rules.
Pull requests get no Azure access at all. There is simply no credential that matches them. A bug worth knowing about. My first sign-in failed with AADSTS700213. The cause: my repository issues "immutable" OIDC subjects that include numeric IDs, like repo:Owner@123/Repo@456:..., instead of the plain repo:Owner/Repo:... that every tutorial shows. The credential I had written never matched. The ID-based form turns out to be the safer one, because if I ever rename or delete the repository, nobody can inherit its trust by creating a new repository with the old name. State. The bootstrap stack keeps its state locally, because it creates the very storage that would hold remote state, so it cannot store its own there on the first run. Every other stack keeps its state in that storage account, which has shared keys disabled, versioning and soft delete turned on, and a prevent_destroy guard. The bootstrap also writes one small file, bootstrap.json, with the non-secret IDs every other stack needs. Under OIDC a client ID is not a credential, so committing it is fine.
infra/sentinel: the workspace, the Activity log diagnostic setting, the HuginnActivity function, the watchlist and the scheduled rules
This stack holds the Log Analytics workspace, the setting that sends the subscription's Activity log into it, the HuginnActivity function, the watchlist, and the rules. The workspace has a daily cap of 0.5 GB as a safety net, so a mistake cannot create a surprise bill. I apply it by hand after reading the plan. CI never applies it, but CI does check it every night, as you will see.
infra/lab: the replay workflow acts as huginn-lab-attacker against a Logic App, a storage account and a VM
The lab stack holds the things the attacker identity acts on: a Logic App, a storage account, a managed identity, and a small locked-down network for the VM tests. The VM itself is deliberately not in Terraform. Each test run creates a fresh one and deletes it a few minutes later. I learned why the hard way: on my student subscription, even a stopped VM counts against a tiny CPU quota. A VM that exists only for the length of one run costs almost nothing and can never be forgotten. The more expensive targets (an App Service, a container group, a container registry) sit behind opt-in flags that are off by default. The fourth stack is a disposable environment for a real Fenrir run. It has its own section near the end.
ci.yml: five parallel jobs that must all pass before a merge
ci.yml runs on every push and pull request. It never signs in to Azure and reads no secrets, which makes it safe to run on any branch. It runs five jobs in parallel. 1. Static rule tests. A Python test file walks every rule folder and checks the mistakes a human reviewer tends to miss:
  • the folder is complete and the YAML is valid;
  • the operations in fenrir_ops really exist in the inventory;
  • every rule marked for CI testing has a replay.sh;
  • every entity the rule maps is a column the query actually outputs;
  • the time window written in the query matches the schedule in rule.yaml;
  • a deployable rule never references a table that needs a licence the tenant does not have.
Several of these tests exist because of a real failure. Each time the lab or a deploy surprised me, I turned the lesson into a test so it could not happen twice. 2. KQL syntax. Every query is parsed by Kusto.Language, Microsoft's own parser for the query language Sentinel uses. A missing bracket fails on my laptop in seconds, not during a deploy. This job has a detail I am fond of. A test that always passes is worse than no test, because it feels like protection. So the job also feeds the parser a folder of deliberately broken queries and fails if the parser accepts any of them. Every run proves the check can still say no. 3. Terraform format and validate, across all four stacks, with no backend and no cloud. 4. tflint, a linter for Terraform mistakes. 5. checkov, a security scanner for infrastructure code. It runs twice: once normally, and once with every opt-in lab resource switched on, because checkov skips resources that are switched off and I wanted those scanned too. My lab is vulnerable on purpose in a few places. A registry's admin user is switched on because that is exactly what operation P-13 lists. So some checkov findings have to be accepted. The rule I set is that every accepted finding is suppressed inline, next to the resource, with its reason written out, and summarised in a decision record. There is no silent global ignore list.
ci.yml green on its first run
Two small hardening habits: every third-party action is pinned to a full commit hash rather than a tag that could be moved, and the workflow's token is limited to read-only.
replay.yml: drift check, replay, cleanup, then alert validation
replay.yml is the heart of the project. It runs every night at 02:30 UTC, and on demand. It has four jobs. The first job signs in as the deploy identity and runs terraform plan on the sentinel and lab stacks. plan compares the files in git with what is really deployed. The job passes only if the answer is "no changes".
Bash
terraform -chdir=infra/$stack plan -input=false -no-color -detailed-exitcode > plan-$stack.txt
code=$?
if [ "$code" = 2 ]; then
  echo "::error::infra/$stack has changes not applied: deployed rules may not match the code"
  exit 1
fi
If someone edited a rule in the portal, or I merged a change and forgot to apply it, the run stops here, before any test. This is what gives the nightly result its meaning: a green run is a statement about the rules in git, not about whatever happens to be deployed. Notice what this job does not do. It never applies. I considered letting CI deploy the rules automatically and decided against it. Every change to Azure stays manual and reviewed, and the pipeline's job is to notice when reality and git disagree. The second job switches to the lab attacker identity and runs each rule's replay.sh. A key decision: CI never runs Fenrir. Running the real tool every night would mean stealing managed-identity tokens on a schedule, which is not something I want an unattended pipeline doing. The replay performs the same Azure operation Fenrir performs, with the same operation name, so the log row is the same shape. Then it throws the response away. The storage keys, callback URLs and command output go straight to /dev/null and are never printed or stored. Here is the core of the Logic App replay:
Bash
NAME="logic-huginn-replay-$(huginn_run_id)"
trap 'huginn_delete "$ID"' EXIT

az rest --method put  --url "$ARM$ID?api-version=2019-05-01" --body "$BODY" > /dev/null
az rest --method post --url "$ARM$ID/triggers/manual/listCallbackUrl?api-version=2019-05-01" > /dev/null
Create a fresh Logic App, list its callback URL once, discard the answer, and delete the app when the script exits, even if it fails halfway. The shared helper library adds safety rails. It refuses to run if the target resource group is not exactly huginn-lab-rg or if the signed-in subscription is wrong, and its delete function refuses any resource ID outside the lab resource group. A bug in a replay script cannot wander off and delete something that matters. This is my favourite problem in the project, because the bug is in the test, not in the rule. Remember that several rules alert only on a new (caller, resource) pair. Now imagine the nightly job using the same attacker identity against the same Logic App every night:
  • Night one: new pair, the rule fires, the build is green.
  • Night two: the pair is now known. The rule correctly stays silent. The build goes red.
The rule would be working perfectly, and the test would be reporting it as broken. The fix is that each replay creates a brand new, uniquely named resource, uses it once and deletes it. The pair is new every single night. To prove the fix, I ran the workflow twice back to back with the same attacker and required both runs to be green. Both passed.
Replay runs: the first failed on the drift check, the next three passed
Each replay already cleans up after itself. The third job runs regardless of what happened before it and sweeps the lab resource group for anything tagged as a replay resource. Two layers, because a leftover VM on a student budget is a real cost. The last job polls Sentinel's alert table until every expected rule has raised an alert that happened after the replay started and names the lab attacker as an entity. It records the time to alert for each rule and fails the run if any rule stays silent for 30 minutes.
replay.yml jobs: drift check, replays, cleanup, alert validation
Alert validation: every rule fired once, about 12 minutes 45 seconds after the replay
One more detail: the replay and evidence workflows share a concurrency group, so two runs can never act on the lab at the same time and confuse each other's results. This is the section that justifies the whole project. Every item below passed code review and would have shipped broken without a real test. My first rules followed Microsoft's sample pattern for picking up new rows: ingestion_time() > ago(5m), meaning "rows that arrived in the last five minutes". The first green replay raised two alerts for every event, and three for the chain rule.
Sentinel alerts: the same rule alerting for consecutive windows
The cause is a quirk of timing. Inside a scheduled rule, now() does not mean "the moment the query runs". It means the end of the time window the rule is evaluating. And Sentinel deliberately runs each query about five minutes after that window ends, to give slow logs time to arrive. So the filter "arrived after now() minus five minutes" has a lower limit and no upper limit. A row that arrives during that five-minute waiting gap is caught by the run that is waiting, and then caught again by the next run, whose window it truly belongs to.
Timeline of the bug: a row ingested at 21:29 falls inside the open-ended window of two consecutive runs, and inside exactly one window after the fix
The fix is one extra condition that closes the window:
Text
let New = Activity
    | where IngestedAt > ago(Frequency) and IngestedAt <= now();
Now each row belongs to exactly one window. A static test also checks that the Frequency in the query equals the schedule in rule.yaml, because if those two ever disagree, rows get counted twice or skipped. I also considered two built-in Sentinel features and rejected both. Rule suppression silences the whole rule for a period, which would also hide a genuine second attack. Alert grouping merges duplicates into one incident but the duplicate alerts still exist. Neither fixes the cause. Fixing that exposed a second trap. A single Run Command call writes three rows, and they arrive minutes apart.
X-08 lab evidence: three rows, one CorrelationId, ingested minutes apart
A rule that counts rows would see the same request as new in two different windows. The three rows share one CorrelationId, so the rules that aggregate now count a request as new exactly once, at the moment its first row lands. After both fixes, two back-to-back replays fired every rule with exactly one alert per event. I wanted the "new pair" rules to run every 5 minutes with a 14-day memory. The Terraform provider accepted it. The documentation page I had read did not forbid it. Then the apply failed: the Sentinel API rejects any rule that looks back two days or more unless it runs at most once an hour. That left a real trade-off:
  • Fast with a short memory: every 5 minutes, remembering pairs for 47 hours. Alerts in 10 to 15 minutes, but a legitimate caller who comes back every three days looks new each time.
  • Slow with a long memory: every hour, remembering 14 days. No extra noise, but up to 70 minutes to alert.
I chose fast, and wrote down what it costs. The plan to get both is on the roadmap: a daily job writes the last 14 days of known pairs into a watchlist, and the fast rule reads that list instead of scanning two weeks of raw logs itself. The lesson went into the status file in plain words: I had recorded "no other constraint" from reading a page, without testing it. A static test now enforces the limit so it fails on my laptop instead of during a deploy. Forty-seven hours can be written as PT47H. Sentinel accepts that, then stores it as P1DT23H (one day and twenty-three hours). The two mean the same thing, but Terraform compares text. So after every apply, Terraform saw a difference that could never be resolved, and the nightly drift check failed forever. The fix was to write the duration the way Sentinel stores it, and add a test that rejects hour counts of 24 or more.
  • A new log pipeline drops its first minutes. Right after I created the setting that exports the Activity log, about ten minutes of events never reached the workspace. Nothing was misconfigured. Lesson: check the workspace itself, not just the source, and do not trust the first minutes of a new pipeline.
  • "Nightly at 02:30" is a suggestion. GitHub runs scheduled workflows on a best-effort basis. My first nightly run started at 09:32, seven hours late. Fine for this project, but worth knowing before you build anything time-critical on a cron trigger.
Some of Fenrir's footprint lives in logs my tenant cannot afford. A Sentinel rule that references a table missing from the workspace fails to deploy, so I could not simply write every rule and hope. The rules are split into three tiers:
  • Core: uses only the free Activity log. Deployable anywhere, tested by the nightly replays. This is where the four validated rules live.
  • Identity: sign-in and Graph rules. They are written and reviewed but marked deployable: false until a P1/P2 licence exists, and a static test stops them from sneaking into a deploy.
  • Beyond Fenrir: rules for the next move an operator would make after Fenrir reports an opportunity, like granting themselves a role. Fenrir never performs these, so they need their own tests.
Current honest status: 4 rules validated, the rest drafts. Validated has a strict meaning here. It means the alert appeared in two back-to-back lab runs, with the run numbers written down.
Cases in Defender, one per alert
The nightly replays are narrow by design. Each performs one action as a service principal, and none of them ever requests a managed-identity token. That leaves the hardest questions open. Is the enumeration phase truly invisible, or does some log I have not looked at catch it? Does a stolen secret ever show up in telemetry? So far my blind-spot claims rest partly on documentation, and this project has already shown twice how far documentation can be from reality. The purple-team environment exists to replace those claims with measurements.
Purple team: a disposable resource group with every Fenrir target and every log source sent to Log Analytics
It is a fourth Terraform stack that I apply by hand for a single run and destroy the same day. CI checks its code but never applies it. One apply creates one of every resource type Fenrir touches, each mapped to the Fenrir operations it answers:
  • A Linux VM with a user-assigned identity: X-08 (Run Command) and the host side of token theft.
  • A Linux web app with SCM basic auth on: X-10 and X-11 (publishing credentials, Kudu).
  • A Logic App with an HTTP trigger: X-12 and X-13 (callback URL).
  • A container group running an idle busybox: X-14 (container exec).
  • An Automation Account with a runbook, a variable and a credential: X-15 to X-18 (runbook source, variables, credential names).
  • A storage account and blob: P-12 and D-01 (listKeys, blob data).
  • A container registry with the admin user on: P-13 and D-03 (listCredentials, image pull).
  • A Key Vault: E-27 (secret read).
Every one of them has every available log category switched on. The VM also streams its Syslog through the Azure Monitor Agent. Two more sources are opt-in: Entra ID sign-in and Graph logs (through a P1/P2 trial), and Defender for Resource Manager, the only Microsoft source that analyses ARM traffic beyond the Activity log.
infra/purple: a user-assigned identity on every host, canary secrets, and every resource sending all its logs to the workspace
Three ideas make it more than a pile of resources: Canary secrets. Wherever a real secret would sit (a runbook, a Key Vault secret, a blob, an app setting), there is a random value starting with HUGINN-CANARY-. After the run, a script searches every table for that prefix. If a canary appears in a log, a stolen secret reached that log. So the environment measures not only which actions are visible, but which stolen secrets leave a trail a defender could hunt for. Capture by indicator, not by table. The capture script does not query the tables I expect. It searches all tables for any row that mentions the run's identities or the attacker's IP address. Telemetry can then turn up in places nobody predicted, which is the whole point of the exercise. Everything is redacted before it is saved. A preflight gate. Before any Fenrir command runs, a check confirms that every log source is really delivering rows to the workspace, and refuses to say READY until it is. An attack run against logging that silently was not working would be a wasted afternoon. The attacker in this environment is a dedicated low-privilege user with access to that one resource group only. Fenrir acts on everything it can see, so it must never run as an account with rights anywhere else. This stack is written, reviewed and passing CI. The first real run is the next milestone.
  • Rules validated: 4, each in two back-to-back replays with exactly one alert per event.
  • Time to alert: 5 to 17 minutes. The log takes 3 to 10 minutes to arrive, then comes the wait for the next 5-minute window, then Sentinel's own 5-minute delay.
  • Static tests: 74 checks across 14 rule folders, plus 15 query files parsed, on every push.
  • Always-on cost: about 0 USD per month. Activity log ingestion is free, and nothing in the lab runs all the time.
  • Per nightly run: well under one US cent, almost all of it the VM that lives for about five minutes.
The whole thing fits inside a student subscription. That constraint shaped many decisions (the per-run VM, the opt-in flags, the daily cap), and I think it made the design better.
  1. Inventory the attacker before writing a rule. The list of 66 operations decided everything else. It showed me that six rules could cover everything the free log can see, and that the rest needed a different answer.
  2. State your blind spots first. They are the most useful output of the project.
  3. Look at real rows. Every assumption I took from documentation and did not test was wrong at least once.
  4. Test the tests. A check that cannot fail protects nothing. Give it something broken and make sure it complains.
  5. Check for drift instead of auto-deploying. A pipeline that can only read and compare is far harder to abuse than one that can change production, and it still catches everything I care about.
  6. Exclude identities, not tools. The attacker uses the same tools your admins do.
  7. Write decisions down while they are fresh. Huginn has eight short decision records. Each one explains a choice, the options I rejected, and what the choice costs. Writing this post was mostly a matter of reading them back.
The remaining core rules (App Service, container exec, registry credentials) need the opt-in lab resources. The identity tier needs a licence trial and the first purple-team run. And the long-memory baseline at five-minute speed is designed but not built. The code, the decision records and the dated status file are all on GitHub at github.com/MarwenOnGit/Huginn.
§ — Also in evidenceView all →

Other exhibits


Exhibit M · 10 Oct 2026 · Active Directory

Active Directory and Azure: an attack and defense notebook

My combined study notes on Windows identity attacks and how to catch them: Kerberos roasting and delegation, NTLM and Kerberos relay, the Printer Bug, DCSync and Golden Tickets, then the Azure side with Entra roles, managed identities, directory sync, and the C2 infrastructure I read up on while prepping for a technical interview.

Filed
Exhibit L · 04 Sept 2026

SQL Injection

PortSwigger Web Security Academy notes on detecting and exploiting SQL injection, from UNION attacks to blind and out-of-band techniques

Filed
Exhibit K · 18 Aug 2026 · Azure Security

Modeling Managed-Identity Privilege Escalation as an Attack Graph

A framework for treating Azure managed-identity abuse in hybrid Entra ID environments as a graph-reachability problem. I define the node and edge types, ground each edge in Azure RBAC semantics, show how my tool Fenrir uses the model to answer one question conservatively, and work through a case study in my own lab. Framework and systematization, not an empirical study.

Filed
§ Contents