Delegated Authority · Replayable Browser Permission Audits

Permission Replay Debugger

When third-party scripts, widgets, or browser extensions try to touch your camera, microphone, location, or USB devices, it is hard to see which step requested access and whether your HTTP rules blocked it. This workbench inspects live Permissions API states without triggering popups, runs probes inside an HTTP Permissions-Policy iframe, captures browser ReportingObserver and Reporting-Endpoints reports, and saves replayable JSONL logs in the Origin Private File System (OPFS).

Why this matters

Unattended scripts and embedded iframes can probe sensitive hardware APIs silently, and standard JavaScript errors do not separate a user denial from an HTTP policy block or link the violation back to the script step that triggered it.

What this opens up

Teams can record, export, and re-import permission traces as plain .jsonl files, then test tighter Permissions-Policy or Report-Only rules offline before rolling them out—while surfacing silent denials that never emit a browser violation report.

How the tests work

Run the three steps below to scan six browser permissions without popups, fire a 4-step probe inside a restricted iframe to correlate violation reports, and save or diff the perm-journal.jsonl log in local OPFS storage. Then edit the policy matrix to replay old traces against stricter rules.

3 Things To Try

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

Run these three checks in order to inspect your browser's current permissions, trigger real HTTP policy blocks inside a child iframe, and verify the local audit file.

1

Scan Current Browser Permissions

Reads the current state of 6 browser permissions (camera, microphone, geolocation, notifications, clipboard-read, persistent-storage) without showing any permission popups.

2

Run 4 Blocked Probes Inside Iframe

Sends camera, microphone, geolocation, and WebUSB requests inside the restricted /probe/restricted-policy iframe to compare captured ReportingObserver violations against silent denials.

3

Save & Diff Local OPFS Audit Log

Writes perm-journal.jsonl to your browser's private local file system (OPFS), reads it back line by line, and checks that the on-disk trace matches memory.

Live Capability Posture & Permission Matrix

Posture unscanned
Journal Entries 0
Policy Enforced 0
Violations Linked 0
Reporting Gaps 0
OPFS Store checking...

Combines passive browser permission queries with actual iframe blocks so you can spot which blocked calls emitted a report and which failed silently.

Browser navigator.permissions.query() posture merged with replay journal observations
Capability Policy Directive Browser Query State Iframe Policy Replay Attempts Violations Effective Posture

Policy Boundary, Iframe Sandbox Toggle & Step Correlator

Toggle iframe sandboxing or parent delegation below, trigger individual hardware probes, and see which step produced each violation report.

same-origin iframe (unsandboxed)

Host delegation vs. child policy: A parent page's HTTP Permissions-Policy sets the upper bound. The parent's <iframe allow> attribute can only delegate features the host permits, and a child document's own Permissions-Policy: camera=() header always overrides a permissive parent allow attribute. Enabling sandbox="allow-scripts" moves the frame to an opaque null origin where (self) no longer matches the host origin.

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.

Editable Policy Matrix & Trace Replay (replayRun())

Change any feature between deny, allow, and report-only—or import a saved .jsonl trace—to preview which steps would flip from allowed to blocked.

Permissions-Policy: camera=(), microphone=(), geolocation=(), usb=(), clipboard-read=(self), payment=() 0 outcome flips
Accepts exported perm-journal.jsonl files or pasted JSONL lines.
Re-evaluated step outcomes from replayRun(recordedEntries, editedPolicyMatrix)
Step Capability Recorded Replayed Status Policy Evaluation Reason
Record steps with Step 1 or Step 2, edit any capability policy above, then click Replay Stored Trace Against Policy.

OPFS JSONL Journal & Policy Wire Inspector

Inspect the raw newline-delimited audit log, live HTTP policy headers, browser violation reports, and server-collected batches stored in SQLite.

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())

[]
Server-Collected Reports (GET /api/report/:runId · Durable Object) 0 server reports
Active endpoint: /api/report/default-session
[]
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=() (plus optional ?policy=report-only|camera-only|custom)
Probe CSP frame-ancestors
frame-ancestors 'self' https://aifoc.us https://*.aifoc.us http://localhost:* http://127.0.0.1:* (required for nested embedding inside aifoc.us)
Reporting-Endpoints
default="<origin>/api/report/<runId>" (backed by SQLite Durable Object ReportCollector)
POST / GET / DELETE /api/report/:runId
Stores browser application/reports+json batches (204 No Content), lists stored reports as JSON, or clears the session log.
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.

Architecture Permission policy boundary, violation correlation & OPFS replay pipeline
Inside Browser Tab · Host Policy -> Iframe Delegation -> Child Header -> Replay
1. Tool Step

Script & Passive Permission Scan

navigator.permissions.query()
  • Tags each step (step-01..04) with tool name and correlation ID
  • Lets you toggle sandbox="allow-scripts" and parent allow rules
2. Restricted Iframe

Probe Frame /probe/restricted-policy

  1. Parent HTTP Permissions-Policy sets the maximum allowed features
  2. Child header blocks camera, microphone, geolocation, and usb
  3. ReportingObserver captures browser violation reports via .toJSON()
  4. Forwards both attempt results and violation reports to the parent page
3. Replay

Correlator & Policy Replay

replayRun(entries, editedMatrix)
correlateViolationsToStep() silent gap count
4. OPFS Log

Local JSONL Journal

opfs://perm-journal.jsonl

serializeJsonl() and parseJsonl() round-trip with line-by-line disk diff.

Cloudflare Edge Worker src/worker.ts

HTTP Headers & Reporting Sink

Emits matching frame-ancestors CSP on / and /probe/restricted-policy, configurable Permissions-Policy / Permissions-Policy-Report-Only headers, and Reporting-Endpoints: default="<origin>/api/report/<runId>" stored in the ReportCollector SQLite Durable Object.

Figure 1: Permission state probing, HTTP Permissions-Policy header enforcement inside the child iframe, ReportingObserver serialization, policy matrix replay via replayRun(), 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-routes.ts — HTTP response headers served on GET /probe/restricted-policy?runId=...:
//   Permissions-Policy: camera=(), microphone=(), geolocation=(), usb=(), payment=()
//   Reporting-Endpoints: default="https://<origin>/api/report/<runId>"
//   Content-Security-Policy: default-src 'self'; frame-ancestors 'self' https://aifoc.us ...;

// 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.

Key terms & further reading
HTTP Permissions-Policy
An HTTP response header that lets a page or iframe allow or block sensitive browser APIs (camera, microphone, geolocation, USB) before any script runs.
Reporting-Endpoints
An HTTP header that tells the browser where to POST structured violation report batches (application/reports+json) asynchronously.
ReportingObserver
A browser JavaScript API that listens in-page for policy violations so an app can match blocked calls to the exact step that triggered them.
Permissions API (navigator.permissions.query())
Checks whether a browser permission is currently granted, denied, or prompt without popping up a permission dialog.
Origin Private File System (OPFS)
Fast local file storage private to a site's origin, used here to persist and diff newline-delimited JSON (.jsonl) audit traces.
Cloudflare Durable Objects (ReportCollector)
A per-session SQLite-backed edge endpoint that stores browser-delivered violation batches so you can compare server reports against in-page traces.