How to fix: REST endpoint response exposes privileged fields
A response body contains privileged field names (role, isAdmin) that, if the same names are also accepted as unvalidated input, would let clients escalate privileges. Detected from response content only; this does not confirm the fields are writable.
Why it matters
Mass assignment lets an attacker send unexpected fields (role: 'admin', isVerified: true, creditBalance: 99999) in a JSON body and have them persisted directly to the database record, privilege escalation requiring only a crafted HTTP request.
Endpoints that bind a request body directly to a model (e.g., user.role, isAdmin, internalId) without an explicit allowlist let clients escalate privileges.
How to fix it
- 1Use explicit DTOs or field allowlists; never spread req.body directly onto ORM models
- 2Mark internal fields (role, isAdmin, isVerified) as non-writable in the schema
- 3Validate and strip unknown properties at the boundary using Zod, Joi, or similar
Code examples
Zod: strict DTO with unknown field rejection
import { z } from 'zod';
const UpdateUserDto = z.object({
name: z.string().min(1).max(100).optional(),
bio: z.string().max(500).optional(),
avatarUrl: z.string().url().optional(),
// role, isAdmin, isVerified are intentionally absent
}).strict(); // .strict() rejects any extra fields
router.put('/users/:id', requireAuth, async (req, res) => {
const parsed = UpdateUserDto.safeParse(req.body);
if (!parsed.success) {
return res.status(400).json({ errors: parsed.error.issues });
}
await db.users.update(req.params.id, parsed.data);
res.json({ success: true });
});References
Detected automatically by VulnRadar. The check id is api-rest-mass-assignment-risk, stable across every scan so you can filter or diff on it.
More api checks
- LowTRACE method referenced in API response body
- InfoREST endpoint allows DELETE
- LowGraphQL introspection field suggestions
- MediumGraphQL endpoint has no rate-limit headers
- LowOpenAPI server URL leaks internal host
- LowCORS preflight result not cached
- HighBearer token in URL query string
- MediumJSONP callback parameter accepted
Questions
- How severe is REST endpoint response exposes privileged fields?
- VulnRadar rates this low severity in the api 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 api-rest-mass-assignment-risk, which stays the same between runs so you can filter, diff, or gate CI on it.
- Which standards does REST endpoint response exposes privileged fields map to?
- It maps to CWE-915. In the OWASP Top 10 it falls under A08:2021.
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.