Inspiration

To a checkout, a stolen account looks exactly like its owner: the right password, the right card details, and after a SIM swap even the right SMS code. The usual answer, an SMS OTP on every payment, adds friction for every genuine customer and does nothing against the attacks that matter most. In our simulation it stopped only 24% of account-takeover payments.

We wanted the checkout to ask a better question. Not "do you know the secret?" but "is this really you?", answered from how the person types and touches the screen, the device they use and who receives the money. And we wanted that answer before the payment ever reaches PayPal.

What it does

PRAMAAN sits in front of a PayPal checkout and decides every payment first:

  • Allow: the server creates a PayPal order, the buyer pays with PayPal's own buttons or card fields, and the server captures it.
  • Step-up: the challenge that fits the likely attack runs first. A new phone and SIM gets a passkey (an SMS code would go to the attacker), and a coached victim gets a bank call-back. Only a pass creates a PayPal order.
  • Block: no PayPal order exists at all. The server refuses to create one even if a tampered browser asks (HTTP 403 GATE_CLOSED).

Every PayPal order carries the PRAMAAN decision id in custom_id, so each transaction leads back to the signals that allowed it. Fraud reported later is refunded with one click through PayPal's Payments API.

How it decides

1. Three specialist models.

  • Touch: a BiLSTM gesture encoder fused with LDA. It turns each swipe into 21 numbers and compares a window of 10 to 20 swipes with the owner's profile.
  • Typing: a 1D-CNN (84k parameters) fused with a scaled Manhattan detector. It reads 31 key timings (hold, down-down, up-down) from a password entry. Only timings are recorded, never the keys.
  • Payee: a calibrated XGBoost over the receiving account's ledger behaviour, such as many new payers within the hour, money forwarded within minutes, or a very new account. It abstains for an account with no history.

2. One monotone XGBoost combines those three scores with 24 device, network and transaction signals (27 features). Every feature is constrained so the risk can only rise as the signal gets worse, \( \partial \hat{p} / \partial x_j \ge 0 \). That means no explanation ever argues in an attacker's favour. Exact tree-SHAP splits each decision into per-signal contributions:

$$\operatorname{logit}\hat{p} = \phi_0 + \sum_{j=1}^{27} \phi_j$$

The model is trained on simulated traffic, so its log-odds are shifted from the simulator's attack share \( \pi_s \) to an assumed real-world prevalence \( \pi_r = 0.2\% \):

$$\operatorname{logit} p = \operatorname{logit}\hat{p} + \operatorname{logit}\pi_r - \operatorname{logit}\pi_s$$

3. A cost-based policy picks the cheapest action for amount \( A \), step-up efficacy \( e_c \), friction \( f_c \) and the cost \( B \) of refusing a genuine payment:

$$C_{\text{allow}} = pA, \qquad C_{\text{step-up}} = \min_c \big[\, pA\,(1 - e_c) + (1 - p)\, f_c \,\big], \qquad C_{\text{block}} = (1 - p)\, B \ \ (\text{only if } p \ge 0.5)$$

The efficacies and frictions are stated assumptions, meant to be tuned with a bank.

How we built it

  • Backend: Python and FastAPI, with PyTorch for the touch and typing models and XGBoost and scikit-learn for the rest. State lives in Redis or in memory, and every decision is written to an audit log (SQLite or Postgres).
  • PayPal integration:
    • OAuth2 client credentials on the server only.
    • Orders v2 (create, get, capture), Payments v2 (refund), and the PayPal JavaScript SDK buttons and card fields.
    • The order amount comes from the decision, never from the browser.
    • Before capturing, the server re-reads the order from PayPal and checks custom_id, amount, currency and APPROVED status.
    • PayPal-Request-Id makes retries safe.
    • It runs on the sandbox only, by design.
  • SDKs: a TypeScript web SDK and an Android SDK collect the signals. Their feature extraction is checked against the Python training pipeline with shared golden vectors.
  • Console (Next.js 16, React 19, Tailwind 4): the PayPal checkout, a decision lab that traces one request end to end, a policy tuner, a live capture page where the web SDK measures your own typing and swipes, an audit log and a model evaluation page.
  • Data: touch and typing come from real behavioural datasets, HMOG and the CMU keystroke benchmark. Customers and attacks are simulated: 3,000 customers over 60 days, 273k requests.

