Guest mode. You can read posts without signing up. Comments, ratings, job contacts and your own posts open after you sign up and accept the rules. What is Kommit →

Редакция КоммитРедакция портала
commit 8491fa5 · 19 days ago

Information Security and Anti-Fraud, Part 6: Rules and Scoring — How to Build an Anti-Fraud System from Scratch

🌐 Machine-translated from Russian. Show original

In this part:

Simple anti-fraud system architecture#

  1. Event — registration, login, payment, withdrawal, change of details.
  2. Signal collection — data about the user, device, network, history.
  3. Rules and scoring — risk assessment calculation.
  4. The solution is to skip, request confirmation, send for manual review, or reject.
  5. Feedback — the result (confirmed or not) is returned to the system for rules configuration.

You can start with a module in your own code and a table in the database — specialized platforms are needed when the volume grows.

Signals#

GroupExamples
Accountaccount age, whether email and phone number are confirmed, transaction history,
Deviceis a new device for the account, how many accounts are there
NetworkIP from a data center or VPN, IP country, matching address
Velocitynumber of operations per 10 minutes, hour, day,
Amountdeviation from the user's regular receipt
Contactsshared phone numbers, addresses, maps, devices with known scammers,

Use personal data signals within the framework of consent and legal requirements and keep them as long as necessary for protection.

Velocity SQL rules#

The most useful rules are about speed. Example: how many different maps were tried on one device in an hour:

SELECT device_id, count(DISTINCT card_fingerprint) AS cards
FROM payment_attempts
WHERE created_at > now() - interval '1 hour'
GROUP BY device_id
HAVING count(DISTINCT card_fingerprint) >= 3;

How many accounts are registered with one IP per day:

SELECT ip, count(*) AS signups
FROM signups
WHERE created_at > now() - interval '1 day'
GROUP BY ip HAVING count(*) > 5;

Scoring points#

Instead of a single hard rule — the sum of points from several signals:

type Ctx = { accountAgeDays: number; newDevice: boolean; ipCountry: string; cardCountry: string;
             amount: number; avgAmount: number; attemptsLastHour: number };

function riskScore(c: Ctx) {
  let s = 0;
  if (c.accountAgeDays < 1) s += 20;
  if (c.newDevice) s += 15;
  if (c.ipCountry !== c.cardCountry) s += 20;
  if (c.avgAmount > 0 && c.amount > c.avgAmount * 5) s += 25;
  if (c.attemptsLastHour >= 3) s += 30;
  return s;
}

function decide(score: number) {
  if (score >= 70) return "decline";   // отклонить
  if (score >= 40) return "review";    // ручная проверка или доп. подтверждение
  return "allow";
}

Advantages of the approach: transparent, easy to explain the solution to the client and support, easy to change weights.

Decisions: not just "yes" and "no"#

RiskSolution
Lowskip without friction for the customer
Mediumadditional step: SMS code, 3-D Secure, confirmation in the
Highmanual verification or failure with clear message

Additional confirmation for medium risk is the best balance: an honest client will pass in 10 seconds, while a fraudster with stolen data usually does not.

Setup and feedback#

  • Each trigger is logged with points for each signal — to understand why the decision was made.
  • The results of manual checks and chargebacks mark operations: fraud or not.
  • Once a week, check the precision and recall rules (part 5: the rule that mostly blocks honest customers needs to be relaxed.
  • First, run the new rules in " observe-only" mode: count how many blocks you want, but don't block them.

When to switch to machine learning#

ML models are justified when there is a marked history (thousands of confirmed fraud cases), a stable flow of operations, and a team that will support the model. Even then, the rules remain: for new schemas, for explainability, and as insurance. Skills from the "SQL for Business" post will help prepare data for such a transition.

Comments 00 участников · 0 гостей🔒 Rate and discuss after signing up

Comments · 0

No comments yet.Sign in to comment, rate and see all comments.