pypi django-tenants 4.0.6

one hour ago

Security release

This release stops a tenant's users from deleting other tenants or taking over their domains (GHSA-rmj3-rwfx-x6r2, high).

Tenant and domain rows can be reached from a tenant's own site, for example when the tenant model is registered in an admin served on tenant domains, as the tutorial does. A staff user of one tenant could bulk-delete other tenants, including the public tenant, and move other tenants' domains to their own tenant.

Affected: all versions before 4.0.6. All users should upgrade, especially projects that register the tenant or domain model in an admin reachable from tenant domains.

See the advisory for full details and workarounds.

Upgrade notes

  • From a tenant's schema, deleting another tenant or another tenant's domain, or adding, changing or moving another tenant's domains, now raises PermissionDenied. Code that does this while switched to a tenant (for example calling create_domain inside tenant_context() for a different tenant) should run it from the public schema, e.g. inside schema_context(get_public_schema_name()).
  • Off the public schema, TenantAdminMixin now lists only the current tenant, and does not allow adding tenants or deleting other tenants. The example projects now use TenantAdminMixin.
  • QuerySet.update(), bulk_create(), bulk_update() and related managers' add()/set() do not run these checks.
  • We recommend registering the tenant and domain models only in an admin served on the public domain.

Don't miss a new django-tenants release

NewReleases is sending notifications on new releases.