Blog / A01:2021 Broken Access Control
A01:2021 · Broken Access Control

Any script on your page can send telemetry as you

A global event listener takes whatever detail it's handed and ships it with your app's bearer token. A third-party widget can forge data in your name.

a scriptdispatches…handler reads theevent detailno origin orschema checkpayload batchedwith the…sent as theauthenticated appATTACKER INPUTIMPACTcheck absent
Attack path · a script dispatches the global event → handler reads the event detail → no origin or schema check → payload batched with the auth header → sent as the authenticated app

A global event listener takes whatever detail it's handed and ships it with your app's bearer token. A third-party widget can forge data in your name.

What goes wrong

The telemetry handler listens for a custom event that any code on the page can fire. There's no check on where the event came from or whether its payload has the shape you expect. Whatever sits in the event's detail gets batched and sent with the Authorization header your app already holds.

Browsers give every script on a page the same DOM. The analytics vendor's snippet can dispatch that event. So can a compromised dependency, or an injected ad. The server sees a well-formed, authenticated request and has no way to tell it came from something you didn't write.

The impact here is measured, not catastrophic. Forged telemetry pollutes your data and can hide real activity or trip downstream logic that trusts those events. It is still your token on the request.

The pattern

Vulnerable
window.addEventListener("app:telemetry", (e) => {
    // any script on the page can dispatch this
    queue.push(e.detail)
})

function flush():
    fetch(endpoint, {
        method: "POST",
        headers: { Authorization: bearer },
        body: JSON.stringify(queue)
    })
Hardened
// no globally dispatchable event; callers import this
function recordTelemetry(event):
    if (!matchesSchema(event)):
        return                    // reject unknown shapes
    queue.push(pick(event, allowedFields))

function flush():
    // short-lived, telemetry-scoped token
    fetch(endpoint, { headers: { Authorization: telemetryToken } })
How the pipeline adjudicated itPROVEN
ABCDEFGH

Every gate held. The exploit path was reproduced against a negative control, the impact was calibrated, and the finding was signed report-ready.

Ed25519 · per-tenant signing key · gate ledger A–H · verify offline against the published payload hash

Why it matters to you

Anything on the page runs with your app's authority in the browser. If a value that leaves your app under a bearer token can be produced by code you do not control, that is a supply-chain hole waiting on one bad dependency. Scope the token to what telemetry actually needs, and stop treating the DOM as a trusted input boundary.

Check your own code