AI Red Teaming Lab 2: AI-Driven Threat Modeling, Attack Planning & STRIDE-GPT — a technical write-up
Lab 2 has two exercises. Exercise 1 is a Flask + Groq app ("SecOps Intelligence Hub") that ingests CTI/DFIR PDF reports, extracts MITRE ATT&CK techniques, and answers questions in two personas — a defensive CTI Report mode and an offensive Red Team mode. Exercise 2 uses STRIDE-GPT to generate a STRIDE threat model from an architecture diagram. The core lesson: the same report produces completely different output depending on the system prompt — persona engineering is the tool.
Attack path (how the steps chain)
- Ingest real adversary tradecraft — upload the APT-Shadow Dragon CTI report; the pipeline extracts text and indexes it for retrieval.
- Map to MITRE ATT&CK — regex + LLM extraction surfaces the techniques the actor actually used (T1566.001 phishing → T1053.005/T1547.001 persistence → T1003.001 LSASS dump → T1021.001 RDP → T1041 exfil).
- Flip the persona — the same context, re-prompted as a red teamer, explains why each technique works and which defensive gap it exploits.
- Generate the emulation plan — the scenario chain assembles a full kill chain: OSINT → macro spear-phish → persistence → credential theft → lateral movement → objective (fraudulent transfers).
- Model the target — STRIDE-GPT turns an architecture diagram into a threat model and attack tree, the planning step that precedes any engagement.
1. Exercise 1 — SecOps Intelligence Hub
1.1 Setup
cd "Labs-2/File Analysis"
python -m venv venv && source ./venv/bin/activate
pip install -r requirements.txt # flask, langchain-groq, faiss-cpu, PyMuPDF, easyocr...
# edit .env: GROQ_API_KEY=gsk_your_key
python app.py # http://127.0.0.1:5000
Look for [OK] GROQ_API_KEY loaded at startup. The first PDF upload downloads the
all-MiniLM-L6-v2 embedding model (~90 MB) — expect 30–120 s.
1.2 How the pipeline works (code walkthrough)
app.py— 4 endpoints:/upload(PDF → text → MITRE extraction → FAISS index),/ask(mode-routed Q&A),/scenario,/engagement. Sessions live in an in-memory dict — a restart wipes them.utils/pdf_reader.py— 3-stage extraction: PyMuPDF → pypdf → EasyOCR for scanned PDFs.mitre_map.py— regexT\d{4}(\.\d{3})?over the text, with keyword-inference fallback. The hard-codedMITRE_MAPonly names 7 techniques, so the upload summary shows "Unknown Technique" for the rest — the LLM still names them correctly in chat.chains.py— the teaching artifact: six LangChain chains onllama-3.1-8b-instant. CTI chains run at temperature 0.2 (factual/defensive), Red chains at 0.6 (creative/offensive). Same context, opposite objectives.graph.py— an alternative LangGraph pipeline (not wired into the routes) that does true top-4 retrieval RAG withllama-3.3-70b-versatile. Good contrast withapp.py's full-context stuffing.
1.3 Solution steps
- Upload
uploads/CTI Report - APT-Shadow Dragon.pdfin Report Ingestion. - CTI mode, Prompt 1: "Extract all MITRE ATT&CK technique IDs mentioned or implied in this report."
- Red Team mode, Prompt 1: "Explain why each technique is effective and what security gap it exploits."
- Scenario generation: click Generate (Red mode) or ask for a full attack scenario with initial access → persistence → lateral movement → objectives.
- Optional:
/engagementwith an industry parameter (e.g. "banking") for a tailored plan.
1.4 Expected results (APT-Shadow Dragon report)
Regex extraction should surface the kill-chain techniques:
- Recon: T1589 (Gather Victim Identity), T1594 (Search Victim-Owned Websites)
- Initial Access: T1566.001/.002 (Spearphishing Attachment/Link)
- Persistence: T1053.005 (Scheduled Task), T1547.001 (Registry Run Keys)
- Cred Access / PrivEsc: T1003.001 (LSASS Memory)
- Lateral Movement: T1021.001 (RDP)
- Discovery: T1083, T1135 · Exfil: T1041 · Impact: T1657 (Financial Theft)
Red Team mode should explain the gaps: T1566.001 exploits the human layer, T1003.001 exploits missing Credential Guard/EDR, T1021.001 exploits flat networks, T1041 exploits absent egress monitoring. The generated scenario chains OSINT → macro-laden spear-phish → DracoNet install → scheduled-task/run-key persistence → LSASS dump → RDP/WMI lateral movement → SWIFT terminal discovery → HTTPS exfil → fraudulent transfers.
2. Exercise 2 — STRIDE-GPT
git clone https://github.com/mrwadams/stride-gpt.git
cd stride-gpt && python -m venv venv && source ./venv/bin/activate
pip install -r requirements.txt
streamlit run main.py # http://localhost:8501
Fill in the app metadata for the provided Desktop application threat model diagram.png
(desktop app, no auth, not internet-facing, processes sensitive user files), upload the diagram, and
generate the threat model + attack tree. The diagram is a simple trust model: User ↔ Desktop App ↔ File System.
Expected STRIDE output for this diagram:
- Spoofing: no launch authentication; malicious file masquerading as a trusted document.
- Tampering: binary/config modification on disk; crafted input files abusing the parser.
- Repudiation: no audit logging — actions and file changes are unattributable.
- Information Disclosure: insecure temp files, world-readable permissions, crash dumps.
- DoS: malformed input crashing the parser; decompression bombs; file locking/deletion.
- EoP: file-parsing exploit → code exec as the user; DLL hijacking via writable load paths.
Typical mitigations generated: code signing, least-privilege execution, sandboxed parsing, secure file permissions, audit logging, signed auto-updates.
3. Troubleshooting
- 401 errors → placeholder still in
.env, or venv not activated. - Groq 429 rate limits → wait ~60 s; avoid re-uploading in a loop (this is why LLM-based MITRE inference is commented out in
mitre_map.py). - "Invalid session" → server restarted; re-upload the PDF.
- Port 5000 busy on macOS → disable AirPlay Receiver or change the port.
- Fresh Python 3.13/3.14 +
faiss-cpu/easyocrwheel issues → use Python 3.10–3.12.