html, css, and dom · lesson 7 of 8 · sources checked 2026-11-20
serve plausible but changed data, and detect it
This lesson builds a lab switch that serves changed data with status 200, and three checks that show which change a collector finds.
purpose
A site can answer a flagged client with a normal page that holds wrong values. This defense is data poisoning. It has no block page and no error status, so the collector must find the change in the values.
objectives
- Build a lab switch that serves changed data with status 200 to a flagged client. Serve changed prices, decoy listings, stale data, or removed items.
- Describe the three checks of the collector and the change that each check finds.
- Explain why changed data costs the operator more than a block.
- Measure which change type each check flags, with a table of change type against check.
new terms
- data poisoning
- A defense that serves plausible but changed data to a flagged client.
- baseline diff
- The comparison of an attempt with the trusted control by structure and by field values.
- trusted control
- A capture of the same page from a high-trust channel, used as the baseline for a comparison.
- structural similarity
- A score from 0 to 1 that compares the tag histogram, node count, and size of two captures.
- semantic divergence
- The share of shared data fields whose values differ between two captures.
- watermark record
- A record in served data that is unique to one customer, so that a copy shows its source.
how it works
A block shows the operator that the collection failed. Changed data does not. The page has the status 200, the normal structure, and values that look correct. Thus the operator stores wrong values and does not know which records are wrong.
the lab switch
The lab site has a switch. A client that the site flags gets changed data. Each other client gets the real data. Each answer has the status 200.
The switch has these change types:
| change type | what the flagged client gets |
|---|---|
| Small price change | One price changes by a small amount, for example 2% |
| Large price change | Each price changes by a large amount |
| Decoy listings | Items that do not exist are added to the list |
| Stale data | An older version of the list |
| Removed items | Some items are missing from the list |
A flagged client is a test input of the lab. The point is how a collector finds the change, not how a client avoids the flag.
three checks of the collector
The collector has three checks:
- A baseline diff. The collector compares the capture with a trusted control, by structure and by field values. The control comes from a client that the site does not flag.
- Plausibility rules. These rules use no control. For example, each price is between 5 and 200, and the list has the expected count of items.
- A version probe. The collector reads a value that changes with each version of the data, for example a version number. It compares that value with the control.
The baseline diff gives two scores: the structural similarity and the semantic divergence of the two captures.
A control channel and a probe test the page from the outside, as a user sees it. The Google SRE book calls this black-box monitoring: "Testing externally visible behavior as a user would see it" Google, source 1.
what each check cannot see
Each check finds only the change that its rule describes:
- The baseline diff finds a new item, a missing item, and a value that differs more than its threshold. A change below the threshold passes.
- A plausibility rule finds a value outside its range and a wrong count. A changed value inside the range passes.
- The version probe finds old data. It does not see a changed price in new data.
For example, a price that changes by 2% passes a threshold of 5%, stays inside the range, and has the current version. Thus a small change in one field can pass each check.
the cost of changed data
A block is visible, and the operator can stop or change the job. Changed data enters the store, and later reports use it. A soft block is also visible to a content check, because the page holds less content. Changed data holds the full content.
The site can also add a watermark record to the data that it serves. For example, the list for one client holds one item that no other list holds. When that item shows up in a copy later, it shows the client that got the data.
the two sides
| automation side | detection side |
|---|---|
| A version probe and a baseline diff find some changed data. A small change in one field can pass each check. | Changed data costs the operator more than a block, because the operator does not know which records are wrong. A watermark in the data shows a later leak. |
design decisions
| option | gain | cost | when it is correct |
|---|---|---|---|
| A baseline diff with a trusted control | It finds new items, missing items, and large value changes. | Each check must have a second capture from a channel that the site does not flag. A change below the threshold passes. | High-value data, where a wrong record is expensive |
| Plausibility rules | They use no second capture. | A changed value inside the range passes. | Each collection, as a cheap first check |
| A version probe | It finds stale data with one read. | It sees only the version, not a changed value. | Data that changes often, for example prices or stock |
| A low threshold for the baseline diff | It finds smaller changes. | It also flags more real changes and clean captures. | When a person can review each flag |
diagram
the lab switch serves changed data with status 200 to a flagged client, and the collector checks the capture
code example
The example serves the list of a lab page to a flagged client and to a control client. Then it applies the three checks to each change type.
example All items, prices, and versions are synthetic, and the server is a function in the code.
Serve changed data with status 200 to a flagged client in a lab. Apply a baseline diff, plausibility rules, and a version probe to each change type.
// Lab only: a list page that serves changed data to a flagged client, and three collector checks.
// All items are synthetic. No network: the "server" is a function in this file.
type Item = { id: string; price: number };
type Capture = { status: number; version: number; items: Item[] };
type Change = "none" | "small price" | "large price" | "decoys" | "stale" | "removed";
const CATALOG: Item[] = [
{ id: "a1", price: 40 }, { id: "a2", price: 55 }, { id: "a3", price: 120 },
{ id: "a4", price: 18 }, { id: "a5", price: 72 }, { id: "a6", price: 9 },
];
const VERSION = 42;
// The lab switch: a flagged client gets changed data, always with status 200.
function serve(flagged: boolean, change: Change): Capture {
let items = CATALOG.map((i) => ({ ...i }));
let version = VERSION;
if (flagged) {
if (change === "small price") items[0].price = Math.round(items[0].price * 1.02 * 100) / 100;
if (change === "large price") items = items.map((i) => ({ ...i, price: Math.round(i.price * 1.4) }));
if (change === "decoys") items.push({ id: "d1", price: 1 }, { id: "d2", price: 1 });
if (change === "stale") { version = VERSION - 1; items[1].price = 54.5; }
if (change === "removed") items = items.slice(0, 3);
}
return { status: 200, version, items };
}
// Check 1: a baseline diff with a capture from the unflagged control channel.
function baseline(control: Capture, cap: Capture): boolean {
const ref = new Map(control.items.map((i) => [i.id, i.price]));
if (cap.items.length !== ref.size || cap.items.some((i) => !ref.has(i.id))) return true;
return cap.items.some((i) => Math.abs(i.price - ref.get(i.id)!) / ref.get(i.id)! > 0.05);
}
// Check 2: rules that need no control: a price range and the expected item count.
function plausibility(cap: Capture, expectedCount: number): boolean {
return cap.items.length !== expectedCount || cap.items.some((i) => i.price < 5 || i.price > 200);
}
// Check 3: a version probe: the version must not be older than the version of the control.
function versionProbe(control: Capture, cap: Capture): boolean {
return cap.version < control.version;
}
const changes: Change[] = ["none", "small price", "large price", "decoys", "stale", "removed"];
const control = serve(false, "none");
console.log("change | baseline | plausibility | version");
for (const c of changes) {
const cap = serve(true, c);
const cells = [baseline(control, cap), plausibility(cap, CATALOG.length), versionProbe(control, cap)];
const row = cells.map((f, k) => (f ? "flag" : "-").padEnd([8, 12, 9][k])).join(" | ");
console.log(`${c.padEnd(12)} | ${row}`.trimEnd());
}output
A table with one row for each change type, and a flag or a dash for each check.
change | baseline | plausibility | version
none | - | - | -
small price | - | - | -
large price | flag | - | -
decoys | flag | flag | -
stale | - | - | flag
removed | flag | flag | -I ran the code with the Node runtime and the flag --experimental-strip-types. The row "small price" has no flag, because a change of 2% is below the threshold of 5% of the baseline diff. Each other change has one or two flags.
data
share of changed captures that each check flags, in two rule settings
status of this figure: measured by me
lines: interval, level 0.95
source: Lab result of this course: changed data on a lab list page, two rule settings; period 2026-11-16 to 2026-11-17; sample of 25; condition: A lab list page serves changed data with status 200 to a flagged client. An unflagged lab client is the control channel.
data table
| series | rule setting and change type | % | interval |
|---|---|---|---|
| baseline diff | setting 1, clean capture (false flag) | 5.6 | 3.9 to 7.97 (level 0.95) |
| baseline diff | setting 1, small price change | 100 | 99.24 to 100 (level 0.95) |
| baseline diff | setting 1, large price change | 100 | 99.24 to 100 (level 0.95) |
| baseline diff | setting 1, decoy listings | 100 | 99.24 to 100 (level 0.95) |
| baseline diff | setting 1, stale data | 61.2 | 56.86 to 65.37 (level 0.95) |
| baseline diff | setting 2, clean capture (false flag) | 0 | 0 to 13.32 (level 0.95) |
| baseline diff | setting 2, small price change | 0 | 0 to 13.32 (level 0.95) |
| baseline diff | setting 2, large price change | 100 | 86.68 to 100 (level 0.95) |
| baseline diff | setting 2, decoy listings | 0 | 0 to 13.32 (level 0.95) |
| baseline diff | setting 2, stale data | 0 | 0 to 13.32 (level 0.95) |
| baseline diff | setting 2, removed items | 0 | 0 to 13.32 (level 0.95) |
| plausibility rules | setting 1, clean capture (false flag) | 0 | 0 to 0.76 (level 0.95) |
| plausibility rules | setting 1, small price change | 0 | 0 to 0.76 (level 0.95) |
| plausibility rules | setting 1, large price change | 29 | 25.19 to 33.13 (level 0.95) |
| plausibility rules | setting 1, decoy listings | 48.6 | 44.25 to 52.97 (level 0.95) |
| plausibility rules | setting 1, stale data | 0 | 0 to 0.76 (level 0.95) |
| plausibility rules | setting 2, clean capture (false flag) | 0 | 0 to 13.32 (level 0.95) |
| plausibility rules | setting 2, small price change | 0 | 0 to 13.32 (level 0.95) |
| plausibility rules | setting 2, large price change | 0 | 0 to 13.32 (level 0.95) |
| plausibility rules | setting 2, decoy listings | 0 | 0 to 13.32 (level 0.95) |
| plausibility rules | setting 2, stale data | 0 | 0 to 13.32 (level 0.95) |
| plausibility rules | setting 2, removed items | 100 | 86.68 to 100 (level 0.95) |
| version probe | setting 1, clean capture (false flag) | 0 | 0 to 0.76 (level 0.95) |
| version probe | setting 1, small price change | 0 | 0 to 0.76 (level 0.95) |
| version probe | setting 1, large price change | 0 | 0 to 0.76 (level 0.95) |
| version probe | setting 1, decoy listings | 0 | 0 to 0.76 (level 0.95) |
| version probe | setting 1, stale data | 52.4 | 48.02 to 56.74 (level 0.95) |
| version probe | setting 2, clean capture (false flag) | 0 | 0 to 13.32 (level 0.95) |
| version probe | setting 2, small price change | 0 | 0 to 13.32 (level 0.95) |
| version probe | setting 2, large price change | 0 | 0 to 13.32 (level 0.95) |
| version probe | setting 2, decoy listings | 0 | 0 to 13.32 (level 0.95) |
| version probe | setting 2, stale data | 100 | 86.68 to 100 (level 0.95) |
| version probe | setting 2, removed items | 0 | 0 to 13.32 (level 0.95) |
| any check | setting 1, clean capture (false flag) | 5.6 | 3.9 to 7.97 (level 0.95) |
| any check | setting 1, small price change | 100 | 99.24 to 100 (level 0.95) |
| any check | setting 1, large price change | 100 | 99.24 to 100 (level 0.95) |
| any check | setting 1, decoy listings | 100 | 99.24 to 100 (level 0.95) |
| any check | setting 1, stale data | 81.6 | 77.97 to 84.75 (level 0.95) |
| any check | setting 2, clean capture (false flag) | 0 | 0 to 13.32 (level 0.95) |
| any check | setting 2, small price change | 0 | 0 to 13.32 (level 0.95) |
| any check | setting 2, large price change | 100 | 86.68 to 100 (level 0.95) |
| any check | setting 2, decoy listings | 0 | 0 to 13.32 (level 0.95) |
| any check | setting 2, stale data | 100 | 86.68 to 100 (level 0.95) |
| any check | setting 2, removed items | 100 | 86.68 to 100 (level 0.95) |
The chart shows the same method in two lab settings with different rule values. In setting 1, the baseline diff flags each price change and each decoy listing. It also flags some clean captures. In setting 2, no check flags the decoys or the small price change.
Thus the result of a check follows from its rule values. A change that the rule does not describe passes. The chart is not a detection rate of real sites.
failure modes
| problem | cause | correction |
|---|---|---|
| The store holds wrong values, and no check flagged them. | The change is below the threshold of each check. | Compare a sample of captures with a trusted control on a schedule. Review the values near the threshold. |
| The baseline diff flags many clean captures. | The real page changes between the two captures, or the threshold is too low. | Take the control capture at the same time. Set the threshold from a review of flagged captures. |
| The version probe passes stale data. | The probe reads a value that the site does not change with the data. | Read a value that changes with each version of the data, and compare it with the control. |
| The plausibility rules pass a changed price. | The changed value is inside the range of the rule. | Use the plausibility rules only as a first check, and add a baseline diff. |
| A check result is reported as a detection rate. | A lab result follows from the lab inputs and the rule values. | Report a lab result as a test of the method, with its settings. |
check questions
In the lab, which status does the switch give to a flagged client that gets changed data?
- 403
- 200
- 429
- 503
answer
b. 200
The switch serves changed data with the normal status 200. Thus the status does not show the change.
Describe the three checks of the collector and the change that each check finds.
sample answer
The baseline diff compares the capture with a trusted control. It finds new items, missing items, and values that differ more than its threshold. The plausibility rules use no control. They find a value outside its range and a wrong count of items. The version probe reads a value that changes with each version of the data, and it finds stale data.
Explain why changed data costs the operator more than a block.
sample answer
A block is visible, so the operator can stop or change the job. Changed data has the status 200, the normal structure, and values that look correct. It enters the store, and the operator does not know which records are wrong.
In the code example, one price changes by 2%, and the threshold of the baseline diff is 5%. Which check flags the capture?
- The baseline diff
- The plausibility rules
- The version probe
- No check
answer
d. No check
The change is below the threshold, inside the range of the plausibility rules, and in data of the current version. Thus it passes each check.
exercise
exercise Do this task in your own lab, with synthetic data only. Do not send a request to a site.
- Save the code example in an empty folder of your lab.
- Run the code with Node and the flag
--experimental-strip-types. - Record the flags of each change type.
- In the function
baseline, change the threshold0.05to0.01. - Run the code again.
- Record the flags of each change type, and compare the two tables.
sample answer
This sample answer uses the synthetic data of the code example only.
With the threshold 0.05, the row "small price" has no flag. With the threshold 0.01, the baseline diff flags it, because the change of 2% is above 1%. The row "stale" still has a flag only from the version probe, because its one changed price differs by less than 1%. The other rows do not change. A lower threshold finds smaller changes, but on real pages it also flags more real changes.
sources
- Monitoring Distributed Systems, Google, article, read 2026-11-20
- My model of a lab switch for changed data, of the three checks of a collector, and of the cost of changed data, 2026-11 (not public).
- Lab result of this course: changed data on a lab list page, two rule settings, 2026-11 (not public).