CWE-915: Mass Assignment
An application binds client-supplied fields directly to an object, letting a user set attributes that were never meant to be writable.
Also known as: Mass assignment, Autobinding vulnerability, Object injection
Risk
Typically high. One extra field in a request can flip a user to admin, change ownership, or alter a balance, and the writable surface is invisible unless the code restricts it explicitly.
Definition
What it is
CWE-915 occurs when an application takes a request body and binds all of its fields onto an internal object or record without restricting which attributes may be set. Convenience features that map input to model properties will happily set fields the user should never control, such as a role, an owner id, a verified flag, or a price. By adding those fields to the request, the user modifies attributes outside the intended form. The weakness is the absence of an allowlist of writable fields.
Use-cases
How it shows up in real code
Role flip via extra field
A profile-update endpoint binds the whole body to the user record. The user adds a role field set to admin and the automatic mapping grants it.
Changing ownership
An update request is bound directly to an order object. The user adds an ownerId field and reassigns the record to themselves or away from another user.
Flipping a verified flag
A sign-up binds all fields to the account. The user includes an emailVerified or isApproved field and bypasses the verification workflow.
Overwriting a price
An order-create endpoint maps the body onto the order, and the user adds a price or discount field, setting a value the server should have computed.
AI risk
Why AI-generated code has increased the exposure
- Assistants reach for convenient bind-everything patterns because they are short and match the prompt, leaving the writable attribute surface unrestricted.
- Which fields are sensitive depends on the data model the assistant cannot see, so it does not know to exclude role, owner, or verified flags.
- Models optimize for the shortest working handler, and whole-body binding is shorter than an explicit allowlist of permitted fields.
- Framework examples in training data commonly show direct model binding without a field allowlist, and that pattern is reproduced as the default.
- Every generated create and update endpoint that binds the body is another mass-assignment surface, so scaffolding many of them scales the exposure.
Vibe coding
How vibe coding amplifies the risk
- Vibe coding ships bind-everything handlers whose dangerous writable fields are invisible in an unread diff.
- Testing with the intended form fields only, the developer never sends an extra field, so the open attribute goes unnoticed.
- Prompt-and-ship skips the review where someone would ask which fields this endpoint should actually allow.
- A quick prototype that bound the whole request body is promoted to production unchanged.
- Rapid CRUD generation multiplies body-binding endpoints faster than anyone audits each for an allowlist.
Detection
How to find it
- Find endpoints that bind a whole request body to a model and confirm an allowlist limits which fields may be set.
- List the sensitive attributes (role, owner, verified, price) and confirm none can be set from client input.
- Send requests with extra, unexpected fields and confirm the server ignores or rejects them.
- Review framework autobinding defaults and disable blanket binding where it is enabled.
Remediation
How to fix it
- Bind only an explicit allowlist of fields the user is permitted to set on each operation.
- Use a dedicated input type or data-transfer object that excludes sensitive attributes entirely.
- Set sensitive fields such as role, owner, and verified flags on the server, never from the request.
- Reject or ignore unexpected fields rather than silently assigning them.
- Add tests that submit extra sensitive fields and fail the build if the server persists them.
Frequently asked questions
- What is CWE-915 (mass assignment)?
- CWE-915 is when an application binds client-supplied fields directly onto an internal object or record without restricting which attributes may be set, so a user can add fields like role, owner, or verified to a request and change values they should never control. The flaw is the absence of an allowlist of writable fields.
- How have AI assistants and vibe coding increased mass assignment risk?
- Assistants reach for convenient bind-everything patterns that match the prompt and cannot see which fields are sensitive, so they leave the writable surface open. Vibe coding ships those handlers unread, and because the developer tests only with the intended form fields, the extra writable attribute stays invisible until someone adds it to a request.
- How do I fix mass assignment?
- Bind only an explicit allowlist of permitted fields, use a dedicated input object that excludes sensitive attributes, set role, owner, and verified flags on the server, reject unexpected fields, and add tests that submit extra sensitive fields to confirm the server ignores them.
Related weaknesses
Catch CWE-915 before you ship
Tethlyn Audit scans your codebase and its git history for CWE-915 and the rest of the broken access control & authorization class, then ranks each finding by real exploitability and data sensitivity.