Queries select specific columns instead of SELECT *
Why it matters
Returning all columns from a user table — including password_hash, stripe_customer_id, and internal flags — in a general API response is an OWASP A02 data exposure pattern (CWE-200). Even when the fields are not sent to the client by the application, they consume network bandwidth and memory, and any serialization bug (an accidentally returned field, a JSON.stringify on the whole object) exposes sensitive internal data. For list views, fetching large content columns for 50 posts when only the title and summary are displayed is a performance problem at scale.
Severity rationale
Low because the exposure requires an additional serialization mistake to reach clients, but the data is in memory and on the wire in a form that amplifies the impact of any adjacent bug.
Remediation
Specify explicit column lists in every query. In Prisma, use select to list only the fields needed for the use case. Define reusable select constants for commonly fetched shapes.
// Reusable select shape — excludes sensitive and large columns
const userPublicSelect = {
id: true, email: true, name: true, avatarUrl: true, createdAt: true
// password_hash, stripeCustomerId: excluded
} as const
const user = await prisma.user.findUnique({
where: { id: userId },
select: userPublicSelect
})
// List view — exclude large content column
const posts = await prisma.post.findMany({
select: {
id: true, title: true, slug: true, createdAt: true,
author: { select: { id: true, name: true } }
// content: omitted — only fetch in detail view
}
})
For consistently excluded fields across the application, configure Prisma model-level omit defaults in schema.prisma.
DetectionPro
The detection method for this pattern is part of AuditBuffet Pro.
The full method (what to look for, pass and fail conditions, and how results get reported) ships inside the Database Design & Operations Audit. The pattern definition, severity rationale, and remediation remain openly licensed under CC-BY-4.0.
External references
- cwe · CWE-200 — Exposure of Sensitive Information to an Unauthorized Actor
- owasp:2021 · A02 — Cryptographic Failures
Taxons
History
- 2026-04-18·v1.0.0·Initial import from database-design-operations·automated