Skip to content

itmesneha/CyberGuard

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

10 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

CyberGuard

Autonomous, trust-aware cyber defense system with human-in-the-loop oversight

CyberGuard uses LangGraph agents to make real-time security decisions, combining drift detection, digital twin simulation, and explainable AI to protect critical infrastructure.

๐ŸŽฏ Key Features

  • ๐Ÿค– Agentic AI (ReAct Loop): Autonomous LangGraph agent implementing the ReAct pattern (Reasoning + Acting)
    • Observe: Reason about incoming events and classify threats
    • Think: Reason about optimal actions based on trust, zone, and attack patterns
    • Act: Execute decisions or request human approval
  • ๐Ÿ“Š Drift Detection: Model trust based on PSI (Population Stability Index) scores
  • ๐Ÿ”„ Digital Twin: Safe simulation environment for testing defensive actions
  • ๐Ÿ‘ค Human-in-the-Loop: All destructive actions require human approval with full context
  • ๐Ÿ” Explainable AI: Full decision context with policy rules, trust metrics, and reasoning chains
  • ๐ŸŽจ Real-time Dashboard: Streamlit UI with live event tracking and approval panels
  • ๐Ÿ”„ Auto-Retraining: LLM-driven model retraining when drift is detected

๐Ÿ“‹ Quick Start

Local Development

# Install dependencies
uv sync

# Run Streamlit dashboard
uv run streamlit run app/streamlit_app.py

Access at: http://localhost:8501

Docker Deployment

# Build and run
docker-compose up -d

# Access dashboard
http://localhost:8080

See DEPLOYMENT.md for detailed deployment options.

๐Ÿ—๏ธ Architecture

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”     โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”     โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚  Data Streamer  โ”‚โ”€โ”€โ”€โ”€โ–บโ”‚  LangGraph Agent โ”‚โ”€โ”€โ”€โ”€โ–บโ”‚  Digital Twin   โ”‚
โ”‚ (CICIDS2017)    โ”‚     โ”‚   (ReAct Loop)   โ”‚     โ”‚   (Simulator)   โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜     โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜     โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
         โ–ฒ                       โ”‚                         โ”‚
         โ”‚                       โ”‚ CSV window              โ”‚
         โ”‚                       โ–ผ                         โ”‚
         โ”‚              โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”               โ”‚
         โ”‚              โ”‚ DriftCatcher APIโ”‚               โ”‚
         โ”‚              โ”‚ (Drift/Retrain) โ”‚               โ”‚
         โ”‚              โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜               โ”‚
         โ”‚                       โ”‚ trust + PSI            โ”‚
         โ”‚                       โ–ผ                         โ”‚
         โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                                 โ”‚
                    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
                    โ”‚                         โ”‚
                    โ–ผ                         โ–ผ
         โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
         โ”‚ Streamlit Dashboardโ”‚โ—„โ”€โ”€โ”€โ”‚  Human Operator  โ”‚
         โ”‚   (8080/8501)      โ”‚    โ”‚ (Approve/Reject) โ”‚
         โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Components

  1. LangGraph Agent - Autonomous decision engine with trust-aware thresholds
  2. Digital Twin - Network simulation for safe action testing
  3. DriftCatcher API - ML drift detection with PSI scoring
  4. Streamlit Dashboard - Real-time monitoring and approval interface
  5. Human-in-the-Loop - Approval workflow for destructive actions

See ARCHITECTURE.md for detailed architecture documentation.

๐Ÿš€ How It Works

1. Event Processing

CSV Event โ†’ Parse & Enrich โ†’ Window by Zone โ†’ LangGraph Agent

2. ReAct Agent Loop (Reasoning + Acting)

Observe (REASONING: classify attack, analyze threat)
  โ†“
Think (REASONING: evaluate trust, zone criticality, attack patterns)
  โ†“
Act (ACTION: execute defensive measure or request approval)
  โ†“
Observe (REASONING: analyze results) โ†’ Loop continues

ReAct Pattern Implementation:

  • Reasoning Steps: Agent reasons about event context, model trust, historical patterns
  • Acting Steps: Agent takes defensive actions (quarantine, isolate, escalate)
  • Continuous Loop: Each action's outcome feeds back into next observation cycle

3. Trust-Aware Actions

Trust Level PSI Range Behavior
HIGH < 0.1 Normal thresholds, fast response
MEDIUM 0.1-0.25 Higher thresholds, more cautious
LOW โ‰ฅ 0.25 No destructive actions, escalate only

4. Approval Workflow

Agent Decides Destructive Action
  โ†’ Mark needs_approval=True
  โ†’ Add to pending_approvals
  โ†’ Display in UI with full context
  โ†’ Human Approves/Rejects
  โ†’ Execute or Block action

