GHSA-CX9C-3CC5-GG94
Delegated permission managers can grant themselves page rights they do not hold via the global page permission admin
CVSS:3.1/AV:N/AC:L/PR:H/UI:N/S:U/C:L/I:H/A:L
Fuente: GitHub
Ciclo de vida de la vulnerabilidad
| Fecha | Fase | Evento | Detalle |
|---|---|---|---|
| Remediación | Parche 5.1.3 | django-cms · -1 d desde divulgación | |
| Divulgación | Publicada | GHSA-CX9C-3CC5-GG94 divulgada · CVSS 6 (GitHub) | |
| Monitoreo | Detectada | Ingresó al índice | |
| Monitoreo | Verificada | Última verificación contra las fuentes |
Summary
On installations running with `CMS_PERMISSION = True`, a non-superuser delegate whose
only elevated right is `can_change_permissions` can use the *Page global permissions*
admin to grant themselves — or any other account — page rights they do not hold,
including `can_publish`, `can_delete`, `can_change_advanced_settings` and
`can_move_page`, site-wide.
This breaks the invariant documented in `docs/explanation/permissions.rst`, that
delegated administrators "cannot hand out rights they do not have."
Details
django CMS restricts per-page permission grants: `PagePermissionInlineAdmin.get_formset()`
excludes each `can_*` flag the acting user does not themselves hold.
`GlobalPagePermissionAdmin`, which manages the site-wide equivalent, had no such
restriction. It defined only `has_add_permission` / `has_change_permission` /
`has_delete_permission`, which gate *access to the changelist* but not *which flags may
be set*. `GlobalPagePermissionAdminForm` exposed all eight `can_*` flags through a bare
`Meta.fields` list, with no `__init__`, no `clean()` and no queryset limiting.
`BasePermissionAdminForm.__init__` forces to `False` only the permission fields absent
from `base_fields`. That is an effective defence for the inline, where `get_formset()`
actually removes fields — but on the global form every flag is present, so the loop was a
no-op and nothing was constrained.
Reaching the admin requires `permissions._has_global_permission(user, site, 'change')`,
which needs only:
- the Django model permission `cms.change_globalpagepermission`, and
- with `CMS_PERMISSION = True`, an existing `GlobalPagePermission` for the user carrying
Superuser is not required. This is precisely the "delegated permission manager" role
the permission system is designed to support, which is what makes the escalation
meaningful rather than theoretical.
Affected code (paths as of 5.1.2):
- `cms/admin/forms.py` — `GlobalPagePermissionAdminForm.Meta.fields`, all flags exposed
- `cms/admin/forms.py` — `BasePermissionAdminForm.__init__`, only nullifies absent fields
- `cms/admin/permissionadmin.py` — `GlobalPagePermissionAdmin`, no restricting hook
- `cms/utils/permissions.py` — `_has_global_permission`, the access gate
Proof of concept
Setup: `CMS_PERMISSION = True`. Delegate is non-superuser staff holding the Django model
permissions `cms.add_globalpagepermission` and `cms.change_globalpagepermission`, plus the
usual page model permissions a content manager carries (`cms.change_page`,
`cms.publish_page`, `cms.change_page_advanced_settings`, `cms.move_page`,
`cms.delete_page`). Their single `GlobalPagePermission` row has `can_change = True` and
`can_change_permissions = True`, every other flag `False`.
Baseline: `user_can_publish_page()` and `user_can_change_page_advanced_settings()` return
`False` for the delegate on any page.
POST /admin/cms/globalpagepermission/add/
user=<self>&sites=<site>&can_add=on&can_change=on&can_delete=on&can_publish=on
&can_change_advanced_settings=on&can_change_permissions=on&can_move_page=on&can_view=onResult: HTTP 302, and a new `GlobalPagePermission` is stored for the delegate with
`can_delete = can_publish = can_change_advanced_settings = can_move_page = True`.
`user_can_publish_page()`, `user_can_change_page_advanced_settings()` and
`user_can_move_page()` then all return `True`.
> Note on the two permission layers. The page-permission checks are wrapped in
> `@auth_permission_required(...)`, so they also require the corresponding Django *model*
> permissions. With only the two `globalpagepermission` model perms, the escalated row is
> still written but the effective checks stay `False`. The transition to `True` requires
> the delegate to also hold the page model permissions — which any staff content manager
> normally does. The stored-privilege escalation happens either way.
Impact
A partially-trusted delegate escalates to full page-management rights across the site —
publish, delete, advanced settings, move — none of which they were granted, and can
confer the same on any other account. Combined with `can_change_permissions` this is a
self-service privilege escalation inside the delegated-permission model.
Because `GlobalPagePermission` rows carry no audit fields, an escalated grant is
indistinguishable from a legitimate one on inspection alone. See *Detection* below.
Patches
<!-- FILL IN before publishing: patched versions per supported branch. -->
The fix restricts grantable flags in three layers:
- `cms/utils/permissions.py` — `get_grantable_global_permissions(user, site_ids=None)`
- `GlobalPagePermissionAdmin.get_exclude()` drops every `can_*` flag the acting user
- `GlobalPagePermissionAdminForm.clean()` enforces the invariant server-side on save,
Editing an existing row does not silently revoke flags the manager may not grant: a flag
you may not grant is one you may not remove.
Workarounds
For installations that cannot upgrade immediately, the precise minimal mitigation is to
**revoke the Django model permissions `cms.add_globalpagepermission` and
`cms.change_globalpagepermission` from every non-superuser account and group**:
from django.contrib.auth.models import Group, Permission
from django.contrib.auth import get_user_model
perms = Permission.objects.filter(
content_type__app_label="cms",
codename__in=["add_globalpagepermission", "change_globalpagepermission"],
)
for user in get_user_model().objects.filter(is_superuser=False):
user.user_permissions.remove(*perms)
for group in Group.objects.all():
group.permissions.remove(*perms)Delegates retain per-page permission management through the page-permission inline, which
restricts flags correctly. Only site-wide grants become superuser-only.
Setting `CMS_PERMISSION = False` also closes the path, but disables the permission system
wholesale and is not a like-for-like substitute.
Detection
`GlobalPagePermission` has no `created_by` or timestamp fields, so review every row and
confirm each grant is intended:
from cms.models import GlobalPagePermission
for perm in GlobalPagePermission.objects.all():
flags = [f for f in perm.get_all_permissions() if getattr(perm, f)]
print(perm.pk, perm.audience, list(perm.sites.values_list("domain", flat=True)), flags)Django's admin log does record who created or changed each row, and is the stronger
signal — any entry here by a non-superuser is worth investigating:
from django.contrib.admin.models import LogEntry
from django.contrib.contenttypes.models import ContentType
from cms.models import GlobalPagePermission
ct = ContentType.objects.get_for_model(GlobalPagePermission)
for e in LogEntry.objects.filter(content_type=ct).select_related("user"):
print(e.action_time, e.user, e.get_action_flag_display(), e.object_repr, e.change_message)When reading the output, keep in mind that `can_add`, `can_change`, `can_delete`,
`can_publish` and `can_move_page` all default to `True` on the model, so rows created
programmatically (rather than through the admin) routinely carry more flags than the
calling code passed. A broad flag set is therefore not on its own evidence of abuse;
correlate with the admin log below.
Note that admin log entries are prunable and absence of evidence is not evidence of
absence.
Affected versions
Verified present and unchanged in 3.11, 4.1, 5.0.11, 5.1.2 and current `main`:
`GlobalPagePermissionAdminForm` is a bare `Meta.fields` list in every one, and
`GlobalPagePermissionAdmin` defines no restricting hook in any of them. Only installations
running `CMS_PERMISSION = True` are affected.
Credit
Reported by Fatih Şeker (`@fatihsugar`), who provided a complete, accurate analysis and a
working end-to-end proof of concept.
References
- CWE-269: https://cwe.mitre.org/data/definitions/269.html
- Related prior advisory in the same delegated-permission surface: GHSA-vwcw-r26r-22cc
Incluye detalles técnicos publicados por el investigador. Úselos solo para validar y corregir sus propios sistemas.
Desglose de métricas
Rangos afectados
Estado del parche por paquete
| Paquete / producto | Estado | Corregida en | Desde divulgación | Última versión |
|---|---|---|---|---|
pypidjango-cms |
Corregida | 5.1.3 | -1 d | 5.1.3 no afectada |
5.1.3Arsenal público
Sin exploits, módulos ni PoC públicos conocidos a la fecha de verificación.
https://github.com/django-cms/django-cms/security/advisories/GHSA-cx9c-3cc5-gg94Las referencias externas se muestran para copiar: cve.llama.ec no lo redirige a otros sitios.
