liveBook · Manning

Mass-assignment attack

As explained in Secure APIs

A mass assignment attack abuses automatic mapping of client-supplied properties to modify fields that should not be writable by the client.

A mass-assignment attack abuses automatic request-to-model mapping. When an API blindly binds client-supplied properties to a database model, attackers can change fields that should remain server-controlled. section 4.6.1

Changing a payment status

A payment endpoint should accept details such as amount and currency, while the server controls the payment status. If it constructs a payment model from the entire JSON body, a request containing "status": "accepted" may override that protected field. Similar changes could affect order status, discounts, loyalty points, or access privileges. section 4.6.1

Prevent the flaw by defining an input schema containing only client-writable fields, then constructing the database model from that constrained object. Keep generated identifiers, workflow status, and other sensitive attributes outside the accepted request.

Use these checks when reviewing an API:

  • Test whether a request can modify payment status, privileges, discounts, or other business-critical fields. section 4.6.1

How Secure APIs covers it

How deep it goes
Explains the failure mode, demonstrates vulnerable and constrained Python implementations, and stops short of framework-wide internals.
Examples
Uses payment status injection, Ruby on Rails user creation, and Python payment endpoint listings to illustrate the vulnerability.
What it assumes
Assumes basic familiarity with API requests, database models, and client-supplied fields while defining the vulnerability from first principles.
What you can do after
Apply constrained request schemas and test whether protected model fields can be changed through client payloads.
How it connects
Connects mass assignment with API schemas, database models, input validation, authorization, and business-critical state.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Secure APIs. The section links point to the parts of the book it draws on.