skip to content

build a detection system · lesson 3 of 9 · sources checked 2026-11-22

features over many requests and the reputation store

This lesson designs the counts that a server keeps over many requests, with keys, windows, a decay, and a state cost for each key.

purpose

One request shows little. Many requests of one address, one network, or one client build show a pattern that no single request shows. An inter-request feature gives that pattern to the model, but each key that you count costs memory and can hurt real users.

objectives

  1. Select the keys and the windows of a feature pipeline.
  2. Define aggregates for each key, for example ratios and volume quantiles over one hour.
  3. Calculate the state cost of a key, and read it from a lab chart.
  4. Explain why the rotation of one key does not reset the counts of the other keys.
  5. Join labels to feature values at the label time, and test the join for future values.

new terms

reputation store
A store of aggregates and history for each key, with a window and a decay.
feature store
A system with an offline store for training and an online store for decisions, with one feature definition.
point-in-time join
A join that gives each label only the feature values that existed at the label time.

how it works

An inter-request feature has three parts: a key, a window, and an aggregate. For example, "requests of one address in the last hour" has the key "address", the window "1 hour", and the aggregate "count".

keys

A key is the value that groups the requests. Each key is a signal of a different part of the client:

  • Address: the source address of the request.
  • Address prefix: the network range of the address.
  • Network: the ASN that announces the address.
  • TLS fingerprint: a fingerprint of the first TLS message of the client, for example a JA4 value.
  • Web session: the cookie of the web session.
  • Account: the account of a user who logs in.

Each key resets when the client changes that part, or when the window ends. The first diagram shows this for each key and window.

rotation of one key

A client can get a new address for each request. The address count then stays low. But the new address has the same TLS fingerprint, the same network, and the same request pattern. Thus the new address adds to the same counts of the other keys.

For example, 500 requests come from 500 addresses in one hour. Each address has a count of 1. The TLS fingerprint key has a count of 500 in that hour, and the network key has the same 500.

A client cannot see or reset these counts. They stay on the server, and a change of one key leaves the others in place.

aggregates

A count alone says little. Better aggregates for a key over one hour are:

  • Ratios, for example the share of requests with no cookie, or the share of requests to one path.
  • Volume quantiles, for example the place of the hourly count of this key against all keys of the same kind.
  • Counts of different values, for example the number of different addresses for one TLS fingerprint. An estimate of that number can use much less memory than a list of all values.

the reputation store and the decay

A reputation store keeps the aggregates and the history of each key. Old evidence must count less than new evidence. A decay does this: each count halves after a fixed time.

For example, a key has 40 trap hits, and its count halves each hour. After 2 hours, the decayed count is 40 x 0.5 x 0.5 = 10.

the state cost and the false-positive cost

Each key has two costs. The state cost is the memory that its counts use. It grows with the number of different values in the window.

example For example, a store keeps 30,000 different addresses in 24 hours, at 300 bytes for each entry. That is 30,000 x 300 = 9,000,000 bytes, which is 9 MB (1 MB = 1,000,000 bytes).

The false positive cost is the harm to real users of a decision on the key. An address key hurts all users of one shared address. A TLS fingerprint key collects the volume of all clients of one TLS stack. The real browsers of one TLS stack can share one value.

one definition for training and for decisions

A feature store has an offline store for training and an online store for decisions. The two stores use one feature definition. Thus the model learns the same value that the decision chain later reads.

The online store must answer inside its part of the latency budget. The offline store keeps each value with its time.

A point-in-time join gives each label only the feature values that existed at the label time. For example, a block at 10:30 makes a label. A count from 11:00 is higher because of the attack after the block, so it must not go into the training row. The code example tests this.

the two sides

automation sidedetection side
Rotation of one key does not reset the counts of the other keys. A new address with the same TLS fingerprint, network, and request pattern adds to the same counts. A key on the TLS stack changes less often than a key on the address.Each key has a state cost and a false-positive cost. An address key hurts the users of a shared address. A TLS fingerprint key collects the volume of all clients of one TLS stack.

design decisions

optiongaincostwhen it is correct
Address keySimple, and it finds a fast sourceResets with each new address, and hurts users of a shared addressAs one key of many, never alone
Network or prefix keySurvives a new address in the same networkCollects the requests of all real users of that networkFor volume against an expected baseline
TLS fingerprint keySurvives a new address and a new networkAll real browsers of one TLS stack can share one valueWith ratios, not with a raw count
Web session or account keyOne user, low false-positive costResets with a new cookie or a new accountFor a site with a login or a stable cookie
A long windowFinds slow patternsLarge stateFor keys with few different values
A short windowSmall stateMisses slow patternsFor keys with many different values

diagram

The first diagram shows what resets each count.

