Expand description
The Omniscient Page: a passive, always-on instrumentation grid injected into every page’s MAIN world before its scripts run.
A human pentester goes looking for a DOM-XSS sink, a CSP gap, a postMessage
handler. This module makes the page report all of them on its own: every
write to a known DOM-XSS sink (with the actual value + a JS stack), every
console line, every uncaught exception, every CSP violation, and every
inbound postMessage is recorded into a bounded buffer the agent reads at
will. Active hunting becomes passive telemetry, coverage no human can hold
across every page, continuously.
The script is injected two ways (see crate::Page::start_sensors): as a
preload (so it runs before page scripts on every navigation) AND evaluated
once on the current document (so a page already loaded at launch is covered).
It is idempotent, defensive (every hook is wrapped in try/catch and calls the
ORIGINAL implementation), and bounded (ring buffers capped), so it never
breaks or hangs the page it observes.
Constants§
- SENSOR_
BUFFER_ CAP - Per-category ring-buffer cap. A hostile page that spams
console.logor fires sink writes in a loop cannot grow this without bound (Law 7). - SENSOR_
SCRIPT - The sensor install script, an idempotent IIFE so the SAME source is valid
both as a preload body and as a one-shot
evaluateexpression. - SENSOR_
SNIPPET_ LEN - Max captured length of any single value/code snippet.
Functions§
- sensor_
reader - Build the reader expression. When
clearis true the buffer slices are emptied after the snapshot is taken (so the agent can read deltas).