brainfish's picture
Add computer-use agent detection section (rule F6)
a6149af verified
|
Raw History Blame Contribute Delete
13 kB
---
license: mit
pipeline_tag: tabular-classification
tags:
- bot-detection
- tiny-model
- browser
- on-device
- behavioral-biometrics
- mouse-dynamics
- keystroke-dynamics
- int8
- javascript
---
# motorprint
**Live demo:** try it in your browser at https://motorprint.brainfish.ai or in the Hugging Face Space [brainfish/motorprint-bot-detection-demo](https://huggingface.co/spaces/brainfish/motorprint-bot-detection-demo).
**A tiny on-device bot vs human detector for the browser.** motorprint reads how the pointer, clicks, scrolling and typing move (speed, jerk, curvature, timing rhythm), scores each 3 s window with a small int8 neural net, and returns a bot score from 0 to 1. It runs inside the tab. There is no server, no LLM and no network call.
- **Code:** https://github.com/brainfish-ai/motorprint (commit `e5b3709`, branch `feat/real-human-data`, PR #1)
- **Paper:** [`paper/motorprint.pdf`](paper/motorprint.pdf), *motorprint: A 6 KB On-Device Bot Detector for the Browser, Built with Weight-Space Programming and Input Provenance Signals* (Ajain Vivek, Brainfish AI, 2026)
- **Model repo:** https://huggingface.co/brainfish/motorprint-bot-detection
- **Author:** Ajain Vivek, Brainfish AI
- **License:** MIT (see `LICENSE`)
> **Read the limitations before you use it.** It is a signal for a risk engine, not a gate. Never block a person on it alone.
## Model
| | |
|---|---|
| Architecture | MLP 38 → 32 → 16 → 1, ReLU, sigmoid output |
| Parameters | 1,793 (1,744 weights + 49 biases); 349 non-zero weights (80% pruned) |
| Weights | symmetric int8, one float scale per output row, base64 in a JSON spec |
| Size | model spec 4,488 B (1,763 B gzipped); whole library with model about 5.8 KB gzipped |
| Input | 38 features per 3 s window of browser input events (2 features, `click_offset` and `wheel_dy_cv`, are switched off) |
| Decision | EMA (α = 0.35) on window log-odds; `isBot` if the smoothed score ≥ **0.704** or any provenance signal fires |
| Hand-written parts | unit G (round 1) and units B, W, R (round 2), written directly in weight space following *Sparks of Weight-Space Programming* (Takehi, Teoh, Zhang and Khattab, MIT CSAIL, blog post, November 2026, https://rikiyat.github.io/blog/weight-space-programming/) |
| Provenance signals | `teleportClick`, `pressure0`, `keylessInsert` (round 3; computed in the recorder, not by the network) |
This repo does **not** contain an ONNX, PyTorch or safetensors export. The model is a JSON spec run by a ~50-line TypeScript runtime (`createModel` in the library).
## Files
| file | what it is |
|---|---|
| `model/motorprint-model.json` | the shipped `ModelSpec` (identical to `src/weights.ts` at `e5b3709`; `thr` 0.704) |
| `model/weights.ts` | the same spec as the TypeScript module the library imports |
| `model/handwritten-units-B-W-R.json` | the raw-feature parameters of the round-2 hand-written units |
| `results/round3-RESULTS.md`, `results/round3-combined.{md,json}` | round-3 benchmark tables and the JSON they come from |
| `results/bench-eval-pre-wsp2-baseline.json` | the gradient-trained baseline on the same benchmark |
| `results/replay-fingerprint.json` | the replay fingerprint study (not shipped) |
| `results/speed.json` | output of `bench/speed.mjs` (latency, sizes, memory) |
| `results/number-check-log.txt` | every headline number re-derived from the JSON (0 mismatches) |
| `paper/motorprint.pdf` | the paper |
## Usage
The library is the intended way to run the model. It is not published on npm yet, so install it from GitHub and build it (`npm run build:lib`). The package name is `motorprint`.
```ts
import { createBotDetector } from 'motorprint';
const detector = createBotDetector({
onScore: ({ score, isBot, threshold, windows, signals, reasons }) => {
// score: 0..1, smoothed over windows. threshold: 0.704.
// signals: { teleportClick, pressure0, keylessInsert } counts since start (sticky).
// reasons: 'motion' and/or the names of the signals that fired.
if (windows >= 4 && isBot) markSessionSuspicious({ score, reasons });
},
});
// later: detector.stop()
```
Motion only (ignore the provenance signals; recommended if your audience uses Safari, Firefox, pens, remote desktop or dictation, where the signals are unverified):
```ts
const detector = createBotDetector({ useSignals: false, onScore: (s) => { /* s.isBot is score >= 0.704 */ } });
```
React:
```tsx
import { useBotScore } from 'motorprint/react';
const bot = useBotScore(); // BotScore | null
```
`BotScore` = `{ score, raw, isBot, threshold, windows, events, features, inferenceMs, signals, reasons }`. Other options: `intervalMs` (500), `windowMs` (3000, must match training), `minEvents` (4), `smoothing` (0.35), `model` (bring your own spec, for example `model/motorprint-model.json`), `autoStart` (true). `scoreEvents(events)` scores a recorded session offline.
To run the bare network on a feature vector:
```ts
import { createModel, extractFeatures } from 'motorprint';
import spec from './motorprint-model.json';
const m = createModel(spec);
const p = m.predict(extractFeatures(windowEvents, 3000)); // probability of automation for one window
```
## Training data
- **Humans (real):** six openly licensed research datasets, 421 users, 5,657 sessions: AdSERP, Freihaut & Göritz MouseTask, DUX, Bogazici (BOUN) mouse dynamics (mouse); KeyRecs and the CMU keystroke benchmark (typing). Five are CC BY 4.0; CMU states the data is "freely available for use" with citation. All were converted to browser events (see `DATA.md` in the code repo). Split by user 70/15/15 (268 / 74 / 79 users).
- **Bots (training):** 460 Playwright sessions in five styles (teleport, linear, eased, bezier, DOM events).
- Raw data is not redistributed here. The dataset authors do not endorse motorprint.
## Evaluation
Benchmark: 10 off-the-shelf tools at their defaults on a four-task test page. Set A has 300 sessions per tool, set B (re-recorded with a provenance probe) has 80 per tool; results use the held-out eval half only (148 per tool in A, **40 per tool in B**). Humans are 2,547 ten-second segments from the 79 held-out test users. The threshold is calibrated on **validation users only** (worst validation dataset ≤ 0.5% session FPR) and applied unchanged. **Score** = mean session detection over the 10 tools, set to 0 if any test dataset exceeds 1% session FPR.
Session detection (%) per tool (from `results/round3-RESULTS.md`):
| detector | ghost | pptr-st | pw-st | uc | nodriver | botasaurus | pyautogui | MCP | replay-CDP | replay-xdo | worst test FPR | pooled test FPR | score | without replays |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| pre-WSP-2 model (fair baseline) | 57.4 | 45.9 | 49.3 | 29.1 | 47.3 | 7.4 | 75.0 | 45.9 | 2.0 | 31.1 | 0.5% | 0.2% | 39.1 | 44.7 |
| A: WSP-2 model | 76.4 | 45.9 | 49.3 | 29.1 | 46.6 | 64.9 | 85.8 | 45.9 | 2.0 | 31.1 | 0.54% | 0.16% | 47.7 | 55.5 |
| A: + F1 teleport-instant-click | 76.4 | 100 | 100 | 98.6 | 46.6 | 64.9 | 85.8 | 100 | 2.0 | 31.1 | 0.54% | 0.20% | 70.5 | 84.0 |
| A: fine-tune LOTO + F1 (not shipped) | 93.2 | 100 | 100 | 98.6 | 73.0 | 69.6 | 85.1 | 100 | 2.7 | 31.1 | 0.56% | 0.20% | 75.3 | 89.9 |
| A: fine-tune, in-sample tools + F1 | 94.6 | 100 | 100 | 98.6 | 73.6 | 85.1 | 85.8 | 100 | 2.7 | 31.1 | 0.50% | 0.20% | 77.2 | 92.2 |
| B: WSP-2 model | 77.5 | 45.0 | 47.5 | 32.5 | 47.5 | 70.0 | 90.0 | 47.5 | 0 | 0 | 0.54% | 0.16% | 45.8 | 57.2 |
| B: + F1 | 77.5 | 100 | 100 | 100 | 47.5 | 70.0 | 90.0 | 100 | 0 | 0 | 0.54% | 0.20% | 68.5 | 85.6 |
| **B: + F1 + F2 pressure0 (shipped)** | **100** | **100** | **100** | **100** | **100** | **100** | **90.0** | **100** | **87.5** | **0** | **0.54%** | **0.20%** | **87.8** | **98.8** |
| B: + F3 keyless insert | same | | | | | | | | | | | | 87.8 | 98.8 |
| B: rules only, no model | 100 | 100 | 100 | 100 | 100 | 100 | 0 | 100 | 87.5 | 0 | 0.50% | 0.04% | 78.8 | 87.5 |
- The "A" and "B" rows also OR in an isTrusted check, which the library does not expose as a signal (it adds nothing once F1 is in on set A).
- Per-dataset test FPR of the shipped combination: AdSERP 0.21% (1/481), BOUN 0.50% (1/201), KeyRecs 0.54% (3/552), others 0. 95% Wilson upper bound on the KeyRecs rate: 1.59%.
- 95% interval on the shipped score (Jeffreys posterior per tool): 87.8 [85.0, 88.3]; without replays 98.8 [95.8, 98.9].
- The baseline (set A) and the shipped row (set B) are different recordings. Within set B the motion model alone scores 45.8.
- The B replay-xdotool 0 is because the first 80 plan slots replay mouse-only traces.
- Leakage: an independent audit found 119 eval sessions whose feature sequence also occurs in the design half; excluding them moves the round-2 score from 48.85 to 47.57.
Speed (`bench/speed.mjs`, shared 8-core Intel Xeon VM, Node 22.23.4 and headless Chrome 156): one scoring tick (window + features + network) p50 / p95 / p99 = 18.8 / 71.0 / 134.5 µs in Node and 20 / 100 / 160 µs in Chrome; the network alone about 2.6 µs (Node); about 0.38 µs of feature work per event in the window; recorder overhead about 0.5 µs per `mousemove`.
## Computer-use agent detection
The shipped model now runs with one more rule aimed at computer-use agents, which drive a real browser by sending synthetic mouse and keyboard input.
- **Rule F6 (hop-click):** fires when the last cursor move before a press is a single jump of 150 px or more and the press is released under 5 ms later.
On **48 held-out real agent sessions** (form filling, navigation, reading and search tasks):
- Shipped model weights alone: **17/48 detected (35.4%, 95% Wilson CI 23.4 to 49.6%)**
- Shipped weights plus rules F1 and F6: **48/48 detected (100%, CI 92.6 to 100%)**, at the first click
Human test false positive rate is unchanged: the worst dataset is still KeyRecs at 0.5435%, and the pooled rate is 0.196% over 2,547 ten-second segments. On simulated agents that move, pause, then click, F6 raises detection from 4/8 to 8/8. The model weights and the 0.704 threshold are unchanged.
The 10-tool benchmark was not re-recorded for this change. F6 can only add detections and never removes existing ones.
## Limitations
- **The provenance rules were found by studying the benchmark tools, and they are evadable.** F1 (a press with exactly one move in the prior 1 s, that move ≤30 ms before the press, release <5 ms later) is the default click of Puppeteer, Playwright and Selenium; F2 (a mouse `pointerdown` with pressure 0) is CDP's default `force=0`. An attacker who passes `force:0.5` and adds move steps and a press delay defeats both. Playwright already defeats F2. Against such an attacker, expect the motion-only numbers (45.8 to 47.7).
- **Pressure-0 is unverified on Safari, Firefox, pens, touch-to-mouse compatibility events and remote-desktop or VNC injectors.** No human dataset records pointer attributes; it fired on 0 of 160 real OS-input sessions in Chrome on Linux only. `keylessInsert` is also unverifiable on our data (dictation, IMEs and password managers are risks). Use `useSignals: false` if this matters.
- **Replays are not caught.** Real human traces replayed through OS input (replay-xdotool) pass. replay-CDP is caught only because the replayer used CDP. A replay fingerprint was prototyped but collides with 0.4 to 1.6% of human sessions, so it is not shipped.
- **Leave-one-dataset-out generalization is poor.** With AdSERP held out of training, models flag about 44 to 49% of its people (43.7% in the repo's LODO run; 46.4 to 48.6% in the independent audit). Expect a higher FPR on your own traffic than 0.54%.
- **Some dataset conversions are lossy or synthetic:** frame coalescing for DUX and BOUN, MouseTask clicks dropped, synthetic `input` events for keystroke datasets, an artificial gap between CMU repetitions, no wheel deltas or target rectangles anywhere. Only AdSERP and DUX contain scrolling.
- **Desktop research recordings only.** No touch, phones, autofill or assistive technology. Make sure assistive-technology users are never locked out.
- **Small held-out sample.** The shipped score uses 40 sessions per tool; the tools ran on one page with tasks we designed; the MCP agent used a scripted policy, not an LLM.
- **Client-side scores can be forged.** Pair the score with server-side checks (rate limits, IP and ASN reputation, TLS fingerprints, challenges).
## Future work
A new real-browser human cohort (several browsers and devices, native scroll, click, key and pointer attributes) used once as a frozen test set, and challenge-response for replays (for example a target that moves after page load).
## Citation
```bibtex
@misc{vivek2026motorprint,
title = {motorprint: A 6 KB On-Device Bot Detector for the Browser, Built with Weight-Space Programming and Input Provenance Signals},
author = {Vivek, Ajain},
year = {2026},
note = {Brainfish AI. Code: https://github.com/brainfish-ai/motorprint. Model: https://huggingface.co/brainfish/motorprint-bot-detection}
}
```