Results

Each result is on users or time periods held out from training:

Model Data Result
Touch: BiLSTM + LDA HMOG, 15 unseen users EER 14.4% (10 swipes), 13.5% (20)
Typing: 1D-CNN + scaled Manhattan CMU, 8 unseen users EER 12.3% (1 try), 8.3% (3 tries); scaled Manhattan alone: 19.9%
Payee: calibrated XGBoost synthetic ledger, 344k transfers ROC-AUC 0.82 (0.999 on accounts that forward money)
Risk engine: monotone XGBoost simulated takeovers, 273k requests ROC-AUC 0.996, PR-AUC 0.889
  • No signal family alone comes close: behaviour-only reaches ROC-AUC 0.880, device-only 0.762 and transaction-only 0.953. All 27 features together reach 0.996.
  • Against SMS OTP, in simulation: PRAMAAN stopped 82.8% of attack payments while challenging 1.8% of genuine ones. SMS OTP on every payment stopped 24.2% and challenged 100%; a rules engine plus OTP stopped 30.2%.
  • Speed: the median decision takes 12.4 ms in-process.
  • Also trained:
    • A temporal graph network for money laundering on IBM's synthetic AML data: ROC-AUC 0.988, F1 0.70 (XGBoost baseline: 0.61).
    • A scam-workflow GRU: PR-AUC 0.995.
    • A CatBoost + LightGBM + XGBoost ensemble on IEEE-CIS: ROC-AUC 0.917.

Attack rates come from simulated attacks, so they are not real-world fraud rates.

Challenges we ran into

  • The same feature, three languages. A swipe or a keystroke has to become the same numbers in the browser, on Android and in Python, or the models see garbage. Shared golden vectors check all three.
  • A mouse is not a finger. Scripted mouse swipes on a laptop once scored as the owner's hands, because the missing motion-sensor features were filled in with averages. Now the touch model only compares a window with a profile when both agree on whether hand motion was measured. Otherwise it gives no score.
  • Keeping PayPal out of reach. A blocked payment must not be able to reach PayPal, whatever the browser does. So the gate is enforced on the server, the amount comes from the decision, and every capture re-checks the order. Each capture attempt gets a fresh request id, so a retry after a declined card really runs.
  • Currency. PayPal doesn't support INR, so the demo converts at a fixed rate of ₹85 to $1.
  • Cold start. On an account's very first credit the payee model is no better than a coin flip (ROC-AUC 0.46), so it abstains instead of guessing.

Accomplishments we're proud of

  • Real PayPal sandbox orders, captures and refunds, each gated by an AI decision and traceable through custom_id.
  • Explanations that are exact (tree-SHAP) and always point the right way (monotone constraints).
  • A typing model that beats the classic scaled Manhattan detector on users it has never seen: 12.3% vs 19.9% EER.

What we learned

  • Typing drifts between sessions. Enrolled from 10 attempts in a single sitting, every method degrades sharply (25.9% EER), so profiles should be built from, and refreshed with, the customer's verified logins.
  • Fusion is the point. No single family of signals is enough on its own.
  • Choosing the step-up matters as much as detecting the attack. An SMS code is useless after a SIM swap.

What's next

  • A pilot on consented real traffic, to replace the simulation's numbers with measured ones.
  • Profile refresh from verified logins.
  • 3-D Secure as a card step-up option in the PayPal flow.
  • Wiring the Android SDK sample to the same API.

Built With

Share this project:

Updates

Submission history