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
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)
})// 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 } })Every gate held. The exploit path was reproduced against a negative control, the impact was calibrated, and the finding was signed report-ready.
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
- List every global event listener that leads to an authenticated network call.
- Confirm each telemetry or analytics payload is schema-validated before it is sent.
- Check whether your app's main token is reused for low-value calls that could carry a narrower one.
- Assume every third-party script can fire any event your page listens for.