A full-stack, real-time system simulating a virtual SOC where LLM agents detect, explain, and mitigate cyberattacks autonomously.
Neural Fortress LIVE is an autonomous AI cyber defense network that simulates a virtual Security Operations Center (SOC). The system leverages LLM agents to detect, explain, and mitigate cyberattacks in real-time, providing a comprehensive platform for cybersecurity training, testing, and demonstration.
Neural Fortress LIVE performs the following key functions:
- Real-time Attack Simulation: Generates realistic cyber attack patterns through the RedTeam agent
- Anomaly Detection: Uses ML algorithms to identify unusual patterns in network traffic and system logs
- Threat Analysis: Maps detected anomalies to MITRE ATT&CK framework using RAG techniques
- Natural Language Explanations: Generates human-readable explanations of detected threats
- Automated Response: Recommends and simulates defensive actions in a sandboxed environment
- Performance Evaluation: Tracks system metrics like detection accuracy and response time
graph TD
A[RedTeamAgent] -->|Attack Events| B[Kafka]
B -->|Log Ingestion| C[WatcherAgent]
C -->|Anomalies| D[BlueTeamAgent]
D -->|Context Query| E[MITRE ATT&CK RAG]
D -->|Threat Alert| F[AnalystAgent]
F -->|Explanation| G[Dashboard]
F -->|Mitigation Request| H[DefenseAgent]
H -->|SOAR Actions| I[Sandboxed Environment]
J[MemoryAgent] <-->|Vector Store| D
J <-->|Vector Store| F
K[Frontend] <-->|WebSockets| G
The backend is structured into several key modules:
-
Agents Module (
backend/agents/):base_agent.py: Abstract base class defining common agent functionalitywatcher_agent.py: Monitors logs and detects anomalies using ML modelsredteam_agent.py: Simulates various attack patterns (brute force, SQL injection, etc.)blueteam_agent.py: Analyzes anomalies and correlates with MITRE ATT&CK frameworkanalyst_agent.py: Generates natural language explanations of security eventsdefense_agent.py: Recommends and executes mitigation actionsmemory_agent.py: Maintains historical context of security events
-
AI Module (
backend/ai/):llm_explainer.py: Generates natural language explanations using LLMsmitre_rag.py: Implements RAG for MITRE ATT&CK framework knowledge retrievalcti_indexer.py: Indexes and retrieves cyber threat intelligenceguardrails.py: Implements safety measures for LLM inputs and outputs
-
ML Module (
backend/ml/):anomaly_detector.py: Implements anomaly detection using IsolationForestllm_integration.py: Handles integration with LLM servicesllm_analyzer.py: Analyzes security alerts using LLMs
-
API Module (
backend/api/routes/):- RESTful endpoints for authentication, alerts, defense actions, and simulations
-
Core Module (
backend/core/):config.py: System configuration and environment variablesdb.py: Database connection and modelsutils.py: Utility functionsws.py: WebSocket handling for real-time updates
-
Evaluation Module (
backend/evals/):metrics.py: Tracks system performance metricsreplay_dataset.py: Provides datasets for system evaluation
- Backend: FastAPI (Python) + Celery + Redis + PostgreSQL
- Streaming: Kafka (attack/event feed) + WebSockets (Socket.IO)
- ML: scikit-learn IsolationForest + PyOD for anomaly detection
- LLM Layer: LangChain + GPT-4 / Claude 3 + FAISS (RAG with MITRE ATT&CK, CVE)
- Frontend: React + Tailwind + Zustand + Socket.IO + Recharts + D3.js
- Infra: Docker Compose (+ optional K8s manifests)
- Auth: JWT + RBAC (Admin, Analyst, RedTeam, BlueTeam)
-
FastAPI Framework:
- Provides high-performance, async API endpoints
- Automatic OpenAPI documentation
- Dependency injection for services
-
Kafka Integration:
- Used for streaming attack events and logs
- Implemented with
aiokafkafor async processing - Topics:
logs,alerts,actions
-
Redis Usage:
- Caching for performance optimization
- Pub/Sub for real-time notifications
- Session management
-
ML Pipeline:
- Feature extraction from log data
- Anomaly detection using IsolationForest
- Batch and real-time processing capabilities
-
LLM Integration:
- RAG implementation for MITRE ATT&CK knowledge
- Guardrails for safe LLM input/output
- Structured output parsing for consistent results
-
React Components:
- Modular component architecture
- Real-time updates via Socket.IO
- Responsive design with Tailwind CSS
-
Data Visualization:
- Network topology visualization with D3.js
- Time-series charts with Recharts
- Alert feed with real-time updates
-
State Management:
- Zustand for global state
- WebSocket integration for live updates
- Authentication and session handling
- WatcherAgent β consumes Kafka logs, extracts IOCs, scores anomalies
- RedTeamAgent β simulates live attacks (brute-force, SQLi, port scan)
- BlueTeamAgent β analyzes anomalies, matches MITRE TTPs via RAG, escalates threat
- AnalystAgent β generates natural-language LLM reports with structured output
- DefenseAgent β runs safe SOAR actions (block IP, disable user, isolate host) as dry-runs
- MemoryAgent β maintains semantic vector store of past incidents and agent decisions
- Purpose: Monitors system logs and network traffic for anomalies
- Implementation:
- Uses
anomaly_detector.pyto identify unusual patterns - Extracts Indicators of Compromise (IOCs) from logs
- Enriches alerts with additional context (geoIP, reputation data)
- Publishes anomalies to Kafka for further processing
- Uses
- Purpose: Simulates realistic cyber attacks for testing and training
- Implementation:
- Generates various attack patterns (brute force, SQL injection, port scanning)
- Configurable attack intensity and frequency
- Produces realistic log entries that mimic actual attacks
- Supports scheduled and on-demand attack simulations
- Purpose: Analyzes detected anomalies and determines threat level
- Implementation:
- Correlates anomalies with known attack patterns
- Uses
mitre_rag.pyto map events to MITRE ATT&CK framework - Calculates confidence scores for detected threats
- Escalates significant threats to the AnalystAgent
- Purpose: Generates human-readable explanations of security events
- Implementation:
- Uses
llm_explainer.pyto create natural language reports - Provides threat assessment and impact analysis
- Recommends appropriate mitigation actions
- Ensures explanations follow security best practices via guardrails
- Uses
- Purpose: Executes or simulates defensive actions
- Implementation:
- Validates proposed actions using
guardrails.py - Simulates actions in a sandboxed environment
- Provides feedback on action effectiveness
- Maintains an audit log of all actions
- Validates proposed actions using
- Purpose: Maintains historical context for better decision-making
- Implementation:
- Stores past incidents and responses in a vector database
- Provides relevant historical context for similar events
- Enables learning from past incidents
- Improves detection and response over time
- Docker and Docker Compose
- Python 3.9+
- Node.js 16+
- Clone the repository:
git clone https://github.com/yourusername/neural-fortress-live.git
cd neural-fortress-live- Configure environment variables:
cp .env.example .env
# Edit .env file with your configuration settings- Start the application using Docker Compose:
docker-compose up -d- Access the dashboard at http://localhost:3000
-
Backend Setup:
# Install backend dependencies pip install -r requirements.txt # Start backend services individually (development mode) cd backend uvicorn main:app --reload --host 0.0.0.0 --port 8000
-
Frontend Setup:
# Install frontend dependencies cd frontend npm install # Start frontend development server npm start
-
Infrastructure Setup:
# Start supporting services only docker-compose up -d kafka zookeeper redis postgres -
Running Tests:
# Backend tests cd backend pytest # Frontend tests cd frontend npm test
| Username | Password | Role | Description |
|---|---|---|---|
| admin | fortress-admin | Admin | Full system access |
| analyst | fortress-analyst | Analyst | View and analyze alerts |
| redteam | fortress-red | RedTeam | Simulate attacks |
| blueteam | fortress-blue | BlueTeam | Respond to incidents |
- RedTeam attack injection β Kafka topic
- WatcherAgent ingests, normalizes, enriches (geoIP, whois)
- BlueTeamAgent detects pattern β queries RAG for context
- AnalystAgent explains via LLM β streams reasoning tokens
- DefenseAgent triggers sandboxed mitigation (dry-run)
- Dashboard updates live: alerts, logs, 3D network visualization
The system implements a real-time data flow pipeline:
-
Attack Generation:
- RedTeamAgent generates attack events in JSON format
- Events are published to Kafka topic
logs - Example attack event:
{ "timestamp": "2023-07-15T14:22:33Z", "source_ip": "192.168.1.100", "target_ip": "10.0.0.5", "protocol": "TCP", "port": 22, "action": "CONNECT", "status": "FAILED", "user": "admin", "attempts": 5 } -
Anomaly Detection:
- WatcherAgent consumes events from Kafka
- ML pipeline extracts features and detects anomalies
- Anomalies are enriched with additional context
- Alerts are published to Kafka topic
alerts
-
Threat Analysis:
- BlueTeamAgent consumes alerts from Kafka
- MITRE RAG system provides attack technique context
- Threat score is calculated based on multiple factors
- High-confidence threats are escalated
-
Response Generation:
- AnalystAgent generates natural language explanations
- DefenseAgent recommends mitigation actions
- Actions are validated through guardrails
- Results are sent to frontend via WebSockets
-
Frontend Visualization:
- Dashboard receives real-time updates via Socket.IO
- Network map visualizes affected systems
- Alert feed displays latest threats
- Detailed view shows full analysis and recommendations
- Prompt injection & PII filter in guardrails.py
- DefenseAgent limited to predefined safe actions
- All LLM outputs validated by JSON schema
- Token-based session isolation for agents
- Audit log for every SOAR and LLM event
The system implements several security measures to ensure safe operation:
-
Input Sanitization:
- All user inputs and log data are sanitized before processing
- PII detection and redaction using regex patterns
- Prompt injection prevention for LLM interactions
-
Action Validation:
- Defense actions are validated against an allowlist
- Actions are executed in a sandboxed environment
- Potentially harmful actions require explicit approval
-
Output Validation:
- LLM outputs are validated against predefined schemas
- Structured outputs ensure consistent and safe responses
- Confidence scores help identify uncertain recommendations
-
Audit Logging:
- All system actions are logged for accountability
- Logs include timestamps, actors, actions, and outcomes
- Audit logs are immutable and tamper-evident
The system includes an evaluation pipeline that:
- Replays sample RedTeam scenarios β computes detection precision/recall
- Graphs Mean Time To Detect (MTTD) & Mean Time To Respond (MTTR)
- Evaluates LLM explanation confidence vs correctness
- Generates confusion matrix + trend charts
The evaluation system is implemented in backend/evals/ and notebooks/evals.ipynb:
-
Performance Metrics:
- Detection accuracy (precision, recall, F1-score)
- Response times (MTTD, MTTR)
- LLM quality metrics (relevance, accuracy, completeness)
-
Replay Dataset:
- Pre-defined attack scenarios for consistent testing
- Includes various attack types (brute force, SQL injection, etc.)
- Configurable parameters for scenario customization
-
Visualization:
- Confusion matrices for detection performance
- Time-series plots for response times
- Distribution charts for LLM quality metrics
This project is licensed under the MIT License - see the LICENSE file for details.
The project uses Docker Compose for containerization:
-
Backend Container:
- Base image: Python 3.9
- Exposes port 8000 for API access
- Mounts code and data volumes
- Runs FastAPI with Uvicorn server
-
Frontend Container:
- Multi-stage build with Node.js and Nginx
- Builds React app and serves static files
- Exposes port 80 for web access
- Configured for SPA routing
-
Supporting Services:
- Kafka and Zookeeper for message streaming
- Redis for caching and pub/sub
- PostgreSQL for persistent storage
The codebase follows these best practices:
-
Modular Architecture:
- Clear separation of concerns
- Dependency injection for testability
- Interface-based design for flexibility
-
Asynchronous Processing:
- FastAPI async endpoints
- Kafka consumers with aiokafka
- WebSocket handlers for real-time updates
-
Error Handling:
- Comprehensive exception handling
- Graceful degradation
- Detailed error logging
-
Testing Strategy:
- Unit tests for core functionality
- Integration tests for component interactions
- End-to-end tests for critical flows
For production deployment, consider:
-
Scaling:
- Horizontal scaling of backend services
- Kafka partitioning for load distribution
- Redis clustering for high availability
-
Security:
- HTTPS with proper certificates
- API rate limiting
- Regular security audits
-
Monitoring:
- Prometheus metrics
- Grafana dashboards
- Log aggregation with ELK stack#