liveBook · Manning

Overposting

As explained in ASP.NET Core in Action, 3e

Overposting is a security vulnerability in which client-supplied fields are bound directly to properties that the application did not intend to expose for modification.

Overposting is a security vulnerability caused by binding client-supplied fields directly to an entity. Fields that were not intended for editing may then become writable. section 12.4.1

Prevent overposting by keeping request binding separate from persistence:

  • Bind the request to a purpose-specific command or input model rather than directly to the database entity. section 12.4.1 section 16.4
  • Copy only permitted properties into the entity before saving it. section 12.4.1
  • Avoid applying [BindProperties] broadly; bind a single property with [BindProperty] when using Razor Pages. section 16.4

Creating a recipe safely

A POST handler accepts CreateRecipeCommand, creates a new Recipe, and explicitly copies fields such as Name, Method, and IsVegetarian. It then adds the entity to AppDbContext and saves it. The client cannot choose arbitrary Recipe properties through direct entity binding. section 12.4.1

How ASP.NET Core in Action, 3e covers it

How deep it goes
Defines the vulnerability and demonstrates explicit mapping, but does not show a concrete attack payload.
Examples
Uses CreateRecipeCommand-to-Recipe mapping and a Razor Pages InputModel with selective property binding.
What you can do after
Apply it via purpose-specific binding models and explicit property mapping before persistence.
How it connects
Connects model binding with EF Core entities, Razor Pages, input models, and validation.

Also explained in

Compare how 2 books explain overposting →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of ASP.NET Core in Action, 3e. The section links point to the parts of the book it draws on.