Explainable behavioral detection and bounded response system for coordinated card-testing attacks.
Card-testing attacks generate large numbers of small payment attempts to discover valid card details.
Traditional transaction-level rules can miss coordinated behavior because attackers distribute activity across:
- Multiple merchants
- Devices
- IP addresses
- Card BINs
- Short time windows
The result can be increased payment failures, unnecessary merchant exposure, and missed coordinated attacks.
Card-Testing Sentinel converts raw payment transactions into behavioral time windows, calculates an explainable risk score, identifies coordinated attack clusters, and generates bounded response recommendations.
⚠️ Note on data: All transactions used in this project are synthetically generated to simulate normal payment behavior and injected card-testing-attack patterns, since real merchant transaction data is not publicly available. Metrics below reflect performance on this synthetic dataset.
The system follows: Raw Transactions ↓ Behavioral Windows ↓ Risk Detection ↓ Suspicious Transactions ↓ Attack Clustering ↓ Attack Explanation ↓ Bounded Recommendation ↓ Human Approval ↓ Action
The system is designed to recommend defensive actions rather than automatically blocking transactions.
Analyzes transaction behavior using:
- Transaction velocity
- Payment failure rate
- Low-value transaction concentration
- Device diversity
- IP diversity
- Card BIN diversity
Each window receives an explainable 0–100 risk score.
Suspicious transactions are grouped using shared behavioral and infrastructure signals, helping identify attacks that span merchants, devices, IP addresses, and card BINs.
Instead of only producing a risk score, Sentinel explains why activity was flagged — e.g., high failure rate, high low-value concentration, rapid transaction volume, shared infrastructure.
Generates controlled recommendations such as PAUSE_SUSPECTED_BIN or RATE_LIMIT_SUSPECTED_TRAFFIC. Every recommendation includes: severity, confidence, action, duration, reasoning, and an approval requirement.
Sentinel follows a human-in-the-loop architecture. Automatic blocking is disabled by design.
Evaluated on 500,000 synthetic transactions:
| Metric | Result |
|---|---|
| Transactions analyzed | 500,000 |
| Time windows | 43,200 |
| Suspicious windows | 5,001 |
| Suspicious transactions | 103,316 |
| Attack clusters | 2 |
| Recommendations | 2 |
| Automatic blocks | 0 |
Held-out test set performance:
| Metric | Result |
|---|---|
| Precision | 91.62% |
| Recall | 82.85% |
| F1 Score | 87.01% |
| Threshold | 79 |
Honest trade-off: At the current threshold, some genuine transactions are flagged for review rather than instantly approved — a real trade-off between catching attacks and disrupting legitimate customers, reported here rather than hidden.
The risk score combines six behavioral signals:
| Signal | Weight |
|---|---|
| Transaction Count | 25% |
| Failure Rate | 30% |
| Low-Value Rate | 25% |
| Unique Devices | 10% |
| Unique IPs | 5% |
| Unique BINs | 5% |
Production threshold: Risk Score ≥ 79, generated using percentile-based comparison against baseline behavior. This makes the system explainable, auditable, and threshold-driven.
Sentinel intentionally avoids uncontrolled automatic blocking.
- Bounded actions — recommendations have predefined scopes and durations.
- Human approval — high-impact responses require operator approval before execution.
- No automatic blocking — the system never directly blocks payment activity on its own.
This reduces the risk of false-positive operational impact and keeps a full audit trail for every decision.
- Initial clustering grouped unrelated transactions together → fixed by tightening the shared-signal similarity threshold in the clustering logic.
- Risk score was initially too sensitive to raw transaction count alone, causing high-traffic-but-legitimate windows to be flagged → rebalanced the six signal weights shown above to reduce false positives.
- Early design allowed the system to act on its own → redesigned around a mandatory human-approval gate to keep the system strictly defense-only.
- Live Razorpay Test Mode API execution is designed into the architecture but not yet wired into the action engine — approved actions are currently logged, not auto-executed against the API.
- Evaluated only on synthetic data; real merchant data would likely surface additional edge cases not represented here.
card-testing-sentinel/ │ ├── README.md ├── requirements.txt ├── .gitignore ├── 01_data_exploration.ipynb ├── app.py ├── data_generator.py ├── detector.py ├── clusterer.py ├── action_engine.py ├── sentinel.py ├── test_detector.py ├── test_clusterer.py └── test_action_engine.py
Python · Pandas · NumPy · Scikit-learn · Streamlit · Matplotlib · Git · GitHub
git clone https://github.com/MMeghana8/card-testing-sentinel.git
cd card-testing-sentinel
python -m venv venv
venv\Scripts\activate # Mac/Linux: source venv/bin/activate
pip install -r requirements.txt
streamlit run app.py