A graph-based security system that detects coordinated account takeover campaigns by analyzing patterns across multiple data points (IPs, devices, users, etc.) that would be invisible when looking at individual users.
✅ Automatic Detection
- Low-and-slow distributed credential stuffing
- Rapid burst attacks (botnets)
- Coordinated attack campaigns
- Impossible travel patterns
✅ Graph Analysis
- Entities: IP, Device, ASN, User Agent, Location, User, Session
- Relationships: Tracks how entities connect
- Connected component clustering
- Risk scoring with confidence levels
✅ Incident Management
- Auto-groups related security events
- Evidence chains with "why clustered" reasoning
- Campaign metrics and attack velocity tracking
- Analyst workflow support
✅ Response Tooling
- Mass session revocation
- Entity blocklisting (IPs, devices, etc.)
- Graph traversal and visualization
- Audit trail of all actions
The system uses existing dependencies:
mongoose- Database modelsgeolib- Geographic calculationsnode-cron- Scheduled analysis
The system initializes automatically when the server starts:
// In server.js - already added
const attackGraphIntegrationService = require('./services/attackGraphIntegrationService');
mongoose.connect(process.env.MONGODB_URI)
.then(() => {
// ... other initialization
attackGraphIntegrationService.initialize();
});MongoDB will automatically create indexes on first run:
- Entity lookups (type, value, risk score)
- Relationship queries
- Incident filtering
After starting the server, verify the system is running:
# Check integration status
curl -H "Authorization: Bearer YOUR_TOKEN" \
http://localhost:3000/api/attack-graph/integration/status
# View dashboard
curl -H "Authorization: Bearer YOUR_TOKEN" \
http://localhost:3000/api/attack-graph/dashboardThe system monitors these security events:
LOGIN_ATTEMPTSUSPICIOUS_LOGINBRUTE_FORCE_ATTEMPT2FA_FAILURESESSION_ANOMALY_DETECTEDIMPOSSIBLE_TRAVEL_DETECTED
Events are automatically processed in batches every 5 seconds.
For each event, the system:
- Extracts entities (IP, device, user, etc.)
- Creates relationships between entities
- Updates risk scores
- Analyzes timing patterns
The system runs detection algorithms:
- Real-time: Burst attack detection (5-minute window)
- Near real-time: Distributed attacks (batch processing)
- Scheduled: Full graph analysis every 6 hours
When patterns are detected:
- Events grouped into incidents
- Confidence score calculated (0-100)
- Severity assigned (low/medium/high/critical)
- Evidence chain built
- "Why clustered" reasoning generated
Analysts use the API to:
- Review incident dashboard
- Investigate entity relationships
- Traverse attack graphs
- Take response actions
Edit services/attackGraphDetectionService.js:
this.config = {
lowAndSlowWindowMs: 24 * 60 * 60 * 1000, // 24 hours
burstWindowMs: 5 * 60 * 1000, // 5 minutes
minEventsForIncident: 3,
minConfidenceScore: 50,
maxGraphDepth: 4,
burstThreshold: 10, // events per 5 min = burst
lowAndSlowThreshold: 50, // events per 24 hrs = campaign
distributedIpThreshold: 5 // unique IPs = distributed
};Edit services/attackGraphIntegrationService.js:
this.config = {
batchSize: 50, // Events per batch
processingIntervalMs: 5000, // Batch frequency
fullAnalysisSchedule: '0 */6 * * *', // Cron schedule
enableRealTimeProcessing: true
};All endpoints require authentication + security:analyst role.
GET /api/attack-graph/incidents
GET /api/attack-graph/incidents/:incidentId
GET /api/attack-graph/incidents/:incidentId/graph
GET /api/attack-graph/entities/:entityId
POST /api/attack-graph/entities/:entityId/traverse
GET /api/attack-graph/entities/high-risk
POST /api/attack-graph/entities/:entityId/blocklist
POST /api/attack-graph/incidents/:incidentId/revoke-sessions
POST /api/attack-graph/incidents/:incidentId/assign
PUT /api/attack-graph/incidents/:incidentId/status
GET /api/attack-graph/metrics
GET /api/attack-graph/dashboard
POST /api/attack-graph/analyze (admin only)
-
Detection (automatic)
- System detects 8 IPs trying same user credentials
- Creates incident:
DISTRIBUTED_CREDENTIAL_STUFFING - Confidence: 75/100, Severity: HIGH
-
Investigation
# View incident details curl -H "Authorization: Bearer $TOKEN" \ http://localhost:3000/api/attack-graph/incidents/INC-20260301-ABC123 # Visualize attack graph curl -H "Authorization: Bearer $TOKEN" \ http://localhost:3000/api/attack-graph/incidents/INC-20260301-ABC123/graph
-
Response
# Blocklist all attacking IPs curl -X POST -H "Authorization: Bearer $TOKEN" \ -H "Content-Type: application/json" \ -d '{"reason": "Credential stuffing", "expiresInHours": 168}' \ http://localhost:3000/api/attack-graph/entities/IP_ENTITY_ID/blocklist # Revoke all related sessions curl -X POST -H "Authorization: Bearer $TOKEN" \ -H "Content-Type: application/json" \ -d '{"reason": "Security incident"}' \ http://localhost:3000/api/attack-graph/incidents/INC-20260301-ABC123/revoke-sessions
-
Resolution
# Update status curl -X PUT -H "Authorization: Bearer $TOKEN" \ -H "Content-Type: application/json" \ -d '{"status": "MITIGATED", "notes": "All IPs blocked, sessions revoked"}' \ http://localhost:3000/api/attack-graph/incidents/INC-20260301-ABC123/status # Validate for metrics curl -X POST -H "Authorization: Bearer $TOKEN" \ -H "Content-Type: application/json" \ -d '{"isTruePositive": true}' \ http://localhost:3000/api/attack-graph/incidents/INC-20260301-ABC123/validate
Check integration service status:
# Status check
curl http://localhost:3000/api/attack-graph/integration/status
# Should return:
{
"initialized": true,
"queueSize": 0,
"isProcessing": false,
"config": { ... }
}Monitor from logs:
[Attack Graph Integration] Processing batch of 50 events
[Attack Graph Integration] Batch complete: 50 successful, 0 failed
[Attack Graph Integration] Starting scheduled full graph analysis
[Attack Graph Integration] Full analysis complete: { eventsAnalyzed: 1247, durationMs: 3421 }
View system performance:
curl -H "Authorization: Bearer $TOKEN" \
http://localhost:3000/api/attack-graph/metricsKey metrics:
- Precision: % of incidents that are real threats
- Active Incidents: Currently under investigation
- High-Risk Entities: Entities requiring attention
Check:
-
Is integration service initialized?
# Check logs for: "[Attack Graph Integration] Initialized successfully" -
Are security events being created?
// Check SecurityEvent collection in MongoDB db.securityevents.find().limit(10).sort({createdAt: -1})
-
Are thresholds too high?
- Lower
minEventsForIncidentin config - Lower
minConfidenceScorein config
- Lower
Solutions:
- Increase
batchSizeto process more events at once - Increase
processingIntervalMsto reduce frequency - Reduce
maxGraphDepthto limit traversal depth - Add more MongoDB indexes
To reduce:
- Increase
minConfidenceScorethreshold - Increase
burstThresholdandlowAndSlowThreshold - Increase
distributedIpThreshold - Mark incidents as false positives for metrics
Remember: Always validate incidents to improve detection over time!
If event queue grows too large:
- Check MongoDB change streams are working
- Increase batch processing frequency
- Reduce analysis window sizes
- All endpoints require
security:analystrole - Manual analysis requires
security:adminrole - Session revocation tracked per analyst
- Blocklisting requires reason documentation
Consider implementing:
- Archive old incidents (>90 days)
- Purge resolved incidents (>1 year)
- Rotate entity data
- Clean expired blocklist entries
All actions are logged:
- Who blocked/unblocked entities
- Who revoked sessions
- Who changed incident status
- All analyst notes timestamped
models/AttackGraphEntity.js- Graph nodesmodels/AttackGraphRelationship.js- Graph edgesmodels/SecurityIncident.js- Incident grouping
services/attackGraphDetectionService.js- Detection engineservices/attackGraphIntegrationService.js- Event processing
routes/attackGraph.js- API endpoints
ISSUE_848_IMPLEMENTATION_SUMMARY.md- Full technical docsATTACK_GRAPH_ANALYST_PLAYBOOK.md- Analyst guide
server.js- Routes registered, service initialized
For detailed documentation, see:
- Technical Docs:
ISSUE_848_IMPLEMENTATION_SUMMARY.md - Analyst Guide:
ATTACK_GRAPH_ANALYST_PLAYBOOK.md
For issues:
- Check server logs
- Review MongoDB collections
- Verify RBAC permissions
Status: ✅ Production Ready
Issue: #848
Implementation Date: March 1, 2026