A matrix of six keys against three windows of 1 minute, 1 hour, and 24 hours. Each key resets when the client changes the value of that key, or when the window ends. A change of one key does not reset the other keys.

keys against windows: what resets each count
key1 minute1 hour24 hours
Addressnew address, or 1 minutenew address, or 1 hournew address, or 24 hours
Address prefixnew prefix, or 1 minutenew prefix, or 1 hournew prefix, or 24 hours
Network (ASN)new network, or 1 minutenew network, or 1 hournew network, or 24 hours
TLS fingerprintnew TLS stack, or 1 minutenew TLS stack, or 1 hournew TLS stack, or 24 hours
Web sessionnew cookie, or 1 minutenew cookie, or 1 hournew cookie, or 24 hours
Accountnew account, or 1 minutenew account, or 1 hournew account, or 24 hours
Each count ends with its window, or when the client changes the value of that one key. The other keys keep their counts.source: My model of keys and windows for inter-request features

The second diagram shows the feature store.

one feature definition for the offline store and the online store, with a point-in-time join

The offline store and the online store use one feature definition. The join gives the training data no value from after the label time.source: My model of a feature store with a point-in-time join

code example

The example joins two synthetic labels to synthetic feature values. The times are minutes of the day: 630 is 10:30.

m37-x05-join.tstypescript

Join synthetic labels to feature values in two ways, and test each join for values from after the label time.

// A point-in-time join of labels to feature values, on synthetic records.
type Feature = { key: string; name: string; at: number; value: number }; // at: minute of the day
type Label = { key: string; at: number; label: "bot" | "human" };
type Row = { key: string; labelAt: number; label: string; name: string; value: number; featureAt: number };

const features: Feature[] = [
  { key: "key-a", name: "requests_1h", at: 600, value: 40 },
  { key: "key-a", name: "requests_1h", at: 660, value: 900 }, // after the block of 630
  { key: "key-b", name: "requests_1h", at: 600, value: 12 },
  { key: "key-b", name: "requests_1h", at: 700, value: 15 },
];
const labels: Label[] = [
  { key: "key-a", at: 630, label: "bot" },
  { key: "key-b", at: 650, label: "human" },
];

// A naive join takes the newest value of the key, also from after the label time.
function naiveJoin(ls: Label[], fs: Feature[]): Row[] {
  return ls.map((l) => {
    const f = fs.filter((x) => x.key === l.key).sort((a, b) => b.at - a.at)[0];
    return { key: l.key, labelAt: l.at, label: l.label, name: f.name, value: f.value, featureAt: f.at };
  });
}

// A point-in-time join takes the newest value at or before the label time.
function pointInTimeJoin(ls: Label[], fs: Feature[]): Row[] {
  return ls.map((l) => {
    const f = fs.filter((x) => x.key === l.key && x.at <= l.at).sort((a, b) => b.at - a.at)[0];
    return { key: l.key, labelAt: l.at, label: l.label, name: f.name, value: f.value, featureAt: f.at };
  });
}

// The test: it fails when a feature value comes from after the label time.
function testNoLeak(name: string, rows: Row[]): void {
  const leaks = rows.filter((r) => r.featureAt > r.labelAt);
  for (const r of rows) console.log(`  ${r.key} label ${r.label} at ${r.labelAt}: ${r.name}=${r.value} from ${r.featureAt}`);
  console.log(leaks.length === 0
    ? `${name}: PASS, no feature value from after the label time`
    : `${name}: FAIL, ${leaks.length} value(s) from after the label time: ${leaks.map((r) => r.key).join(", ")}`);
}

console.log("naive join:");
testNoLeak("naive join", naiveJoin(labels, features));
console.log("point-in-time join:");
testNoLeak("point-in-time join", pointInTimeJoin(labels, features));

output

The joined rows of each join, and the result of the test for each join.

naive join:
  key-a label bot at 630: requests_1h=900 from 660
  key-b label human at 650: requests_1h=15 from 700
naive join: FAIL, 2 value(s) from after the label time: key-a, key-b
point-in-time join:
  key-a label bot at 630: requests_1h=40 from 600
  key-b label human at 650: requests_1h=12 from 600
point-in-time join: PASS, no feature value from after the label time

The output shows that the naive join gives the bot label the count 900 from after the block. The point-in-time join gives the count 40 from before the label, and its test passes.

data

state size of each key and window in a lab gate, 1,000,000 requests

status of this figure: measured by me

state size of each key and window in a lab gate, 1,000,000 requestsabcdef1 minute125086101347526465992050535526781 hour608181944105311026774103931875416471616224 hours1923434182651679929146201495086721004590102unit: bytesa. sessionb. addressc. client stringd. address prefixe. header-order hashf. network

