Browser Capability & Policy Boundary Telemetry

Permission Replay Debugger

Queries live browser permission states without triggering user prompts, executes capability probes inside an HTTP Permissions-Policy sandbox iframe (/probe/restricted-policy), correlates ReportingObserver violation records to initiating tool steps, and persists replayable JSONL traces in the Origin Private File System (OPFS).

Hypothesis

Recording navigator.permissions.query(), HTTP Permissions-Policy frame blocks, and ReportingObserver violations into a structured JSONL trace makes unattended permission escalation inspectable before shipping.

Confirm vs. Falsify

Confirm: restricted iframe probes emit ReportingObserver records that correlate cleanly to step IDs in OPFS JSONL. Falsify: silent browser denials block calls while emitting zero violation reports (counted under Reporting Gaps).

What to try first

Run Step 1 to query the 6-capability matrix, Step 2 to replay a 4-step tool sequence inside /probe/restricted-policy, and Step 3 to write, parse, and diff perm-journal.jsonl in OPFS.

3 Things To Try

Ready. Run step 1, 2, or 3 to collect live traces.
1

Scan Live Browser Matrix

Run a non-prompting navigator.permissions.query() scan across 6 capabilities (camera, microphone, geolocation, notifications, clipboard-read, persistent-storage) and attach live onchange listeners.

2

Replay Tool Sequence

Dispatch a 4-step tool sequence (camera, microphone, geolocation, WebUSB) inside the /probe/restricted-policy iframe and compare real ReportingObserver violations against silent denials.

3

Persist & Diff OPFS Journal

Write perm-journal.jsonl to the Origin Private File System (or memory fallback), parse it back via parseJsonl(), and inspect the line-by-line disk diff.

Live Capability Posture & Permission Matrix

Posture unscanned
Journal Entries 0
Policy Enforced 0
Violations Linked 0
Reporting Gaps 0
OPFS Store checking...
Browser navigator.permissions.query() posture merged with replay journal observations
Capability Policy Directive Browser Query State Iframe Policy Replay Attempts Violations Effective Posture

Sandboxed Policy Boundary & Step Correlator

Live Frame: /probe/restricted-policy loading...
Correlated Step <-> Violation Links 0 links
Events linked by correlateViolationsToStep()
Step Tool Feature Origin Frame Delta Disposition
No ReportingObserver violations correlated yet. Run Step 2 to execute probes inside /probe/restricted-policy.

OPFS JSONL Journal & Policy Wire Inspector

OPFS JSONL Journal & Disk Diff (perm-journal.jsonl) 0 lines

Live In-Memory JSONL Stream (serializeJsonl(entries))

# Empty journal. Scan permissions or replay tool sequence to emit JSONL records.

OPFS Persisted File vs In-Memory Diff (perm-journal.jsonl)

# Persist to OPFS (Step 3) to inspect line-by-line disk vs memory diff.
HTTP Policy & Reporting Wire Headers (GET / & GET /probe/restricted-policy) live fetch pending

Measured HTTP Response Headers

Fetching live headers from / and /probe/restricted-policy...

Raw Serialized ReportingObserver Events (report.toJSON())

[]
Correlated Trace & Posture Summary JSON (correlateViolationsToStep() + summarizePolicyPosture()) unscanned
{}

Architecture & Runtime Boundary

HTTP Boundary Headers Served by Worker

GET /
Content-Security-Policy: ... frame-ancestors 'self' https://aifoc.us https://*.aifoc.us http://localhost:* http://127.0.0.1:*; frame-src 'self';
GET /probe/restricted-policy
Permissions-Policy: camera=(), microphone=(), geolocation=(), usb=(), payment=()
Reporting-Endpoints
perm-endpoint="<origin>/api/report-noop"
POST /api/report-noop
Accepts browser application/reports+json batches and responds 204 No Content.
1. The Problem

Unattributed Capability Failures

Automated scripts, extensions, and embedded tool frames invoke media, geolocation, clipboard, or WebUSB APIs across document boundaries. When an HTTP Permissions-Policy header or browser permission blocks a call, standard exceptions do not link the violation report back to the tool step ID and frame origin that initiated it.

