Template for a cyber threat intelligence (CTI) agent that fetches public threat intel, triages it using a local LLM (via Ollama), enriches key entities/IOCs with external sources, and produces actionable reporting plus starter detection content.
This repo is intentionally generic (not tied to a specific enterprise ecosystem). Integrations are provided as interfaces + examples you can adapt.
- Fetch threat intel from free sources (advisories / bulletins / feeds).
- Normalize & compress content to optimize token usage (HTML → text, boilerplate removal, dedupe, “toon”/summary conversion, chunking).
- Use a local model (template assumes Mistral 7B via Ollama).
- The model can call tools to:
- Query a CMDB (example: OpenSearch index) to understand exposed/high-value assets.
- Query a Top-20 threat actor list (example: SQL table) to prioritize relevant actors.
- Output: a ranked list of “concerning” items with rationale and what to do next.
- Extract from bulletins:
- Threat actors, campaigns, malware
- IOCs (hashes, IPs, domains, emails, URLs, etc.)
- Use tools to enrich entities/IOCs via APIs.
- Free API sources (examples to wire in):
- AlienVault OTX (pulses/indicators)
abuse.chThreatFox (IOC context)abuse.chMalwareBazaar (hash intelligence)abuse.chURLhaus (malicious URL intelligence)- urlscan.io (URL / domain scan context)
- Paid sources (placeholders):
- Recorded Future
- DomainTools
- VirusTotal
- GreyNoise
- (Add others as needed)
- Free API sources (examples to wire in):
- Produce:
- Executive summary (daily “news bulletin” for leadership)
- Operational actions & defensive recommendations that are specific (environment-aware) and avoid generic advice like “enable MFA”.
- Generate starter detection content:
- OpenSearch detections
- YARA rules
- Suricata rules
- Python 3.11+
- Ollama installed and running
ollama pull mistral:7bCreate a local .env from .env.example and set API keys you have (free and/or paid). Keys are optional; the template will run with enrichment disabled.
python -m cti_agent run --input examples/sample_bulletin.txt --out out/flowchart LR
A[Free CTI Sources] --> B[Fetch + Normalize + Token Optimize]
B --> C["Triage (LLM via Ollama)"]
C -->|tool calls| D["CMDB (OpenSearch)"]
C -->|tool calls| E["Top Actor List (SQL)"]
C --> F[Enrichment Loop]
F --> G[External CTI APIs]
F --> H[Analysis + Reporting]
H --> I[Detections: OpenSearch / YARA / Suricata]
For an AWS-native deployment (alternative to local Ollama), see cloud_architecture.md.
flowchart LR
S["EventBridge schedule"] --> L1["Lambda: fetch + toon optimize"]
L1 --> SM["AWS Secrets Manager (API keys)"]
L1 --> B1["S3: raw + normalized bulletins"]
B1 --> L2["Lambda: orchestrate pipeline"]
L2 --> BR["Amazon Bedrock (LLM)"]
BR -->|tool calls| T1["Lambda tools: CMDB query (OpenSearch)"]
BR -->|tool calls| T2["Lambda tools: top actors (RDS/Aurora)"]
BR -->|tool calls| T3["Lambda tools: CTI enrichers (external APIs)"]
L2 --> O["S3: reports + detections + run metadata"]
cti_agent/: Python package (pipeline + tool interfaces)connectors/: Example connector implementations (OpenSearch, SQL, CTI APIs)examples/: Sample bulletins and configout/: Generated reports/detections (gitignored)
examples/sample_outputs/cti_report.mdexamples/sample_outputs/run_metadata.json
This template is designed to work within LLM context limits while improving accuracy and lowering cost.
- Goal: shrink raw bulletin/feed content before any LLM step.
- Approach: normalize + compress content into a “toon” representation (e.g., remove boilerplate, dedupe, chunk/summarize).
- Metric:
run_metadata.jsonrecordstoon_optimizationincludingpercent_saved(example: ~95% reduction for JSON-heavy pulls).
- Map step: each kept bulletin becomes a compact Fact Card (small JSON) with:
- entities (actors/campaigns/malware/vulns/products)
- IOCs (typed)
- SCC-style signals (source credibility, confidence, exploit likelihood, novelty)
- key points and limited evidence
- Reduce step: triage/report/detections are generated from Fact Cards, not full bulletin text.
- Fact Cards are scored deterministically and we select top N items.
- This reduces noise and prevents paying the model to “sort the internet.”
- We only enrich IOCs from the selected top N items (not every IOC from every feed).
- Enrichment results are cached (
out/.cache/enrichment_cache.json) to avoid repeated API calls and reduce cost/rate-limit risk.
- Internal context tools (CMDB/OpenSearch, SQL top actors) should return compact summaries suitable for prompts.
- This improves grounding while keeping token budgets predictable.
- Extraction outputs are designed as schema-constrained JSON (Fact Cards) with validation.
- When parsing fails, the pipeline can drop/flag the item rather than silently hallucinating structure.
- This is a template: you’ll plug in your org’s data sources, auth, and schemas.
- Do not commit secrets. Use
.envlocally and keep.env.examplesanitized.