Mass Assignment Lab: Add an Admin Flag the Form Never Showed

✨ AI Summary
QuickStart's signup form sends username, email and password — and the backend copies every field it receives into the new user record. The form never shows an 'admin' box, but nothing stops you from adding one to the request yourself.
Lab at a glance: Intermediate · 90 XP · about 15 minutes · runs in your browser, no signup or setup. Try it yourself first; the full solution is behind a spoiler below.

What this lab teaches

Mass assignment (also called autobinding or over-posting) happens when an app bulk-copies request fields straight into a data model. It is convenient — one line binds the whole form — but if the model has sensitive fields the user should not control, an attacker can set them simply by adding them to the request.

The lesson: the fields a form shows are not the fields a server will accept. Without a whitelist, the server accepts whatever you send.

How QuickStart creates your account

Signup takes your details as JSON and copies each key into the User record. The visible form sends only username, email and password, but the User model also has an is_admin field — and the backend has no list of which fields a signup is allowed to set.

The attack approach

  • Notice the signup body is JSON and the backend binds all of it to the user model.
  • Reason that the User record probably has fields the form does not show, such as a role or admin flag.
  • Add is_admin set to true to the signup request alongside the normal fields.
  • Because there is no whitelist, the extra field is copied in and your new account is an admin.

Full walkthrough (spoiler)

If a normal signup leaves you as a plain user, add the field yourself — open the steps.

Show the step-by-step solution
  1. Take the normal signup request with username, email and password.
  2. Add one more field, is_admin: true, to the JSON body.
  3. Submit it. The backend copies every field — including is_admin — into the new User record, because it has no field whitelist.
  4. Your account is created with admin rights. The lab detects the admin flag and marks you solved.

Why it works

The server trusts the shape of the request to match the form. By binding the whole body to the model, it lets the client decide which columns to fill — including ones the UI never exposes. The is_admin field was always there; the form simply never sent it, and nothing enforced that.

Core principleWhitelist the exact fields each endpoint may set. Never bind a whole request body to a model that has privileged fields.

Where this happens in the real world

The most famous case is GitHub in 2012, when researcher Egor Homakov used a mass-assignment flaw in Ruby on Rails to add his public key to an organisation he did not own. The same class — over-posting a role, balance or owner_id — remains common in APIs and maps to Broken Access Control (A01) in the OWASP Top 10 (2021).

How to defend against it

  • Use an explicit allowlist (strong parameters, DTOs) of the fields each endpoint may accept.
  • Separate input models from database models so privileged columns are never bindable from a request.
  • Mark sensitive fields read-only at the data layer so they cannot be set by user input.
  • Test by adding unexpected fields (is_admin, role, balance) to requests and checking whether they take effect.
Mr Elite tip: When testing an API you are authorised to assess, add fields you were never offered — role, is_admin, verified, owner_id — to create and update requests, and see whether the server honours them.

Try it, then go further

Reading about it is the easy part. Open the lab, try your own approach before peeking at the spoiler, and see how many attempts it takes.

❓ Frequently asked questions

What is mass assignment?
A bug where an app copies all fields from a request straight into a data model, letting an attacker set fields — like an admin flag — that the form never exposed.
Why is binding the whole request body risky?
Because the model often has fields the user should not control (role, is_admin, balance). Without a whitelist, the client decides which ones to fill.
What is the famous example?
In 2012 a researcher used mass assignment in Rails to add his key to the Rails organisation on GitHub, demonstrating the flaw publicly.
How do I prevent mass assignment?
Whitelist the exact fields each endpoint may set (strong parameters or DTOs), separate input from database models, and mark sensitive fields read-only.
⚡
Join free to earn XP for reading this article Track your progress, build streaks and compete on the leaderboard.
Join Free
Lokesh N. Singh aka Mr Elite
Lokesh N. Singh aka Mr Elite
Founder, Securityelites · AI Red Team Educator
Founder of Securityelites and creator of the SE-ARTCP credential. Working penetration tester focused on AI red team, prompt injection research, and LLM security education.
About Lokesh ->

Leave a Comment

Your email address will not be published. Required fields are marked *