Skip to content

Build rate limit bypass detection with behavioral anomaly scoring #615

Description

@Smartdevs17

Context

Static rate limits (100 req/min per IP, 1000 req/min per API key) are easy to bypass by distributing requests across multiple IPs or API keys.

Current Limitation/Problem

Distributed attacks (botnets, rotating API keys) bypass per-IP and per-key rate limits entirely. No behavioral anomaly detection exists.

Expected Outcome

ML-powered behavioral anomaly detection: model learns normal API usage patterns per key and per user, detects anomalies (sudden burst, unusual endpoints, abnormal timing), and triggers adaptive rate limiting.

Acceptance Criteria

  • Feature extraction: request rate, endpoint distribution, time-of-day pattern, payload size, user-agent entropy, geographic spread
  • ML model: Isolation Forest (unsupervised) for anomaly scoring, with configurable threshold
  • Adaptive limiting: when anomaly score exceeds threshold (default 0.8), temporarily reduce rate limit by 50% or 90%
  • False positive handling: allow-listed patterns (webhook callbacks, health checks), manual override per key
  • Anomaly dashboard: recent anomalies with feature breakdown, severity, and suggested action
  • Alert: real-time Slack/PagerDuty notification on high-confidence attacks (score >0.95)
  • Edge case: legit traffic spike (Black Friday) -> train separate seasonal model, whitelist event days
  • Edge case: model drift -> auto-retrain weekly with latest traffic patterns, alert on >5% accuracy drop

Technical Scope

  • ml-service/ - rate limit anomaly detection model (Isolation Forest)
  • backend/gateway/middleware/ - adaptive rate limit middleware
  • backend/monitoring/ - anomaly score Prometheus metric per key
  • mobile/app/screens/ - RateLimitDashboardScreen (admin only)
  • ml-service/jobs/ - weekly model retraining and evaluation

Metadata

Metadata

Assignees

Labels

200-points200 point issueStellar WaveIssues in the Stellar wave programdrips-waveIssues in the Drips Wave programhighHigh complexity issue

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions