Home / patterns

API responses that return whole database records (excessive data exposure)

A founder at a bright coworking table looking at a laptop with a blurred list of data fields, holding a black marker over a printed page with several lines redacted by black bars, a potted plant and notebook nearby, no brand logos
Quick answer: A common AI-generated shortcut is return Response.json(user) or res.json(await db.user.findMany()). That sends every column to the browser—password hashes, emails, internal flags, Stripe IDs, admin notes—even if the screen only shows a name. The page looks fine, but anyone can open DevTools and read the rest. OWASP calls this Broken Object Property Level Authorization (API3:2023), formerly “excessive data exposure.” The fix is to return only the fields each endpoint needs.

Last updated November 12, 2026

Steps

  1. Open your app with DevTools → Network, click through the main screens and inspect each JSON response. Note any field the user should not see: password or passwordHash, tokens, other users’ emails or phone numbers, role or isAdmin, internal notes, payment or customer IDs.
  2. Search the code for whole-object returns: res.json(user), Response.json(rows), return { ...record }, toJSON() on ORM models, and select * or Supabase .select('*') in queries that feed API responses or Server Components passed to client components.
  3. Replace them with explicit field lists. In Prisma use select for the few fields you need, or omit to drop sensitive ones (omit can also be set globally on the client for fields like password). In SQL or Supabase, list columns instead of *.
  4. Treat Next.js props the same way: anything a Server Component passes to a Client Component is sent to the browser, so map records to a small object first.
  5. For lists and public profiles, use a separate, smaller response shape than the owner’s own account view, and check the caller is allowed to see each property, not just the record.
  6. Add a response schema (for example a Zod object with only allowed fields, parsed before returning) so new columns added later are not leaked automatically.
  7. Retest: reload the screens and confirm the network responses now contain only what the page displays.

Why it matters

OWASP’s API Security Top 10 (2023) ranks Broken Object Property Level Authorization as API3. An endpoint is vulnerable if it exposes object properties the user should not read (previously named Excessive Data Exposure) or lets them change properties they should not touch (previously Mass Assignment). OWASP notes that inspecting API responses is enough to find sensitive properties, and that the impact can include data disclosure and, in some cases, account takeover. Its prevention advice: avoid generic serializers like to_json(), cherry-pick the properties you return, keep response data to the minimum the feature needs, and add schema-based response validation. MITRE’s CWE-200 covers the underlying exposure of sensitive information to an unauthorized actor. This page is for reviewing your own app’s responses.

Sources

OWASP API Security Top 10 2023: API3 Broken Object Property Level Authorization — https://owasp.org/API-Security/editions/2023/en/0xa3-broken-object-property-level-authorization/

MITRE CWE-200: Exposure of Sensitive Information to an Unauthorized Actor — https://cwe.mitre.org/data/definitions/200.html

Prisma docs: Excluding fields (omit) — https://www.prisma.io/docs/orm/prisma-client/queries/excluding-fields

Checked at the source on November 10, 2026.

Related patterns

Found a problem you'd rather not fix yourself?

Tell us what's wrong. A StorenTech engineer reviews your app and replies with a fixed quote, so you know the cost before any work starts.

Get it fixed by StorenTech

Vibe Security Weekly

One email a week with new failure patterns and how to fix them.

By joining you agree we may email you this newsletter. See our privacy policy. Free. Unsubscribe anytime. We'll never sell your email.