Skip to content

v0.7.2

Choose a tag to compare

@igorbenav igorbenav released this 28 Sep 03:36
· 16 commits to main since this release
94e36cc

Release v0.7.2 - Guardrails for Your Own Registration Route

Date: 2026-09-28

A small release about one thing: apps that register users through their own route instead of
CRUDAuth's /register. The allowlist has always protected CRUDAuth's endpoint, but nothing helped
an app audit the schema it wrote itself, and the field that matters most there, email_verified,
is what the OAuth account claim depends on. No breaking changes, and upgrading needs no code
changes.


Why this exists

CRUDAuth's /register keeps email and username, plus whatever you opt into with
register_extra_fields. Everything privileged is dropped unconditionally (is_superuser,
email_verified, the password, the OAuth identifiers, the primary key), and the gate covers a
column_map alias too.

An app with its own signup route gets none of that. If that route accepts email_verified, someone
can register under an address they don't own as already verified. When the owner later signs in
with Google, CRUDAuth finds a verified account with that email and links their provider identity to
it, but skips the claim, because the account looks like it proved itself. The claim is what would
otherwise make the password unusable, clear MFA, bump token_version and terminate the sessions.
So the person who registered first keeps password access to the account its owner now uses. The same
goes for google_id and github_id, which decide which account a provider login resolves to.

This shipped as a real vulnerability in a downstream project
(GHSA-h3fc-96x2-49rx),
which is what prompted the release: the defect wasn't in CRUDAuth, but nothing in CRUDAuth made it
easy to notice either.


The check

UserRepository.gated_register_fields(names) already existed; the sets behind it are now exported
from the package root, so an app can assert its own schema in one line:

from crudauth import REGISTRATION_GATED_FIELDS  # the full set, if you want to read it

def test_signup_accepts_no_privileged_field():
    assert not auth.repo.gated_register_fields(SignUp.model_fields)

It answers with the privileged fields a set of names contains, by logical name and by mapped
column, so a column_map rename can't slip one past. Put it next to your signup tests and a field
added later can't quietly reopen the hole.

A signup schema that's safe to write yourself:

class SignUp(BaseModel):
    model_config = ConfigDict(extra="forbid")

    email: EmailStr
    username: str
    password: str

Nothing privileged declared, extra="forbid" so an attempt is a 422, and build the row from those
fields plus a hash, never from **payload.model_dump(), which carries whatever the schema grew
since.


Documentation

  • "Registering users from your own route" in the registration guide, with the schema, the
    assertion, and why email_verified is the field that turns a careless signup into account
    takeover.
  • The two field sets are described on the UserRepository API page.
  • The same rule is in the agent skill references, so an assistant writing a signup route follows it:
    identity.md carries the schema and the assertion, and oauth.md records that the claim only
    holds while email_verified is server-owned, and that an app doing its own account linking has to
    claim as well.

Upgrading

pip install -U crudauth

Nothing is required. If your app has its own registration route, add the assertion above to its
tests. And if it links OAuth accounts with its own code rather than OAuthAccountService, check
that it claims an unverified account on link.


Full Changelog: v0.7.1...v0.7.2

Dependencies: unchanged.

Docs: https://benavlabs.github.io/crudauth