AI & Agentic Workflows in Cybersecurity
Local offline LLMs (Ollama, Qwen3-Coder), automated triage, agentic security workflows, and prompt injection defense.
Overview
AI & Agentic Workflows in Cybersecurity explores the application of local, privacy-first artificial intelligence to vulnerability triage, security telemetry parsing, and agentic workflows. By running offline language models (e.g. Qwen3-Coder via Ollama) on dedicated local hardware, practitioners can analyze sensitive scan logs, triage findings, and generate remediation guidance without exposing proprietary security data to third-party cloud APIs.
Core Concepts
- Local Offline Execution: Running quantized neural models locally (via Ollama or llama.cpp) guarantees that proprietary scan output, network topology, and security credentials remain strictly inside the local boundary.
- Vulnerability Triage & Classification: Using models to parse verbose Nmap or vulnerability scan outputs, extract key CVEs, assess CVSS severity, and draft executive summaries.
- Agentic Reasoning (ReAct Pattern): Autonomous agents operate via cyclic reasoning: Thought → Tool Action → Observation → Final Answer. In security contexts, tool execution must be strictly gated with safety constraints.
- AI Security & LLM Guardrails: Mitigating OWASP Top 10 for LLMs risks (such as indirect prompt injection and unauthorized tool execution) through sandboxing, strict input sanitization, and structured JSON schemas.
Tools & Requirements
Ollama (local inference server), Qwen3-Coder (code & security reasoning model), Python 3, and a local compute stack (e.g. NVIDIA RTX GPU).
$ curl -fsSL https://ollama.com/install.sh | sh $ ollama run qwen2.5-coder:7b $ ollama list
Commands & Practical Examples
1. Querying Local Model via REST API
Send security scan output directly to local Ollama instance for structured JSON triage:
$ curl http://127.0.0.1:11434/api/generate -d '{
"model": "qwen2.5-coder:7b",
"prompt": "Analyze this Nmap output: 21/tcp open vsftpd 2.3.4. State CVE, CVSS score, and remediation in bullet points.",
"stream": false
}'
2. Python Automated Triage Script
A Python script connecting to the local AI compute stack to analyze scan findings automatically:
import requests, json
def triage_vulnerability(service_banner):
payload = {
"model": "qwen2.5-coder:7b",
"prompt": f"Given the service banner: '{service_banner}', output a JSON object with keys 'cve', 'severity', and 'remediation'.",
"format": "json",
"stream": False
}
resp = requests.post("http://127.0.0.1:11434/api/generate", json=payload)
return json.loads(resp.json()['response'])
result = triage_vulnerability("Apache httpd 2.4.49")
print(json.dumps(result, indent=2))
Practical Workflow (Agentic Security Pipeline)
- Telemetry Ingestion: Capture raw scan findings or authentication logs from test environment.
- Sanitization: Strip internal domain names and sensitive credentials prior to model prompting.
- Local Model Prompting: Execute structured prompt requesting risk classification and remediation steps.
- Schema Validation: Parse output using strict JSON schemas to discard hallucinations.
- Human-in-the-Loop Review: Verify technical recommendations before incorporating into formal security reports.
Common Mistakes & Troubleshooting
- Unverified Model Output: Never trust AI-generated exploit commands blindly. Language models can hallucinate non-existent flags or miscalculate CVSS metrics. Always verify findings manually.
- Cloud Data Leakage: Sending client or lab scan results to public third-party LLM APIs exposes confidential vulnerabilities. Always run models locally offline.
Security Considerations & Scoping
When building agentic workflows that have the ability to run shell commands or execute network probes, always enforce read-only tool limits, require explicit human confirmation for network actions, and isolate runners inside disposable Docker containers.
Related Topics
- Module 12: Security Automation with Python & Scripting
- Module 15: Penetration Testing Methodology
- Module 01: Nmap Reconnaissance & Scanning
Further Reading & TryHackMe Paths
- OWASP Guidance: OWASP Top 10 for Large Language Models.
- Project Source: Architecture derived from personal development of SentinelAI, Autonomous Pentesting Agent, and Local AI Compute Stack.