Automate Email Threat Analysis with n8n and TheHive Cortex

This workflow automates the process of analyzing email attachments for cybersecurity threats using n8n, TheHive, and Cortex. It streamlines triage by extracting observables and performing automated analyzers to identify malicious domains, IPs, and emails, saving hours of manual threat hunting daily.
emailReadImap
theHive
cortex
+2
Workflow Identifier: 1595
NODES in Use: emailReadImap, theHive, cortex, if, wait
Automate email threat analysis with n8n and TheHive

Press CTRL+F5 if the workflow didn't load.

Learn how to Build this Workflow with AI:

What This Workflow Does

This workflow automatically reads emails with attachments from an IMAP inbox.
It creates cases in TheHive using the email details and uploads attachments as artifacts.
It extracts observable data like domains, IP addresses, and emails from attachments.
Then it runs Cortex analyzers on these observables to find threats.
The case is updated with IOC details and reputation findings.
Special analyzers run on different IOC types based on conditional logic.

This helps save time, cut errors, and speed up threat detection from suspicious emails.


Who Should Use This Workflow

Security analysts dealing with many suspicious emails daily should use this workflow.
It fits teams using TheHive and Cortex platforms for case and IOC management.

Users wanting to automate email attachment analysis and IOC enrichment will find this helpful.


Tools and Services Used


Workflow Inputs, Processing Steps, and Outputs

Inputs

Processing Steps

  • IMAP Email node fetches incoming emails and attachments.
  • TheHive node creates a new case with email metadata and uploads attachment artifacts.
  • Promote the case to active and retrieve full details using TheHive nodes.
  • TheHive Observable node extracts observables like domains, IPs, and emails from the case.
  • TheHive Analyzer Email node runs Cortex analyzers on the observable attachments.
  • Cortex node retrieves analyzer reports containing IOCs.
  • IF node checks if any IOCs (domain, email, IP) are found to decide next actions.
  • TheHive nodes create observables in the case for each IOC type and tag them accordingly.
  • Wait node pauses briefly to allow case updates to complete.
  • Cortex analyzers specific for domains, emails, and IPs run again for extended reputation analysis.

Outputs

  • Active cases in TheHive with attachments and annotations.
  • Extracted and tagged domain, email, and IP observables.
  • Detailed Cortex analyzer reports linked with cases.
  • Automatic enriched threat intelligence allowing faster investigation.

Beginner step-by-step: How to Use This Workflow in n8n Production

1. Import the Workflow

  1. Download the workflow file by clicking the Download button on this page.
  2. Open the n8n editor where automation is configured.
  3. Use the “Import from File” option to add the workflow file.

2. Configure Credentials and Settings

  1. Add API Keys and credentials needed for TheHive, Cortex, and your IMAP email account.
  2. Update IDs, email addresses, mailbox folders, or analyzer IDs if they differ in your environment.
  3. Check the source field in the TheHive case creation node and update to your email provider name if needed.

3. Test the Workflow

  1. Send a test email with an attachment to the monitored inbox.
  2. Run the workflow manually or wait for it to trigger automatically.
  3. Verify the case is created and the observable extraction happens as expected.

4. Activate for Production

  1. Toggle the workflow to “active” mode in n8n editor.
  2. Monitor execution history and logs for issues.

Customization Ideas

  • Change the email source field in TheHive for accurate data tagging.
  • Add more Cortex analyzer IDs to run more types of scanning on IOCs.
  • Adjust the wait time to fit TheHive API performance and avoid race conditions.
  • Add filters to process emails with specific subjects or sender addresses.
  • Connect notification nodes such as Slack or Email to alert security teams on new case creations.

Troubleshooting

  • Problem: No case created in TheHive even after email arrives.
    Cause: TheHive API credentials missing or misconfigured; “create case” operation not set.
    Solution: Check and update TheHive credentials, confirm all required fields are correctly mapped.
  • Problem: Cortex analyzer returns no IOCs or fails.
    Cause: Wrong analyzer ID or Cortex service issues.
    Solution: Verify analyzer IDs, test Cortex separately, enable retry on failure in the analyzer node.
  • Problem: Workflow stuck on the Wait node.
    Cause: Network delays or webhook misconfiguration.
    Solution: Increase timeout limits, check webhook IDs, adjust wait durations.

Pre-Production Checklist

  • Verify the IMAP Email node retrieves test emails and attachments.
  • Confirm TheHive API credentials are valid and have needed permissions.
  • Run Cortex analyzer nodes with sample data to ensure output.
  • Check that data flows through the nodes correctly.
  • Perform an end-to-end test with a real suspicious email.

Deployment Guide

Make sure all credentials like IMAP email and TheHive/Cortex API keys are correct and accessible.
Activate the workflow in n8n editor by switching it to “active”.
Watch executions in n8n for errors or issues.
Consider adding notifications or dashboards for alerting security teams.

For more control, try self-host n8n to run workflows securely on your own server.


Summary

✓ Saves hours by automatically processing suspicious emails into TheHive cases.
✓ Finds and tags IOCs like domains, emails, and IPs from attachments.
✓ Runs Cortex analyzers to get detailed threat intelligence.
✓ Speeds investigation with automatic updates and conditional analysis.
✓ Easy to deploy and customize inside n8n platform.


Automate email threat analysis with n8n and TheHive

Visit through Desktop to Interact with the Workflow.

Frequently Asked Questions

Yes, configure the IMAP Email node with Gmail’s IMAP server settings and credentials.
Yes, running Cortex analyzers uses API credits based on the subscription plan.
Email data stays within secure n8n and TheHive environments. Protect all API keys carefully.
The workflow suits moderate volumes. For high traffic, scale n8n workers and TheHive infrastructure accordingly.

Promoted by BULDRR AI

Related Workflows

Automate Twist Channel Creation and Messaging with n8n

This workflow automates creating and updating a channel in Twist and sending a personalized message to specific users. It eliminates manual setup errors and saves time managing Twist communications.

Automate Ideogram Image Generation with Google Sheets & Gmail

This workflow automates graphic design image generation via Ideogram AI, storing image data in Google Sheets and Google Drive, with email alerts via Gmail. It saves designers hours by automating image creation, remixing, review, and record-keeping.

Automate IT Support with Slack and OpenAI in n8n

Streamline IT support by automating Slack message handling using n8n and OpenAI. This workflow handles Slack DMs, filters bots, queries a Confluence knowledge base, and delivers AI-generated responses, improving support efficiency and response time.

Automate Crypto Analysis with CoinMarketCap & n8n AI Agent

Discover how this unique n8n workflow leverages CoinMarketCap’s multi-agent AI to deliver precise, real-time cryptocurrency insights directly via Telegram. Manage crypto data analysis efficiently with automated multi-source API integration.

Automate Gumroad to Beehiiv Subscriber Sync with n8n

Learn how to automatically add new Gumroad sales customers as Beehiiv newsletter subscribers using n8n automation. This workflow saves time by syncing sales data to Google Sheets CRM and notifying your Telegram channel instantly.

Generate On-Brand Blog Articles Using n8n and OpenAI

This workflow automates the creation of on-brand blog articles by analyzing existing company content using n8n and OpenAI. It extracts article structures and brand voice to produce consistent draft articles, saving significant content creation time.
1:1 Free Strategy Session
Your competitors are already automating. Are you still paying for it manually?

Do you want to adopt AI Automation?

Every hour your team does repetitive work, you're burning real money.
While you wait, faster businesses are cutting costs and moving quicker.
AI and automations aren't the future anymore — they're the present.

Book a live 1-on-1 session where we show you exactly which of your daily tasks can be automated — and what it’s costing you not to.