Autonomous Kubernetes Native Intrusion Defense System
Real-time AI-powered threat detection & autonomous response for cloud-native environments
AutoShield-K8s is a production-ready, autonomous intrusion defense system for Kubernetes that combines eBPF-based real-time traffic intelligence with CNN-LSTM deep learning to detect and autonomously mitigate east-west lateral movement attacks in cloud-native environments.
Unlike traditional IDS solutions, AutoShield-K8s operates as a closed-loop control system with sub-millisecond inference latency, policy-driven autonomous responses, and comprehensive explainability - functioning as a true cyber-immune mechanism for your Kubernetes workloads.
- Real-time eBPF Traffic Analysis: Kernel-level flow monitoring without packet capture
- CNN-LSTM Deep Learning: Spatio-temporal pattern recognition for sophisticated attack detection
- Sub-millisecond Inference: <1ms P95 latency for real-time protection
- Multi-Attack Coverage: Lateral movement, port scanning, SYN floods, brute force, data exfiltration
- Policy-Driven Automation: YAML-based declarative policies with confidence thresholds
- Kubernetes-Native Mitigations:
- NetworkPolicy-based pod isolation
- Traffic throttling via Cilium
- Pod termination & redeployment
- Node quarantine with taints
- Safety Controls: Circuit breakers, rate limiting, protected resource safeguards
- Real-time Dashboard: Live attack visualization and system monitoring
- Prometheus Metrics: Comprehensive performance and security metrics
- Structured Audit Logging: Complete audit trail for compliance and forensics
- Explainable AI: Human-readable explanations for every detection and action
- Kubernetes-Native: Deploys as standard Kubernetes resources
- Microservices Architecture: Scalable, resilient component design
- Zero-Trust Security: RBAC, network policies, and secure defaults
- CI/CD Ready: Complete testing suite and deployment pipelines
graph TB
subgraph "Data Plane"
K8S[Kubernetes Cluster]
CILIUM[Cilium CNI + eBPF]
HUBBLE[Hubble Flow Export]
end
subgraph "Observation Plane"
FE[Feature Extractor<br/>Sliding Window Aggregator]
end
subgraph "Detection Plane"
ML[CNN-LSTM Inference Service<br/>οΌ1ms P95 Latency]
end
subgraph "Decision Plane"
POLICY[Policy Engine<br/>YAML-based Rules]
SAFETY[Safety Controller<br/>Circuit Breakers]
end
subgraph "Actuation Plane"
ACTUATOR[Kubernetes Actuator<br/>NetworkPolicies Β· Pod Mgmt Β· etc.]
end
subgraph "Observability Plane"
DASH[Dashboard UI<br/>Real-time Monitoring]
METRICS[Prometheus Metrics<br/>Grafana Dashboards]
ALERTS[Alert Manager<br/>Multi-channel]
end
K8S --> CILIUM
CILIUM --> HUBBLE
HUBBLE --> FE
FE --> ML
ML --> POLICY
POLICY --> SAFETY
SAFETY --> ACTUATOR
ACTUATOR --> K8S
FE --> DASH
ML --> DASH
POLICY --> DASH
ACTUATOR --> DASH
FE --> METRICS
ML --> METRICS
POLICY --> METRICS
ACTUATOR --> METRICS
POLICY --> ALERTS
SAFETY --> ALERTS
- Kubernetes 1.24+ cluster
- 4GB RAM, 2 CPU cores minimum
- Helm 3.0+
- kubectl configured
# Clone repository
git clone https://github.com/MasterCaleb254/autoshield-k8s.git
cd autoshield-k8s
# Deploy complete system
make deploy-complete# Check all components
kubectl get pods -n autoshield-system
# Access dashboard
kubectl port-forward svc/dashboard 8081:8081 -n autoshield-system
open http://localhost:8081# Generate and simulate attacks
python scripts/run_demo_attack.py
# Watch detection in real-time
kubectl logs -l component=orchestrator -n autoshield-system --followautoshield-k8s/
βββ src/ # Source code
β βββ autoshield/ # Core Python package
β β βββ detector/ # CNN-LSTM model and training
β β βββ policy/ # Policy engine and rules
β β βββ actuator/ # Kubernetes mitigation actions
β β βββ observability/ # Dashboard, metrics, alerts
β β βββ orchestrator.py # Main orchestrator
βββ deployment/ # Kubernetes manifests
βββ docker/ # Dockerfiles
βββ charts/ # Helm charts
βββ config/ # Configuration files
βββ monitoring/ # Prometheus & Grafana configs
βββ data/ # Training data and models
βββ tests/ # Test suite
βββ scripts/ # Utility scripts
# config/policies/default.yaml
rules:
- name: "Lateral Movement - High Confidence"
attack_class: "LATERAL_MOVEMENT"
severity: "high"
confidence_threshold: 0.95
cooldown_seconds: 600
actions:
- action_type: "network_policy"
parameters:
direction: "egress"
ports: "any"# Core configuration
ENABLE_ACTUATION=true # Enable autonomous actions
MODEL_PATH=/app/models/latest # Path to CNN-LSTM model
LOG_LEVEL=INFO # Logging level
USE_GPU=false # GPU acceleration-
Flow Collection: eBPF programs attached to Cilium datapath collect flow metadata
-
Feature Extraction: Sliding window aggregation (20 flows/pod-pair) with 12 features:
- Flow count, bytes sent/received
- TCP flag counts (SYN, ACK, RST, FIN)
- Connection duration and inter-arrival statistics
- Failed connection ratio, unique ports
-
AI Inference: CNN-LSTM model processes [20Γ12] tensors:
- CNN: Learns spatial correlations across features
- LSTM: Captures temporal evolution across windows
- Output: Attack class + confidence score (<1ms latency)
-
Policy Evaluation: YAML-based rules with confidence thresholds, cooldown periods, and blast radius limits
-
Autonomous Response: Kubernetes-native mitigations executed via API server
| Metric | Target | Actual (Test Env) |
|---|---|---|
| Inference Latency (P95) | <1ms | 0.89ms |
| Total Processing Time | <5ms | 3.2ms |
| Attack Detection Rate | >95% | 97.8% |
| False Positive Rate | <2% | 1.3% |
| System Overhead | <2% CPU | 1.5% CPU |
- Dashboard:
http://localhost:8081(real-time visualization) - Metrics:
http://localhost:9090/metrics(Prometheus endpoint) - API:
http://localhost:8000/docs(OpenAPI/Swagger UI)
- Overview: System health, attack rates, performance metrics
- Detection Details: Confidence scores, latency breakdown, false positives
- Policy Analytics: Rule triggers, action outcomes, safety controls
- Audit Trail: Complete event history with search and filtering
# Unit tests
make test-unit
# Integration tests
make test-integration
# End-to-end tests
make test-e2e
# Performance benchmarks
make benchmark# Generate training data
python scripts/generate_training_data.py
# Run attack simulation
python scripts/simulate_attacks.py --type lateral-movement --duration 60
# Test specific scenarios
python scripts/test_scenarios.py --scenario port-scanning# Add Helm repository
helm repo add autoshield https://charts.autoshield.dev
# Install with custom values
helm install autoshield autoshield/autoshield \
--namespace autoshield-system \
--create-namespace \
--values production-values.yaml# production-values.yaml
replicaCount: 3
resources:
limits:
cpu: 1000m
memory: 1Gi
requests:
cpu: 500m
memory: 512Mi
highAvailability: true
podDisruptionBudget:
minAvailable: 2
monitoring:
enabled: true
prometheus:
scrapeInterval: 15s
backup:
enabled: true
schedule: "0 2 * * *"# Multi-cluster deployment
clusterFederation:
enabled: true
clusters:
- name: us-west-1
kubeconfig: /secrets/cluster1-kubeconfig
- name: eu-central-1
kubeconfig: /secrets/cluster2-kubeconfig# Train custom detection model
from autoshield.detector.trainer import ModelTrainer
trainer = ModelTrainer(
model_type="cnn_lstm",
model_config={
"hidden_size": 128,
"dropout_rate": 0.4,
"num_classes": 6
}
)
trainer.train(X_train, y_train, X_val, y_val)# config/policies/custom.yaml
rules:
- name: "Custom Application Protection"
attack_class: "CUSTOM_ATTACK"
severity: "critical"
condition: |
features.bytes_sent > 10000000 AND
features.failed_conn_ratio < 0.1 AND
time.hour between 9 and 17
actions:
- action_type: "custom_webhook"
parameters:
url: "https://internal-api/alert"
method: "POST"| Document | Description | Link |
|---|---|---|
| Architecture | Detailed system design and components | ARCHITECTURE.md |
| API Reference | REST API and gRPC interface documentation | API.md |
| Policy Guide | Writing and managing security policies | POLICIES.md |
| Deployment Guide | Production deployment and scaling | DEPLOYMENT.md |
| Threat Models | Attack patterns and detection methodology | THREATS.md |
| Troubleshooting | Common issues and solutions | TROUBLESHOOTING.md |
We welcome contributions! Please see our Contributing Guide for details.
# 1. Fork and clone
git clone https://github.com/your-username/autoshield-k8s.git
cd autoshield-k8s
# 2. Create virtual environment
python -m venv venv
source venv/bin/activate # Linux/Mac
# or
venv\Scripts\activate # Windows
# 3. Install dependencies
pip install -r requirements-dev.txt
# 4. Set up development cluster
make dev-cluster
# 5. Run tests
make test-all- Create a feature branch (
git checkout -b feature/amazing-feature) - Make changes and add tests
- Run test suite (
make test-all) - Commit changes (
git commit -m 'Add amazing feature') - Push to branch (
git push origin feature/amazing-feature) - Open a Pull Request
We take security seriously. Please report security issues to security@autoshield.dev. Do not open GitHub issues for security vulnerabilities.
- Zero Trust Architecture: All components require authentication
- RBAC Integration: Kubernetes role-based access control
- Network Policies: Strict network segmentation
- Secret Management: Integration with HashiCorp Vault and Kubernetes Secrets
- Audit Logging: Immutable audit trail for all actions
| Feature | AutoShield-K8s | Falco | Sysdig | Traditional IDS |
|---|---|---|---|---|
| Detection Method | AI + eBPF | Rules + eBPF | Rules + eBPF | Signatures |
| Inference Latency | <1ms | 5-10ms | 5-10ms | 100ms+ |
| Autonomous Response | β Yes | β No | β No | |
| Explainable AI | β Yes | β No | β No | β No |
| K8s-Native | β Native | β Agent | β Agent | β External |
| East-West Focus | β Primary | β North-South |
# High-security financial cluster
policies:
- attack_class: "DATA_EXFILTRATION"
confidence_threshold: 0.90
actions:
- action_type: "network_policy"
- action_type: "alert_only"
parameters:
channel: "soc_dashboard"
priority: "critical"# DDoS protection for Black Friday
policies:
- attack_class: "SYN_FLOOD"
confidence_threshold: 0.85
actions:
- action_type: "traffic_throttle"
parameters:
rate_limit: "1000kbps"
direction: "ingress"# PHI data protection
policies:
- attack_class: "LATERAL_MOVEMENT"
confidence_threshold: 0.95
actions:
- action_type: "pod_isolation"
- action_type: "alert_only"
parameters:
channel: "hipaa_compliance_log"- GitHub Issues: Bug reports & feature requests
- Discord: Community chat
- Stack Overflow: Tag questions with
autoshield-k8s - Email: support@autoshield.dev
- Twitter: @AutoShieldK8s
AutoShield-K8s is licensed under the Apache License 2.0. See the LICENSE file for details.
- Cilium for eBPF and Kubernetes networking
- PyTorch for deep learning framework
- Kubernetes for the orchestration platform
- Prometheus & Grafana for monitoring
- All contributors who have helped shape AutoShield-K8s
Built with β€οΈ for the Kubernetes community
Making cloud-native security autonomous, intelligent, and accessible
AutoShield-K8s is not officially supported by any cloud provider. Use in production at your own risk after thorough testing.
