Agentic phishing triage and threat hunting with Sublime Security
Sakil (Lead Security Architect)
A phishing report arrives and the clock starts. Somebody has to decide whether the message was a real attempt, who else received it and what happens to the copies still sitting in mailboxes.
Triage is built around the first decision: reading the headers, the authentication results, where each link points and the age of the sending domain.
The other two are a different kind of work. Finding the rest of the campaign means describing the attack rather than the message and searching mail nobody flagged. Turning what you find into a detection means testing that description, checking it against the rules you already run and knowing what else it would fire on. Neither is complicated, but both took us longer than the triage that prompted them. Each needs somebody who can write queries against mail.
This post is about those two jobs: the threat hunt and the detection rule that come after the verdict. It also covers what it takes to hand them to an agent without getting back something that reads well and is wrong.
Any mail platform you can query will do for this. We use Sublime Security. Sublime parses inbound mail into a structured model, runs detection rules over it and gives you a query language called MQL to search that model yourself. Its free Core tier covers all three. That is enough to read a message, hunt for the others and author a rule. Containment actions like quarantine are available for enterprise users.
This post shows how Tracecat uses Tracecat to triage malicious emails with agents, starting with phishing on Sublime's free tier. By the end, you'll be able to build an agentic system that:
- Opens one case per flagged or user-reported message group, with the evidence Sublime parsed
- Scopes the campaign by indicator, then hunts the attacker's technique across every mailbox
- Surfaces mail that matches the technique and that the platform took no action on
- Tracks removal of mail as a case task for a human, because the free tier cannot quarantine
- Drafts a candidate detection rule, tests it and creates it in Sublime only after somebody presses an approve button in Slack
All of it runs on one workflow with three lanes, two agent presets and the skills attached to them.
Automations-as-code
Everything in this post is open source: https://github.com/TracecatHQ/tracecat
What you need
- Tracecat. A workspace with the Tracecat MCP server connected to your coding agent.
- Model provider. An API key for the provider Socky and Detectee run on. Each preset can use a different provider.
- Agent presets. Two presets with the slugs
sockyanddetectee, each with the skills listed under "The skills behind the agents". Detectee holds no tool that creates or enables a rule.
- Sublime Security. A Core tier account with your mail source connected. The workflow reads message groups, runs MQL, validates rules and starts hunt jobs. Core cannot quarantine or remove a message. The hunt queries match impersonated names against
$org_display_names, a list Sublime keeps for your organization. No names are written into the MQL. - Google Workspace. Read-only Directory and Reports access. Socky uses it to resolve a recipient to a person and to read the audit log around delivery.
- Threat enrichment, optional. VirusTotal, AbuseIPDB and urlscan, for the sender domain and the links.
- Slack. Create an app at api.slack.com/apps from the manifest below. Install it and invite it to a channel for phishing triage. You add the event and interactivity request URLs after you deploy.
{
"display_information": {
"name": "Socky",
"description": "Security alert triage bot"
},
"features": {
"bot_user": {
"display_name": "socky"
},
"rich_previews": {
"is_active": true,
"entity_types": [
"slack#/entities/incident"
]
}
},
"oauth_config": {
"scopes": {
"bot": [
"app_mentions:read",
"channels:history",
"chat:write",
"links:write",
"reactions:write",
"users:read",
"users:read.email"
]
}
}
}
| Integration | Secret | Keys |
|---|---|---|
| Sublime Security | sublime | SUBLIME_API_KEY |
| Google Workspace | OAuth integration (google_admin) | An admin over OAuth, or a service account with domain-wide delegation |
| VirusTotal, optional | virustotal | VIRUSTOTAL_API_KEY |
| AbuseIPDB, optional | abuseipdb | ABUSEIPDB_API_KEY |
| urlscan, optional | urlscan | URLSCAN_API_KEY |
| Slack | slack | SLACK_BOT_TOKEN |
Every Sublime action passes base_url. It defaults to https://platform.sublime.security.
detection_proposals: Detectee's one proposed rule per case. The approve lane reads it back by case_id.
| Column | Type | Notes |
|---|---|---|
case_id | TEXT | Lookup key |
canonical_id | TEXT | |
rule_name | TEXT | |
mql_source | TEXT | |
severity | TEXT | |
rule_description | TEXT | |
agent_verdict | TEXT | |
status | TEXT |
slack_work_objects: the Slack card for each case. The hunt step uses it to find the card's thread.
| Column | Type | Notes |
|---|---|---|
external_ref_id | TEXT | Unique |
case_id | TEXT | |
channel | TEXT | |
message_ts | TEXT | |
entity | JSONB |
Deploy it
Click your coding agent to get a prompt. The agent reads the workflow, the presets and the skills from the repository, connects to Tracecat over MCP, builds in dependency order, checks each step before moving on and keeps the schedule off until you have seen a case you believe.
Click to deploy through prompts
How the workflow runs
One workflow runs all three lanes. They write to the same case and tables and share the two presets. You test and publish one workflow.
A schedule starts the poll lane. The lane runs three Sublime queries, drops duplicates and then takes each message group on its own. Socky investigates it, writes the case, posts the card and hunts for the other copies.
The three queries ask for different things: the mail Sublime scored as malicious or suspicious, the mail that fired one of its high or critical rules and the mail somebody reported. They overlap. A fourth step drops the duplicates so that each message group gets one case.
Because none of that needs judgment, none of it is given to an agent. The same four steps run every time. We would rather the step that decides what gets a case did not vary between runs.
A Slack button starts the click lane. The workflow reads which button was pressed and does that one thing: set a verdict and push it to Sublime, create and enable an approved rule, discard a proposal, scan the links or acknowledge.
Generate detection rule starts the detection lane. Detectee drafts a rule, tests it, writes the proposal on the case and posts it to Slack behind an Approve button.
The two presets
- Socky runs the investigation, the hunt and the Slack card updates. Its tools are read-only against Sublime and the enrichment services, plus the Tracecat case and Slack tools it needs to write its own output.
- Detectee is the detection engineering agent. It reads the rules you already run, writes a candidate and tests it. It cannot deploy one: nothing in its allowlist creates a rule or turns one on. That step is a workflow action behind a human click.
The skills behind the agents
Because skills load on demand rather than all at once, a preset can carry a large library and a run pays only for the skills it opens. These are the skills this automation uses.
Socky
sublime-phishing-case-lifecycle. The path from one message group to a triaged case and a published card. The case description contract and the Slack delivery contract.email-evidence-core. The hunt job contract, plus which Sublime and Google Workspace reads are permitted, how a mailbox resolves to a person and what each indicator does and does not prove.business-context. Deployments, schedules, benign patterns, the employee list.hypothesis-driven-triage. The investigative method and the hypothesis library.case-output. How a case description, brief or evidence table is laid out.case-writing-style. How the case should read (built on ASD-STE100 Simplified Technical English) and which evidential qualifiers it must keep.slack-case-threads. Mentions, thread replies and button payloads.org-chart. Who reports to whom, for naming an owner.
Detectee
email-evidence-core. The hunt job contract, plus which Sublime and Google Workspace reads are permitted, how a mailbox resolves to a person and what each indicator does and does not prove.sublime-detection-engineering. Authoring MQL: the dialect, the required tests, what a backtest can and cannot claim.business-context. Deployments, schedules, benign patterns, the employee list.case-writing-style. How the case should read (built on ASD-STE100 Simplified Technical English) and which evidential qualifiers it must keep.
Agentic threat hunting
Two of those skills do the hunting. email-evidence-core holds the hunt job contract. sublime-detection-engineering holds the tests a candidate rule has to pass.
Agentic threat hunting means the agent writes the query instead of slotting the sender address into a saved search or reusing a template somebody wrote for a different campaign. Socky reads the case, works out what the attacker did and writes that as MQL.
That buys two things. The search reaches mail nobody flagged, because it runs over the whole retention window instead of the alert queue. And it survives the attacker changing their infrastructure, because a method described in a query matches the next sender and the next subject as well as this one.
Writing the query also gives the detection rule a head start. A query that describes a method and has been tested against real mail is already close to a rule. That is why the detection step starts from the hunt rather than from the message.
Checking the result was harder. When the agent reads a message, the evidence is in front of it and goes into the case for the next reader to check. A hunt is less visible. The query runs across every mailbox and comes back as a list. That list looks much the same whether the query was right or wrong. Too broad and the message you wanted is somewhere under ordinary notification mail. Too narrow and it returns the message you started with, where a table with one row can read as "nobody else got this."
A detection rule is harder still, because it judges mail that has not arrived yet. Too broad and people start seeing ordinary mail flagged. Too narrow and nothing happens at all. That looks exactly like a quiet week until the next phish gets through.
So the agent does not get to hand us a result and have us take its word for it. Three things have to hold before a hunt result reaches a case:
- The query has to match the phish it was written from. Before it searches anything else, Socky runs the query against the one message already known to be malicious. If the query cannot match that, it is broken and nothing it returns afterwards means anything.
- It cannot narrow its way to a clean answer. A narrower query returns a shorter list that is easier to read and more likely to miss somebody. To stop that, what the query may drop is fixed in advance: our own domains and senders Sublime already trusts. It may not drop a different sender, a different recipient or a subject with
Re:in front of it. - The report says what Sublime searched, not what was asked for. Retention can be shorter than the window in the request. When it is, the job returns the shorter window without flagging it. Reading the window back from the finished job keeps a period nobody searched out of the case.
From message to detection
The rest of this post follows one flagged message through five steps, from the investigation that opens its case to a detection rule somebody has approved.
1. Investigate the message group
Socky runs the same investigation on every flagged email. Each investigation generates a Tracecat case and a Slack alert message.
- Read what the platform parsed. Socky uses the Message Data Model, not the raw file: the sender and the display name, the authentication results, the links and where they point against what they display, the headers, the recipients and whether each message was read, replied to or forwarded. It resolves the mailbox to a person through the directory and checks the business context for a benign pattern that would explain the mail.
- Enrich the few indicators worth enriching. Domain registration age, the reputation of the sending IP and the link and sender domains. Registration age is the signal that gives away a lure sent from a domain the attacker has just bought.
- Reach a verdict and say what it rests on. The case records the verdict, the evidence under it and a named list of what could not be checked. The case writes "no link click is recorded" so that a reader does not take it for "nobody clicked the link."
- Scope who else got this message. Socky searches the sender address, the sender domain, the link domain and the attachment hash.
- Post the card. The verdict, the deviation that earned it, the recipients, the case link and the buttons that carry a decision back into the workflow. Two of them sit on the card itself, Malicious and Benign, because that is the decision the reader opened it to make. The rest sit in the card's overflow menu, one press away: mark it as spam, generate a detection rule, scan the links, open the message in Sublime, open the admin console.
The case is written and the card is posted. Step 4 looked past this one message only as far as the groups Sublime had already flagged.
2. Hunt the technique across every mailbox
Socky keeps going from there. If the same lure arrived from a different domain under a different subject without any rule firing on it, nothing in the run so far would have surfaced it. The hunt answers whether any such mail exists.
The hunt runs MQL over every message in the retention window, flagged or not. The query matches the shape of the lure rather than the indicators this message carried. The scope count is a floor. The hunt is whatever sits past that floor.
The sender address, the sender domain, the link domain and the attachment hash are cheap for an attacker to change between sends. The method behind them usually is not. The workflow searches on both. Scoping keeps the copies of one delivery, then hunting adds the deliveries that share the method, including the ones no rule fired on.
| Step | Indicator scoping | Technique hunt |
|---|---|---|
| Searches | Flagged message groups | Every message in the retention window |
| Matched on | Sender address, sender domain, link domain, attachment hash | The shape of the lure |
| Answers | Who else got this message | Who else got this attack |
| Costs | A filtered read | One batch job |
Writing the query. Socky deliberately takes the attacker's method from the case rather than the indicators the case has already searched. The method is whatever the attack needs in order to work: a reply-to that points somewhere other than the sender, a link whose visible text and destination disagree, a subject that borrows an internal name, an attachment that does not match what the sender normally sends. The query names that and leaves out everything the attacker can change for free.
Two habits keep the query durable. The query refers to the lists Sublime maintains for the organization (your own domains and the senders Sublime already trusts) instead of writing names and allowlists into the query text. That keeps it working as staff and suppliers change. It also matches on shape rather than exact strings. A prefix, a truncation or a reordering does not slip past it.
A hunt that has not finished looks like a hunt that found nothing. Because the job runs in the background for a few minutes, the agent has to check back to find out whether it is done. Left alone, it fires those checks off in seconds, is told every time that the job is still running, runs out of attempts and reports an empty hunt.
So each wait between checks is longer than the last: twenty seconds, then forty, sixty, ninety and two minutes twice. A job that finishes in seconds is reported in seconds, but a slow one still gets seven and a half minutes before the step stops waiting. One long sleep would make every hunt slow to catch the rare slow one.
If the job is still running when that runs out, the step says so and prints the job ID instead of reporting a total. A hunt whose ID is written down can be read again later. A hunt reported as empty is lost.
The hunt returns two kinds of row that matter. The first is mail that matches the method with no rule firing on it. It is still sitting in a mailbox and nobody knows it is there. That is the gap the hunt exists to find.
The second is mail the platform did flag, where nobody ever opened the alert. The detection worked and the response did not. Socky lists the two separately, because what they need is different: the first needs a rule written for it, the second needs somebody to work the queue.
A big total is not a reason to narrow the query. Plenty of ordinary mail shares a surface with an attack. Most of what comes back is legitimate. The number worth reading is how many of those rows nobody flagged.
The step posts that result into the card's thread and writes the same rows onto the case so the finding lands where the decision gets made. Slack gets them as a list and the case gets them as a table, because Slack does not render a Markdown table and prints the pipes instead.
3. Read what the hunt returned
Each returned group carries more than the fact that it matched. These fields are the platform's record of what happened in each mailbox, not the agent's reading of it. The containment tasks get built from them.
| Field | What it tells you |
|---|---|
read_at | When the recipient opened the message |
replied_at | The recipient replied. The case changes from attempted to engaged |
forwarded_at | The message was forwarded and the lure spread inside the company |
forward_recipients | Which mailboxes it was forwarded to. Each gets its own removal task |
flagged_rules: null | The platform took no action on this message |
4. Author a detection, behind a human gate
The hunt has just listed mail that reached a mailbox with no rule firing on it. That is a detection gap: the method works, yet nothing currently running describes it closely enough to catch it.
A rule closes that gap. Writing it for the method rather than for this one message keeps it closed after the sender and the subject change.
Detectee writes that rule but does not add it. Creating a rule and turning it on change what happens to everybody's mail. Both wait for a human.
Pressing Generate detection rule acknowledges in the thread and starts the work in the background. Detectee then works through a fixed sequence:
- Read what made the message malicious and what the hunt already found. From the case and the parsed model, not from the case title. The mailbox hunt has already run by the time anyone presses the button. Detectee reads its result off the case rather than hunting a second time.
- Check the existing rules. It compares MQL, not titles. Two rules with different names can match the same mail. A rule named for one campaign often already covers the next one.
- Author a candidate rule. One technique per rule, with the MQL written to be read by a person.
- Validate the syntax. Through Sublime's rule validation, before anything is saved.
- Prove it matches the source message. A rule that does not match the message it was written for is wrong, whatever its syntax says.
- Prove it stays quiet on something legitimate. The candidate is run against ordinary mail that shares a surface feature with the phish, such as a calendar invitation carrying a colleague's name. The proposal reports whether it stayed quiet.
- Measure the volume. One hunt job runs the candidate MQL over the retention window to show what it would have caught. It is the only hunt this lane starts. Where the technique hunt asked who else was targeted, this one asks how much ordinary mail the rule would fire on.
That last step is a backtest: the candidate rule is run over mail that has already arrived, to show how often it would have fired. A rule that would have fired on hundreds of ordinary messages is not shippable, however good its intent. The backtest is the only way to find that out before it goes live.
When the backtest matches nothing, the proposal says the volume is unknown rather than calling the rule clean. An empty result has two explanations that look identical from the outside: the technique is rare, or the rule does not work. The same applies when the hunt could not run at all. The proposal still arrives, saying which of its checks it was unable to complete.
The proposal is written to the case and posted to Slack with the full MQL, the tests, the hunt result and the window it covered, behind Approve and Discard buttons.
The button press is the authorization. Access to the channel is the control here: whoever can see the card can approve it. The case records who pressed.
If that is too open, restrict approval with a condition on the action that creates the rule. The press already carries the Slack user ID of whoever made it. Keep the allowed IDs wherever suits you, such as a trigger input or a Tracecat table you can edit without touching the workflow. Then check the presser's ID against that list before the create call runs. Our Google OAuth workflow does this for its revoke button and replies privately to anyone else who presses. Wherever the list lives, the check runs in the workflow. Detectee has no say in who may approve.
Nothing reaches Sublime until somebody presses Approve. On approval, the workflow reads the proposed rule back from the stored proposal and creates it from that. The rule that exists is exactly the MQL the approver read. Creating and enabling are two separate calls in that order. A failure between them leaves the rule off rather than on and unreviewed.
Discard records who discarded it and that nothing was created.
Neither the create call nor the enable call is available to the agent. An agent that can write a rule and also switch it on can change what happens to everybody's mail without anyone having read the rule first. Keeping both calls in the workflow means the only route to a live rule runs through a person who has seen the MQL.
5. What ends up on the case
The case opens with the verdict in a sentence and a row of links out to the places a reader will want to check for themselves: the message in Sublime, Sublime's remediation queue and the mail log search in the Google Workspace admin console. Somebody skimming gets the answer and a way to verify it without reading any further.
Below that, the layout is fixed:
- Evidence tables. The rules that flagged the message, the authentication results, the sender domain's registration, the links and attachments and what could not be checked.
- Scoping. What the indicator search returned, labeled as a search of the flagged set.
- The hunt table. Every matched group, with the mailbox, the sender, the interaction fields and whether the platform flagged it.
- Case tasks. One task per mailbox for removal, one to confirm it is gone and one for the detection rule if somebody asked for one.
Case tasks hold the containment work a person still has to do. Because Sublime Core cannot remove mail, every removal is a human action with its own task and its own open or closed state.
Make it your own
Every part of this is a separate action. The pieces that depend on a particular vendor can be swapped without touching the logic around them. The mail platform is one action and a skill. The place approvals land is another, whether that is a chat tool or your service desk. The list the query checks employee names against can come from the mail platform, your identity provider or a table you maintain yourself.
Two parts carry over even if you replace Sublime. The first is the separation between scoping by indicator and hunting by technique. It applies to any platform that lets you query mail it did not flag. The second is the shape of the detection gate: an agent that authors and proves, a human who approves and a workflow that creates the rule from stored state rather than from the agent's last message.
Beyond that, five directions we did not build and would:
- Containment, where your tier allows it. Removal is manual here only because Core cannot quarantine. On a tier that can, or through the mail platform's admin console, the removal tasks become actions. The detection gate is the pattern to copy: the agent proposes, a person approves, the workflow carries it out. Trigger it from a button on the card the way Approve already works, or from a case task, as another lane here or as a detached call. Whichever way you build it, the mailboxes to act on are derived by the workflow from the hunt result, never read back out of the agent's summary. They are shown to a person before anything is deleted. A wrong hunt query is a noisy case today. Give an agent the ability to delete mail and the same mistake removes somebody's messages.
- Feed the approved rule into detection as code. If you already keep Sublime rules in a repository, the approval can open a pull request carrying the same MQL, the tests it passed and the backtest volume. Your existing review and deployment path takes it from there. The proposal already holds everything a rule file needs. The case keeps the evidence for why the rule exists.
- User outreach. The case already knows which mailboxes received the message and which recipients read, replied to or forwarded it. That is enough to send each one a short, specific note rather than a company-wide warning nobody reads. A reply is also evidence: "I did reply with my number" changes the case from attempted to engaged. Hearing that from them is quicker than working it out from the record.
- Raise an incident alongside the case. For a confirmed campaign, open a PagerDuty or incident.io incident from the verdict lane and keep the case as its evidence record. The incident wants a responder, a severity and a timeline. The case wants the hunt table and the authentication results. Let each hold what it is good at and link them.
- More enrichment at the sender and link layer. The automation checks registration age on the sender and link domains as well as the reputation of the sending IP. A threat intel platform, a passive DNS source or any feed that tracks infrastructure reuse would add to that. The hunt is where we would expect it to add most: a hunt can return unflagged mail from several senders with nothing obvious in common. Whether those senders share hosting is a question none of the checks here can answer.
Before you add an enrichment source, check whether it is silent. Some services answer out of data they already collected: you ask about a domain, they check their own records and nothing of yours reaches the attacker. Others go and fetch the thing you asked about. Submitting a domain or a URL to one of those tells whoever owns it that somebody is looking. On most of them the submission stays visible to anyone else who searches that service later. Against infrastructure still in use, that can be enough for the attacker to move it, burn the link or go quiet before the scoping is finished. That is why link scanning sits behind its own button here rather than running on every case, with a brief in the card's thread that says the submission is public before anyone presses. Only registered domains go out, never full URLs carrying a token.
What next?
What we learned
- Every flagged or reported message gets a case. The poll runs on a schedule and opens the case within minutes of delivery, rather than when somebody reaches the queue.
- Facts belong in the workflow, judgment in the agent. The queries, the deduplication, the fan-out, the verdict write and the read-back are typed actions with fixed arguments. The agents read the evidence and decide. They do not carry the plumbing.
- The flagged set is a floor. Scoping by indicator finds the copies of one delivery. Hunting by technique finds the mail that shares its method, including the mail no rule fired on.
- The agent proposes and a person deploys. Detectee drafts and tests. The workflow creates the rule from stored state after a named person presses Approve, then records who that was.
- The record keeps itself up to date. The case, the removal tasks and the Slack thread are written as the run goes. The evidence, the decision and the person who made it stay in one place.
What we did not cover
This automation decides, records and proposes, then stops.
- The mail is not removed. Because Core cannot quarantine, every copy stays where it is until somebody removes it in the admin console. The case carries that as a task per mailbox.
- The sender is not blocked. Nothing here adds a domain or an address to a block list.
- No account is touched. No session is revoked and no password is reset, even where somebody replied.
- The recipients are not warned. Nobody is told their mailbox received it unless a person tells them.
- Attachments are not detonated. Analysis stops at what the platform already parsed. There is no sandbox: nothing is opened or run to see what it does.
The workflow, the presets and the skills are on GitHub and in the Tracecat docs.
We would like to hear how you scope a phishing campaign today and whether you check the mail nobody flagged.