Skip to main content

How to fix: JSON Array at Top Level

API returns JSON array as top-level response. This check only inspects response shape; it does not check whether the endpoint is session/cookie-authenticated or returns sensitive data, which is what the underlying attack actually requires.

Why it matters

Only legacy browsers (pre-ES5, which supported overriding the Array constructor) were vulnerable to JSON hijacking, and only for endpoints that rely on ambient session cookies for auth. A public, unauthenticated read endpoint returning a bare array carries effectively no risk from this pattern.

Older browsers could include JSON in script tags and override the Array constructor to read its contents cross-origin.

How to fix it

  1. 1Wrap array in object, or use CORS properly.

Code examples

Wrap JSON arrays in objects; set X-Content-Type-Options

TypeScript
// BAD: returning a bare JSON array (exploitable in old browsers)
// return Response.json([...items]);

// GOOD: wrap in an object
return Response.json({ items });

// Also set X-Content-Type-Options: nosniff
return new Response(JSON.stringify({ items }), {
  headers: {
    "Content-Type": "application/json",
    "X-Content-Type-Options": "nosniff",
  },
});

References

Detected automatically by VulnRadar. The check id is json-hijacking-vulnerable, stable across every scan so you can filter or diff on it.

See every content check

Questions

How severe is JSON Array at Top Level?
VulnRadar rates this low severity in the content category. The severity is fixed per check, not scored per site, so the same finding is the same severity on every scan.
Does VulnRadar check for this automatically?
Yes. It runs as part of every scan under the check id json-hijacking-vulnerable, which stays the same between runs so you can filter, diff, or gate CI on it.

Missing a check?

The detection set is open. If you know a misconfiguration this does not catch, propose it: the issue template asks for the threat model, how to detect it, the false-positive risk, and a test fixture, which is the same thing a maintainer would have to work out anyway.

Propose a checkHow a check is built

Scan your own site for json array at top level

VulnRadar runs this check and hundreds more against a URL in seconds. No agent to install, just paste a URL.

Or scan this site as a demoRead the docs

How to fix: JSON Array at Top Level | VulnRadar