Modern web frameworks make it easy to bind an incoming JSON request body directly to an ORM model or database update call. When an endpoint passes the entire parsed request object to the database without filtering which properties a user is allowed to edit, it creates a Mass Assignment (or Broken Object Property Level Authorization) vulnerability.
How mass assignment leads to privilege and billing tampering
Consider a profile update endpoint (`PATCH /api/v1/users/me`) where the frontend form sends `{ "displayName": "Asha", "timezone": "Asia/Kolkata" }`. If the controller passes `req.body` directly into `db.user.update({ data: req.body })`, an attacker can inspect the GET response for `/api/v1/users/me`, spot internal model columns, and include them in the PATCH payload:
- Role and permission escalation: submitting `{ "role": "admin" }`, `{ "isStaff": true }`, or `{ "permissions": ["*"] }` on a self-service profile or team-member update route.
- Tenant reassignment: changing `{ "organizationId": "org_target" }` during object creation or update to inject records into another customer's workspace.
- Billing and quota manipulation: overwriting `{ "plan": "plus", "scanCredits": 999, "paymentVerified": true }` on an order or account settings endpoint.
- Verification state bypass: setting `{ "emailVerified": true }` or `{ "mfaRequired": false }` during registration or account recovery.
Enforcing explicit input schemas and DTO allowlists
Blocklist filtering (such as deleting `req.body.role` before saving) is fragile because any new privileged column added to the database schema becomes writable by default until someone remembers to update the blocklist.
Instead, define a strict Data Transfer Object (DTO) or input validation schema (using libraries such as Zod, Valibot, Joi, or Pydantic) for each route and role. Explicitly pick only the fields that specific operation is allowed to modify, derive `userId` and `tenantId` exclusively from the verified server session, and use separate read serializers so internal administrative columns are never leaked in public API responses.
Never pass raw request bodies directly into ORM create or update calls; validate and pick an explicit allowlist of editable fields per endpoint.