source: Lab result of this course: state size of the counters of a lab gate, simulated request log; date 2026-11-13; sample of 1,000,000; condition: A header-order hash stands in for a TLS key. The request log comes from stated population inputs, so the entry counts are simulated. The bytes are measured.

data table
state size of each key and window in a lab gate, 1,000,000 requests
serieskeybytes
1 minutesession125086
1 minuteaddress101347
1 minuteclient string52646
1 minuteaddress prefix59920
1 minuteheader-order hash50535
1 minutenetwork52678
1 hoursession6081819
1 houraddress4410531
1 hourclient string1026774
1 houraddress prefix1039318
1 hourheader-order hash754164
1 hournetwork716162
24 hourssession192343418
24 hoursaddress26516799
24 hoursclient string2914620
24 hoursaddress prefix1495086
24 hoursheader-order hash721004
24 hoursnetwork590102
Python object bytes of the counter store after a simulated day. The session key over 24 hours holds most of the state. These are lab values for one host. A compiled store uses fewer bytes.

The chart shows that the state cost of a key follows the number of its different values in the window. A key with a new value for almost each visitor, such as the web session, grows fast in a long window.

A key with few values, such as the network, stays small. In the chart, a hash of the header order takes the place of a TLS fingerprint key. The chart has no account key. It adds a key on the client string, the user agent text of each request.

failure modes

problemcausecorrection
A source with a new address for each request has low counts.The pipeline counts the address key only.Count the TLS fingerprint and network keys too.
Real users of one shared address get a block.A decision acts on the address key alone.Use the address as one feature of many, not as the decision.
The memory of the store grows past its limit.A key with many different values has a long window.Give that key a shorter window, or estimate its counts.
A model looks good in training, but it is weak on live traffic.The training rows hold feature values from after the label time.Use a point-in-time join, and test it for future values.
Old trap hits keep a key flagged.The store has no decay.Halve each count after a fixed time.

check questions

  1. A key has a new value for almost each visitor. Which window keeps its state small?

    1. A window of 24 hours
    2. A window of 1 minute
    3. No window, so that the store keeps all values
    answer

    b. A window of 1 minute

    The state cost grows with the number of different values in the window. A short window keeps few values of such a key.

  2. Name two aggregates of a key over one hour that say more than a raw count.

    sample answer

    A ratio, for example the share of requests with no cookie. A volume quantile, for example the place of the hourly count of this key against all keys of the same kind. A count of different values, for example the number of different addresses for one TLS fingerprint, is also correct.

  3. A key has 50,000 different values in its window, and each entry uses 400 bytes. What is its state cost?

    1. 20 MB
    2. 2 MB
    3. 200 MB
    answer

    a. 20 MB

    50,000 x 400 = 20,000,000 bytes. With 1 MB = 1,000,000 bytes, that is 20 MB.

  4. Explain why a new address for each request does not reset the counts of a source.

    sample answer

    The new address has the same TLS fingerprint, the same network, and the same request pattern. Thus each request adds to the same counts of these other keys. The counts stay on the server, and a change of one key leaves the other keys in place.

  5. A label has the time 10:30. Which feature value goes into its training row by a point-in-time join?

    1. The value of 11:00, because it is the newest value
    2. The mean of the values of 10:00 and 11:00
    3. The value of 10:00, because it is the newest value at or before the label time
    answer

    c. The value of 10:00, because it is the newest value at or before the label time

    A point-in-time join gives each label only the feature values that existed at the label time. A value from 11:00 is a future value for that label.

exercise

exercise Do this task on paper. Your lab gate keeps a 1-hour window. In one synthetic hour it sees these values:

  • 800 requests from 800 different addresses.
  • All 800 requests have one TLS fingerprint value.
  • All 800 requests come from one network.
  • Each entry of the store uses 500 bytes.
  • A trap key had 64 hits 3 hours ago, and its count halves each hour.
  1. Write the count of the address key, the TLS fingerprint key, and the network key for that hour.
  2. Calculate the state cost of the address key for that hour.
  3. Calculate the decayed count of the trap key now.
  4. Write the key that you use as the first feature for this source, and the false-positive cost of that key.
sample answer

The answer uses the synthetic values of the task.

Each address has a count of 1. The TLS fingerprint key and the network key each have a count of 800. The address key has 800 entries, and 800 x 500 = 400,000 bytes, which is 0.4 MB.

The decayed trap count is 64 x 0.5 x 0.5 x 0.5 = 8. The TLS fingerprint key and the network key both show the source. Use the TLS key first, because it also survives a new network, and use it with a ratio, not with a raw count. Its false-positive cost: the real browsers of one TLS stack can share that value.

sources

  1. My model of keys, windows, aggregates, the decay, the state cost, and the point-in-time join, 2026-11 (not public).