OOmnistu

Blog / Web & Ecommerce

Web & Ecommerce

Allow-list the fields a profile update may change, and test that a block-list leaks

Allow-list the fields a profile update may change and prove a block-list leaks. SQLite fixtures run the same attacks against three designs.

OOmnistu
Reviewed 2026-11-18 · 3 min read

A profile form has two fields: display name and email. The database row behind it has more: an admin flag, a credit balance, an owner ID. If the server copies every submitted field onto the row, a visitor who adds is_admin=1 to the request becomes an administrator. Nothing in the form needed to show that field. The attacker only had to guess its name.

This is mass assignment, which OWASP's Mass Assignment Cheat Sheet also calls autobinding or object injection depending on the framework. The sheet says it is exploitable when attacker-controlled input can set fields the caller is not authorized to change, and notes that field names can be guessed or discovered. Its recommended fixes are to prefer dedicated input objects that contain only editable fields, to explicitly allow-list fields when binding, and not to rely on a block-list alone, since a new or overlooked sensitive field remains bindable. It also says these controls limit writable properties and do not replace authorization for the requested record.

This guide tests those points in a small Python and SQLite sketch. It was prepared with AI assistance and reviewed on 18 November 2026. It is not a framework binder.

One function, three modes

The function update_profile checks that the caller is editing their own record, then builds the update. In allow mode it refuses any key outside display_name and email and checks each value is a string. The other two modes exist only to be tested: block removes the key is_admin and passes the rest on, and none passes everything.

EDITABLE = {'display_name': str, 'email': str}

if mode == 'allow':
    extra = set(payload) - set(EDITABLE)
    if extra:
        raise Refused('unknown fields: ' + ','.join(sorted(map(str, extra))))
    for k, v in payload.items():
        if type(v) is not EDITABLE[k]:
            raise Refused('bad type for ' + k)
    fields = dict(payload)

Column names reach the SQL text only from the allow-list in the real mode. Values are always bound as parameters. The other modes use a fixed schema check so the demonstration cannot touch anything unexpected.

Tests that must catch the weaker designs

A test that passes against the safe version proves little unless it also fails against a broken one. The fixture runs the same five attack payloads against each mode, each on a fresh database: setting is_admin, setting credits, setting owner_id, setting id, and sending an object where a string belongs. For each it checks whether protected state changed.

The assertions require at least those results. If someone weakened the allow-list, the first would fail. If someone made the other modes safer by accident, the mutation checks would flag it.

The ordinary cases

An update of display_name and email on your own record works and leaves the other user untouched. Nine bad payloads are refused: None, an empty object, a list, a string, an integer email, a null email, a boolean name, an upper-case EMAIL key and an integer key. An allowed field sent for another user's record is also refused, and that user's name is unchanged. The last case is the sheet's point that a field allow-list does not replace authorization. Both checks are needed.

All of it passes on Python 3.10.12 with SQLite 3.37.2.

Limits

This is a sketch of the idea. It has no web framework, no real binder, no nested-object binding and no real authentication. The sheet mentions that nested objects need review. Here, the nested case is just a dictionary where a string is expected. Your framework's DTOs or allowed-field settings need their own tests. Also, the block-list mode is a simplified stand-in, not a model of any specific framework feature.

Sources