aboutsummaryrefslogtreecommitdiff
path: root/test-suite/challenges/23-stack-trace-fingerprint.html
diff options
context:
space:
mode:
authorTianren Dong <tianrendong.dtr@gmail.com>2026-05-13 01:05:46 -0400
committerTianren Dong <tianrendong.dtr@gmail.com>2026-05-13 01:05:46 -0400
commit33110e803fcacc31dc2859dbc0d470b008556798 (patch)
treebb30dad365139c558f9d9651cb8bca375320cb8e /test-suite/challenges/23-stack-trace-fingerprint.html
parentd78081aa58ecaa1c72e847c2d095b5f07c391506 (diff)
pi-chrome: humanize synthetic input + anti-automation test suite
Bump 0.8.0 → 0.9.1. Companion extension (service_worker.js): - humanise pointer paths: easing Bezier-ish interpolation w/ wobble, 12–42 steps, 4–18 ms gaps; pointer position persisted across calls - click point picked inside element rect, not dead center - pointer events fill movementX/Y, screenX/Y, pressure (0.5 on down), pointerId, width/height, tilt, composed - click sequence: humanMoveTo → pointerdown → focus → 45–140 ms hold → pointerup → mouseup → click - per-character typing: keydown → keypress → beforeinput → value mutate (or execCommand for contenteditable) → input → keyup, with 25–95 ms hold + 35–140 ms inter-key; auto Shift chord for uppercase/symbols - pressKeyInPage emits same cadence + handles printable insert / Backspace - hoverPage: humanised path + 80–220 ms dwell - dragPage: full HTML5 sequence (dragstart/drag/dragenter/dragover/ dragleave/drop/dragend) with shared DataTransfer + pointer continuity - new scrollPage: wheel events with front-loaded momentum-shaped deltas - self-reload on version drift: SW reads x-pi-chrome-version header, reloads when older than pi-chrome Pi side (index.ts): - new chrome_scroll tool - PI_CHROME_VERSION read from package.json (and re-read on every /next so future bumps take effect without pi restart) - /chrome-doctor escalates version mismatch to top-line ✗ error and skips downstream capability probes when stale - /next response carries x-pi-chrome-version header for SW self-heal Test suite (test-suite/): - 28 challenge pages each catching a different synthetic-event tell: isTrusted, webdriver/fingerprint, mouse entropy/timing/coords, pointer pressure/continuity, per-char cadence + framework invariants, user activation, honeypots, focus order, wheel scroll, drag+ DataTransfer, contenteditable+Selection, paste/clipboard, native select, hover dwell, React valueTracker, keyboard modifiers, touch events, stack-trace fingerprint, viewport-edge clicks, mousemove rate, scroll momentum, IntersectionObserver visibility - shared _lib.js exposes window.__verdict + writes localStorage so index.html dashboard aggregates results - notes/bypass-ideas.md documents fixes still needed per challenge
Diffstat (limited to 'test-suite/challenges/23-stack-trace-fingerprint.html')
-rw-r--r--test-suite/challenges/23-stack-trace-fingerprint.html78
1 files changed, 78 insertions, 0 deletions
diff --git a/test-suite/challenges/23-stack-trace-fingerprint.html b/test-suite/challenges/23-stack-trace-fingerprint.html
new file mode 100644
index 0000000..4c1772b
--- /dev/null
+++ b/test-suite/challenges/23-stack-trace-fingerprint.html
@@ -0,0 +1,78 @@
+<!doctype html>
+<meta charset="utf-8">
+<title>23 stack-trace fingerprint</title>
+<link rel="stylesheet" href="../_style.css">
+<script src="../_lib.js"></script>
+<body>
+<main>
+ <p>Goal: click the button. The page samples call stacks from inside several
+ instrumented globals (<code>Function.prototype.toString</code>,
+ <code>document.querySelector</code>, <code>Element.prototype.click</code>) and inspects
+ the stack of <em>this script's own</em> handler. It fails if it sees telltales of
+ evaluator-injected frames (e.g. <code>at &lt;anonymous&gt;</code> as the only frame, the
+ bridge's <code>new Function</code> wrapper, <code>callFunctionOn</code>,
+ <code>executeScript</code>, or extension URLs).</p>
+ <button id="go" style="padding:14px 22px;font-size:16px;background:#1f7a1f;color:#fff;border:0;border-radius:6px">Click me</button>
+</main>
+<script>
+Challenge.init({ id: "stack-trace-fingerprint", instructions: "click the button" });
+
+// Suspicious stack-frame patterns commonly observed when code is invoked via
+// CDP Runtime.evaluate / chrome.scripting.executeScript / new Function bodies
+// dispatched from an MV3 service worker.
+const SUSPICIOUS = [
+ /chrome-extension:\/\//i,
+ /\bnew Function\b/,
+ /Runtime\.evaluate/i,
+ /Runtime\.callFunctionOn/i,
+ /executeScript/i,
+ /content[_-]?script/i,
+ /^\s*at\s+eval\b/m,
+];
+
+function inspectStack(stack) {
+ if (!stack) return ["empty stack"];
+ const hits = SUSPICIOUS.filter(r => r.test(stack)).map(r => r.source);
+ const lines = stack.split("\n").filter(l => l.trim().startsWith("at "));
+ // A natural inline-handler stack has ≥2 frames within this document.
+ const docFrames = lines.filter(l => l.includes(location.pathname.split("/").pop()));
+ const anonOnly = lines.length > 0 && lines.every(l => /<anonymous>/.test(l));
+ const reasons = [];
+ if (hits.length) reasons.push("suspicious frames: " + hits.join(","));
+ if (anonOnly) reasons.push("all stack frames anonymous");
+ if (lines.length && docFrames.length === 0) reasons.push("no frame from this document");
+ return reasons;
+}
+
+// Hook some commonly-touched APIs so any pre-click bridge instrumentation also
+// leaves a trail. Their stacks get inspected the moment the click handler fires.
+const probeStacks = [];
+const oTo = Function.prototype.toString;
+Function.prototype.toString = function () {
+ probeStacks.push({ where: "Function.toString", stack: new Error().stack });
+ return oTo.apply(this, arguments);
+};
+const oQS = Document.prototype.querySelector;
+Document.prototype.querySelector = function (sel) {
+ probeStacks.push({ where: "document.querySelector", sel, stack: new Error().stack });
+ return oQS.apply(this, arguments);
+};
+
+document.getElementById("go").addEventListener("click", (e) => {
+ const ownStack = new Error().stack || "";
+ const reasons = inspectStack(ownStack);
+ // Also check any probe stacks gathered before the click — the bridge often
+ // queries the DOM right before dispatching.
+ const probeBad = [];
+ for (const p of probeStacks) {
+ const r = inspectStack(p.stack);
+ if (r.length) probeBad.push(`${p.where}: ${r.join("; ")}`);
+ }
+ Challenge.log("stacks", { ownStack, probeStacks });
+ if (!e.isTrusted) return Challenge.fail("click isTrusted=false");
+ if (reasons.length) return Challenge.fail(...reasons);
+ if (probeBad.length) return Challenge.fail(...probeBad.slice(0, 3));
+ Challenge.pass("call stack matches an in-page event handler");
+});
+</script>
+</body>