2. The Goal

Deterministic Policy Replay & Audit

Produce a verifiable capability trace before and during tool execution: query non-prompting navigator.permissions.query() states, test header-enforced isolation in /probe/restricted-policy, flag silent denials lacking a violation report, and bind every enforcement event to a structured JSONL audit log.

3. How It Works

Cross-Frame Trace Correlation

The probe iframe registers a ReportingObserver, serializes violation reports with .toJSON() to avoid DataCloneError, and forwards payloads over postMessage. correlateViolationsToStep() matches directive, origin, and timestamp delta to each tool step before writing perm-journal.jsonl to OPFS.

Permission Replay Debugger Runtime Architecture Flow from Tool Step to Permission Check and Permissions-Policy Frame, through ReportingObserver and Correlator, into the OPFS JSONL Replay Log, with side delivery to /api/report-noop. 1. TOOL CALL STEP Tool Script / Step ID step-01..04 + toolName origin + ts (ISO-8601) 2. POLICY BOUNDARY Permission Check & Frame navigator.permissions.query() <iframe /probe/restricted-policy> camera=(), usb=(), geo=() 3. TRACE CORRELATOR ReportingObserver + Link report.toJSON() -> postMessage correlateViolationsToStep() 4. OPFS REPLAY LOG perm-journal.jsonl serializeJsonl(entries) parseJsonl() + disk diff Reporting-Endpoints: perm-endpoint -> POST /api/report-noop (204 No Content)
Figure 1: Synchronous permission state probing, HTTP Permissions-Policy header enforcement inside the child iframe, ReportingObserver event serialization, and OPFS JSONL persistence.
How This Is Set Up · Implementation & Policy Contract

Code Matching the Live App

Query capability state before invocation with navigator.permissions.query(), isolate sub-frame execution behind HTTP Permissions-Policy headers, capture ReportingObserver violations, and persist correlated traces as OPFS JSONL records (perm-journal.jsonl).

Uninstrumented call (no attribution)
// Direct device calls trigger unlogged prompts or throw opaque errors across frames
async function captureFrame() {
  try {
    // No pre-flight permission query, no frame policy check, and no audit log
    const stream = await navigator.mediaDevices.getUserMedia({ video: true });
    return stream.getVideoTracks()[0];
  } catch (err) {
    // Cannot separate user denial from HTTP Permissions-Policy enforcement
    console.warn("Capture failed:", err.name);
    return null;
  }
}
Instrumented policy boundary & OPFS journal
// public/app.js + public/probe-client.js — query, observe violations, persist OPFS JSONL
const status = await navigator.permissions.query({ name: "camera" });
const allowedByFrame = document.permissionsPolicy?.allowsFeature("camera") ?? null;

const observer = new ReportingObserver(
  (reports) => reports.forEach((r) => forwardReport(r.toJSON())),
  { types: ["permissions-policy-violation", "feature-policy-violation"], buffered: true },
);
observer.observe();

// Persist correlated records to Origin Private File System as newline-delimited JSON
const root = await navigator.storage.getDirectory();
const handle = await root.getFileHandle("perm-journal.jsonl", { create: true });
const writable = await handle.createWritable();
await writable.write(serializeJsonl(correlated.entries));
await writable.close();
Complete Page Setup: HTML Markup, Journal Schema & Cross-Frame Wiring

End-to-end wiring from the restricted probe <iframe> in public/index.html, the PERMISSION_PROBES matrix and OPFS JSONL record schema in public/lib/perm-journal.js, ReportingObserver forwarding in public/probe-client.js & public/app.js, and Permissions-Policy + Reporting-Endpoints headers in src/worker.ts.

<!-- 1. Page HTML Setup (public/index.html) -->
<button type="button" id="btn-scan-permissions">Scan Permissions Matrix</button>
<button type="button" id="btn-run-replay">Replay Tool Script in Iframe</button>
<button type="button" id="btn-persist-opfs">Persist &amp; Diff OPFS JSONL</button>
<iframe id="probe-frame" class="probe-iframe" src="/probe/restricted-policy" title="Restricted Permissions-Policy Probe Frame"></iframe>
<script type="module" src="/app.js"></script>

