Back to Case Studies
Shield icon with traffic metrics dashboard
Security Engineering Featured

Enhancing Transaction Security Using AWS WAF and Redis-Based Rate Limiting

Protize Engineering Team Updated
#AWS WAF #Security #Rate Limiting #Redis #Fintech

Enhancing Transaction Security Using AWS WAF and Redis-Based Rate Limiting

Fraud attempts and abusive traffic often spike during promotional events, merchant go‑lives, or seasonal peaks.
Protize adopted a layered defense strategy combining AWS WAF for L7 filtering with Redis-based rate limiting at the application edge to protect APIs, preserve capacity, and ensure predictable latency under attack.


1) Threat Landscape

Our goal: block bad traffic early, throttle suspicious clients gracefully, and never degrade service for good users.


2) Architecture at a Glance

  1. CloudFront → AWS WAF enforces managed rules + custom rulesets.
  2. ALB → NestJS API terminates TLS and forwards to service pods.
  3. Redis (Elasticache) stores counters, token buckets, and sliding windows per IP, merchantId, API key, and route.
  4. Async audit pipeline mirrors suspicious requests to a risk topic for offline analysis and model training.

3) AWS WAF Ruleset Strategy

Observability: Sampled requests are shipped to Kinesis Firehose → S3 for Athena queries and dashboards.


4) Redis-Based Rate Limiting (App Edge)

We implemented a sliding window + token bucket hybrid:

Pseudocode Sketch

function checkLimit(key, limit, windowMs, burst) {
  const now = Date.now();
  // 1) consume burst tokens first
  const tokens = redis.decrby(`${key}:burst`, 1);
  if (tokens >= 0) return allow();

  // 2) sliding window count
  redis.zadd(`${key}:win`, now, `${now}`);
  redis.zremrangebyscore(`${key}:win`, 0, now - windowMs);
  const count = redis.zcard(`${key}:win`);

  if (count > limit) return block();
  return allow();
}

5) Coordinating WAF and App Limits


6) Securing OTP & Auth Flows


7) Incident Playbook & Automation


8) Results

MetricBeforeAfter
Card testing success window> 2 hours< 10 minutes
OTP spam during promo peaksFrequentRare
P95 latency under attack900ms180ms
False positives (weekly)ModerateLow

9) Lessons Learned

  1. Push coarse‑grained blocks to the edge (WAF); keep fine‑grained controls in the app.
  2. Sliding windows + small bursts keep UX smooth while containing abuse.
  3. Labels from WAF → App create powerful, explainable risk signals.
  4. Always send machine‑readable error bodies for blocked/throttled traffic.

10) Next Steps


Authored by the Protize Engineering Team — November 2025.

← Back to Case Studies