-
-
ScamPreventionDemo Diagram: Zero-Trust Financial Defense System Architecture
-
Jest Tests for Security Guardrail (Client, Quantization, Secure Aggregation, FedProx, Rollback)
-
Security Guardrail: Test Quantization
-
Security Guardrail: Client
-
Security Guardrail: Security Aggregation
-
Security Guardrail: FedProx
-
Security Guardrail: Rollback
-
Master Verification Test Completion
Inspiration
Peer-to-peer (P2P) payment scams, social engineering, and automated account takeovers (ATOs) happen in milliseconds—often bypassing static fraud rules before a victim realizes their session has been hijacked. Meanwhile, traditional centralized fraud detection forces payment platforms and merchants to pool sensitive behavioral and transaction telemetry into central data lakes, creating massive privacy liabilities and regulatory bottlenecks.
I built ScamPreventionDemo to prove that modern financial ecosystems can stop high-risk fraud at the exact moment of checkout without sacrificing user privacy or adding latency. By combining zero-trust client behavioral telemetry, deterministic cryptographic payload signing, real-time AG Grid security operations, risk-gated PayPal Sandbox step-up authentication, and privacy-preserving Federated Learning, ScamPreventionDemo turns every checkout session into a self-defending financial perimeter.
What It Does
ScamPreventionDemo is an end-to-end, multi-layered financial security platform engineered to detect, intercept, and neutralize anomalous sessions and high-risk P2P transfers in real time:
- Risk-Gated PayPal Checkout & Step-Up Verification: Evaluates payment vectors dynamically at checkout, distinguishing between standard merchant gateway transactions (
MERCHANT_GATEWAY) and high-risk peer-to-peer transfers (PERSONAL_P2P). When risk thresholds are breached, the system intercepts the flow, emits risk decision-tree telemetry (/v1/risk/decision-trees), and triggers an automated PayPal Sandbox Step-Up Authentication Modal (@paypal/checkout-server-sdk& PayPal JS SDK) before permitting order capture (USD 100.00). - Zero-Trust Client Surveillance & Cryptographic Integrity: Offloads continuous behavioral anomaly scoring (
POINTER_TELEPORTATION,KEVIN_DYNAMICS,VISIBILITY_CHANGE,HEARTBEAT) to a dedicated background Web Worker (telemetryworker.js) with 200ms flood throttling. Every telemetry packet is recursively canonicalized and signed in the browser via the Web Crypto API (x-security-integrity), while the Node.js backend enforces constant-time verification (crypto.timingSafeEqual) to eliminate replay and payload-tampering attacks. - Automated Lockdown & Stateful Redis Session Invalidation: Maintains an immutable SHA-256 hash-chained local audit trail (
auditlogger.js). Upon consecutive anomaly threshold breaches, the UI immediately blurs sensitive financial views, purges local storage, and triggers an instant TTL-backed session invalidation (session_invalidated:<sessionId>) inside a password-authenticated Redis broker alongside 1-second sliding-window rate limiting (20 req/secper IP). - AG Grid Enterprise Real-Time Telemetry Console: Streams live security events and dynamic risk scores (
0–39 Low,40–69 Medium,70–100 High) over Server-Sent Events (/api/events/stream) into a high-frequency AG Grid Enterprise console, empowering SOC analysts to filter threats, inspect risk vectors, and launch step-up PayPal verification workflows with one click. - Privacy-Preserving Federated Threat Intelligence (Flower Core): Trains collaborative fraud detection models across distributed edge nodes using the Flower framework—ensuring raw merchant and user data never leaves the local node.
System Architecture
+-----------------------------------+ TLS 1.3 / HTTPS +---------------------------------------+
| Client Application | ---------------------------> | Financial Middleware |
|-----------------------------------| SHA-256 HMAC Signatures |---------------------------------------|
| - React 19 UI & AG Grid Dashboard | | - Node.js / Express REST & SSE Server |
| - Web Worker Anomaly Engine | <--------------------------- | - JWT RBAC & Timing-Safe Verification |
| - PayPal JS SDK Step-Up Modal | Server-Sent Events (SSE) | - Redis Rate Limiter & Session Store |
+-----------------------------------+ +---------------------------------------+
|
v
+---------------------------------------+
| Federated AI/ML Core (Linux) |
|---------------------------------------|
| - Flower NumPy Client & Aggregator |
| - Gaussian DP Noise & int8 Quantizer |
| - FedProx Strategy (mu=0.01) |
| - Automated Safe-State Rollback |
+---------------------------------------+
How I Built It (Technological & Mathematical Rigor)
Frontend & SOC Console (React 19, AG Grid Enterprise, PayPal JS SDK): Engineered a responsive fintech command center featuring live SSE grid updates, custom risk-tier badge renderers, and clean Zoid lifecycle management (paypalpayment.jsx) for step-up PayPal checkout modals.
Zero-Trust Financial Middleware (Node.js, Express, Redis, @paypal/checkout-server-sdk): Built a hardened REST and SSE server enforcing JWT RBAC, Redis sliding-window rate limiting, replay-proof SHA-256 HMAC signature verification, and server-side PayPal Sandbox order creation and capture.
Federated Learning Threat Intelligence (Python, Flower, NumPy):
Differential Privacy Blinding: Injects calibrated Gaussian noise \( \mathcal{N}(0, \sigma^2) \) with \( \sigma = 0.005 \) into local model gradients prior to network transmission, mathematically preventing gradient inversion attacks and safeguarding merchant confidentiality.
8-Bit Weight Quantization: Compresses 32-bit floating-point parameter tensors (float32) into int8 representations across edge-to-aggregator links, achieving a verified 4.00x bandwidth reduction with minimal accuracy loss.
FedProx Statistical Stabilization: Implements a proximal optimization penalty term \( \frac{\mu}{2} \|w - w^t\|^2 \) with \( \mu = 0.01 \) inside our custom aggregation strategy (fedprox_optimizer.py) to prevent weight divergence across non-IID merchant traffic patterns.
Automated Parameter Rollback: Continuously validates incoming weight tensors for numerical corruption (NaN or Inf), instantly reverting to the last cryptographically verified checkpoint to guarantee zero-downtime inference.
Challenges I Ran Into
- Cross-Runtime Cryptographic Canonicalization: Browser JavaScript engines and Node.js servers can serialize JSON object keys in inconsistent orders, breaking HMAC signatures. I solved this by implementing deterministic recursive key-sorting on both client and server prior to computing SHA-256 digests and validation.
- Preventing PayPal SDK Zoid Component Leaks in Dynamic Modals: Rendering and unmounting PayPal Buttons repeatedly inside live AG Grid operator modals caused Zoid iframe teardown race conditions. I engineered a dedicated cleanup wrapper (paypalpayment.jsx) that gracefully destroys active button instances on modal close.
- Balancing Federated Bandwidth vs. Model Stability: Transmitting unquantized neural weights across edge nodes introduces network bottlenecks, while aggressive quantization can destabilize heterogeneous updates. Combining int8 quantization (4.00x compression) with FedProx proximal regularization (\( \mu = 0.01 \)) and automated NaN/Inf rollback solved both bottlenecks simultaneously.
Accomplishments That I'm Proud Of
Verified 4.00x Bandwidth Compression & Differential Privacy: Proven via our automated master orchestration suite (verify_orchestration.py), confirming both \( \sigma = 0.005 \) Gaussian noise injection and 4.00x int8 tensor compression.
- Battle-Tested Exploit Resilience: Hardened against HMAC payload tampering, prototype pollution, and API flooding (HTTP 429), validated through an automated Jest & Supertest security suite (telemetry.test.js) and zero-leak secret scanning (Gitleaks).
- Unified Sub-Second Operator Workflow: Bridged client Web Worker anomaly detection, Redis session invalidation, live AG Grid Enterprise SSE streaming, and PayPal Sandbox step-up authentication into one seamless defense loop.
What I Learned & What's Next
Building ScamPreventionDemo reinforced that true financial security requires defense-in-depth—combining behavioral biometrics at the browser edge, deterministic cryptography in transit, stateful speed in Redis, actionable visibility in AG Grid, and privacy-preserving intelligence in Flower. Next, I plan to deploy multi-region Flower aggregator nodes on edge compute workers and integrate transformer-based sequence models for multi-step checkout session profiling.
Built With
- ag-grid
- express.js
- federated-learning
- flower
- javascript
- node.js
- paypal
- python
- react
- redis