๐Ÿ“Š Dashboard Panels

  • โš ๏ธ Pending Approvals - Actions awaiting human review
  • ๐Ÿค– Model Retraining - Active retraining jobs and history
  • ๐Ÿ” Decision Inspector - Last significant action with full context
  • ๐Ÿ“ˆ Model Trust & Drift - Trust levels and PSI scores per zone
  • ๐Ÿšจ Recent Attacks - Last 50 attack events
  • ๐Ÿ–ฅ๏ธ Host Status - Current state of all hosts
  • ๐Ÿ“‹ LangGraph Trace - Agent execution steps

๐Ÿ›ก๏ธ Trust-Aware Thresholds

DMZ Zone (Less Critical)

  • High Trust: 3+ attacks โ†’ quarantine
  • Medium Trust: 5+ attacks โ†’ quarantine
  • Low Trust: 7+ attacks โ†’ escalate only

Internal Zone (Critical Infrastructure)

  • High Trust: 5+ attacks โ†’ isolate
  • Medium Trust: 8+ attacks โ†’ isolate (requires approval)
  • Low Trust: Only escalate/monitor, no destructive actions

๐Ÿ”„ Model Retraining

When drift is detected (PSI โ‰ฅ 0.1):

  1. Digital Twin Agent analyzes drift severity (LLM-driven)
  2. Recommendation: retrain, monitor, or escalate
  3. If retraining recommended โ†’ trigger model retraining
  4. On success โ†’ reset zone trust to HIGH
  5. Display job status in UI

๐Ÿ“ Project Structure

CyberGuard/
โ”œโ”€โ”€ agents/           # LangGraph agent (observe, think, act nodes)
โ”œโ”€โ”€ app/              # Streamlit UI and background runner
โ”œโ”€โ”€ digital_twin/     # Network simulator and topology
โ”œโ”€โ”€ streaming/        # Event streamer and windowing
โ”œโ”€โ”€ tools/            # DriftCatcher API client
โ”œโ”€โ”€ config/           # Configuration files
โ”œโ”€โ”€ data/             # Network traffic CSV files
โ”œโ”€โ”€ Dockerfile        # Container image
โ”œโ”€โ”€ docker-compose.yml # Docker Compose setup
โ”œโ”€โ”€ ARCHITECTURE.md   # Detailed architecture docs
โ”œโ”€โ”€ DEPLOYMENT.md     # Deployment guide
โ””โ”€โ”€ APPROVAL_WORKFLOW.md # Human-in-the-loop workflow

๐Ÿ”ง Configuration

Environment Variables

Variable Default Description
DRIFTCATCHER_API_URL http://localhost:8000 DriftCatcher API endpoint
STREAMLIT_SERVER_PORT 8080 (Docker) / 8501 (local) Dashboard port

Configuration Files

  • config/settings.yaml - Window size, thresholds
  • digital_twin/topology.yaml - Network zones and hosts
  • pyproject.toml - Python dependencies

๐Ÿ“ฆ Dependencies

  • langgraph - Agent orchestration
  • langchain - LLM integration
  • streamlit - Dashboard UI
  • pandas - Data processing
  • requests - DriftCatcher API client
  • pyyaml - Configuration management

๐Ÿณ Docker Deployment

Quick Start

docker-compose up -d

Custom Configuration

docker run -d \
  -p 8080:8080 \
  -e DRIFTCATCHER_API_URL=http://192.168.1.100:8000 \
  -v $(pwd)/data:/app/data \
  -v $(pwd)/runtime:/app/runtime \
  cyberguard:latest

Production Deployment

๐Ÿ“ˆ Performance

  • Latency: ~10-50ms per event (observe โ†’ think โ†’ act)
  • Throughput: 1000+ events/sec
  • Drift Check: ~1-2 seconds per window (100 events)
  • Memory: ~200MB baseline, +10MB per 10K events

๐Ÿ”’ Security Features

  1. Approval Required: All destructive actions need human approval
  2. Trust Degradation: System becomes conservative as drift increases
  3. Digital Twin Testing: Actions tested in simulation first
  4. Audit Trail: Full decision history with reasoning
  5. Explainability: Every action has visible policy rule

๐Ÿ“š Documentation

๐Ÿ› ๏ธ Development

# Install dependencies
uv sync

# Run tests (if available)
uv run pytest

# Format code
uv run black .

# Type check
uv run mypy .

๐Ÿ”ฎ Future Enhancements

  • Multi-model ensemble for drift detection
  • Automated retraining without approval for low-risk zones
  • Real-time PCAP integration (live network traffic)
  • Advanced actions (firewall rules, VLAN isolation, honeypots)
  • Threat intelligence integration (MISP, STIX/TAXII)
  • Policy engine with user-defined rules
  • Multi-tenancy support

๐Ÿ“„ License

[Your License Here]

๐Ÿ‘ฅ Contributors

[Your Team/Contributors Here]

๐Ÿ™ Acknowledgments

  • CICIDS2017 Dataset for network traffic data
  • LangGraph for agent orchestration
  • Streamlit for rapid dashboard development

About

Autonomous, trust-aware cyber defense system with human-in-the-loop oversight CyberGuard uses LangGraph agents to make real-time security decisions, combining drift detection, digital twin simulation, and explainable AI to protect critical infrastructure.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors