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

Last updated November 12, 2026
Steps
- 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.
- 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.
- 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 *.
- 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.
- 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.
- 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.
- 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
- Mass assignment: users can set fields like role or is_admin
- IDOR in vibe-coded apps: changing an ID in the URL to see someone else's data
- RLS or auth present, but no ownership check (IDOR)
- Error messages that leak stack traces, queries or keys
- Passwords, tokens and personal data written to your logs
- Passwords stored in plain text or with fast hashes
- API routes with no auth check
- GraphQL APIs with introspection on and no depth or cost limits
- CSV exports that run formulas when opened in a spreadsheet (CSV injection)
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 StorenTechVibe 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.