// 2. Audited Permission List & OPFS JSONL Entry (public/lib/perm-journal.js)
export const PERMISSION_PROBES = [
  { name: "camera", policyDirective: "camera", apiSurface: "navigator.mediaDevices.getUserMedia({ video: true })", iframeProbe: true },
  { name: "microphone", policyDirective: "microphone", apiSurface: "navigator.mediaDevices.getUserMedia({ audio: true })", iframeProbe: true },
  { name: "geolocation", policyDirective: "geolocation", apiSurface: "navigator.geolocation.getCurrentPosition()", iframeProbe: true },
  { name: "notifications", policyDirective: null, apiSurface: "Notification.requestPermission()", iframeProbe: false },
  { name: "clipboard-read", policyDirective: "clipboard-read", apiSurface: "navigator.clipboard.readText()", iframeProbe: false },
  { name: "persistent-storage", policyDirective: null, apiSurface: "navigator.storage.persist()", iframeProbe: false },
];
const journalEntry = createJournalEntry({
  step: "tool-01",
  toolName: "media.capture_video_frame",
  origin: window.location.origin,
  permissionName: "camera",
  state: "policy-blocked",
  source: "permissions-policy-iframe",
  detail: 'NotAllowedError: Permissions policy "camera" blocked.',
  ts: Date.now(),
  frameUrl: `${window.location.origin}/probe/restricted-policy`,
  correlationId: "tool-01:camera:req-1",
});

// 3. Iframe ReportingObserver Forwarding & OPFS Persistence (public/probe-client.js + public/app.js)
new ReportingObserver(
  (reports) => reports.forEach((r) => window.parent.postMessage({ kind: "probe:violation-report", report: r.toJSON() }, location.origin)),
  { types: ["permissions-policy-violation", "feature-policy-violation"], buffered: true },
).observe();

state.correlationResult = correlateViolationsToStep(state.rawEntries, state.reportEvents);
const root = await navigator.storage.getDirectory();
const handle = await root.getFileHandle("perm-journal.jsonl", { create: true });
const writable = await handle.createWritable();
await writable.write(serializeJsonl(state.correlationResult.entries));
await writable.close();
Worker Policy Headers & Deterministic Step Correlation
// src/worker.ts — HTTP response headers served on GET /probe/restricted-policy:
//   Permissions-Policy: camera=(), microphone=(), geolocation=(), usb=(), payment=()
//   Reporting-Endpoints: perm-endpoint="https://<origin>/api/report-noop"
//   Content-Security-Policy: default-src 'self'; frame-ancestors 'self'; ...

// public/lib/perm-journal.js — correlate violations & count silent reporting gaps
const entry = createJournalEntry({
  step: "tool-01",
  toolName: "media.capture_video_frame",
  origin: window.location.origin,
  permissionName: "camera",
  state: "policy-blocked",
  source: "permissions-policy-iframe",
  frameUrl: `${window.location.origin}/probe/restricted-policy`,
  correlationId,
});
const { entries, correlations } = correlateViolationsToStep([entry], reportEvents);
const posture = summarizePolicyPosture(permissionStates, entries);
// posture.journalStats.silentPolicyBlocks counts blocked steps with 0 ReportingObserver records
What disappears

Uninstrumented getUserMedia and getCurrentPosition calls that trigger surprise prompts or fail silently without attribution across nested iframes.

What becomes explicit

Pre-flight PermissionStatus queries, HTTP Permissions-Policy allowlists per frame, ReportingObserver violation records, silent reporting gaps, and reproducible OPFS JSONL audit journals.

Platform gaps remaining

Not all capabilities expose navigator.permissions.query() names or document.permissionsPolicy.allowsFeature() uniformly across browsers, some policy blocks omit ReportingObserver entries, and child-frame reports require explicit postMessage forwarding.