GHSA-M7HP-FFPV-6JHV
Per-user page permission cache is not scoped to a site, disclosing other sites' page trees
Texto original en inglés · Ver en español
CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:L/I:N/A:N
Fuente: GitHub
Ciclo de vida de la vulnerabilidad
| Fecha | Fase | Evento | Detalle |
|---|---|---|---|
| Divulgación | Publicada | GHSA-M7HP-FFPV-6JHV divulgada · CVSS 4.3 (GitHub) | |
| Monitoreo | Detectada | Ingresó al índice | |
| Monitoreo | Verificada | Última verificación contra las fuentes |
Summary
With `CMS_PERMISSION=True` on a multi-site installation, the per-user page-permission cache key does not include the site, while the values it caches are computed per site. After a user's permissions have been cached for a site they legitimately work on, the same cached value is served for every other site. The "may change at least one page" gate on the page tree, the page changelist and the page-link autocomplete then passes for sites the user has no rights on, and those endpoints list the pages of that site — titles, slugs, URLs and tree structure — to a user who cannot otherwise see them.
Details
`cms.cache.permissions.get_cache_key` built its key from the cache prefix, the user id and the action name only:
def get_cache_key(user, key):
return "%s:permission:%d:%s" % (get_cms_setting('CACHE_PREFIX'), user.pk or 0, key)The value stored under that key comes from `cms.utils.permissions.get_page_actions_for_user(user, site)`, which filters `PagePermission` rows by `page__site=site`. `cms.utils.page_permissions._get_page_permission_tuples_for_action` reads and writes the cache through the site-less key, so the per-site result of one site is returned for another.
`user_can_change_at_least_one_page` returns `perm_tuples == GRANT_ALL_PERMISSIONS or bool(perm_tuples)` — a non-empty list is enough. A list warmed from site A is non-empty, so the gate passes for site B even though none of its entries can match a site-B page.
The affected entry points take their site from the request, including a client-supplied `?site=` parameter via `cms.utils.admin.get_site_from_request`:
- `PageContentAdmin.get_tree`, `get_tree_rows` and `changelist_view`, gated by `PageContentAdmin.has_change_permission(request, obj=None)`;
- `PageAdmin.get_list` (the page-link autocomplete), gated by `PageAdmin.has_view_permission`, which delegates to `PageAdmin.has_change_permission(request, obj=None)`.
Both gates call `user_can_change_at_least_one_page` with the cache enabled. `PageContentAdmin.has_view_permission` already passed `use_cache=False` and was not affected.
Two properties bound the impact:
- No write escalation. The cached values are `(grant_on, path)` tuples, and `has_generic_permission` matches a page's `path` against them. `path` is the tree's materialized path, which is allocated globally across sites, so no tuple warmed from site A can ever match a site-B page. Per-page permission checks continue to refuse correctly, and an attempt to change a foreign site's page is still rejected.
- The poisoning is one-directional. Warming from a site where the user holds no page permissions caches nothing at all, because `get_page_actions_for_user` returns an empty mapping and the store loop never executes. There is consequently no inverse variant in which a user loses access to a site they do hold rights on.
Users holding a `GlobalPagePermission` are unaffected in both directions: `has_global_permission` short-circuits before the cache is consulted, and `get_global_actions_for_user` is memoized per `(user, site)`.
`PageContentAdmin.user_can_access_site` and `raise_site_permission_denied` exist in the admin but are not called from anywhere. They would not have helped: `user_can_access_site` resolves through `get_sites_for_user`, which calls `user_can_change_at_least_one_page` and would have read the same poisoned value.
Impact and prerequisites
The attack requires:
- `CMS_PERMISSION=True` and more than one configured `Site`;
- an authenticated staff user who holds page permissions on at least one site, so that the cache can be warmed;
- a cache backend retaining the entry for `CMS_CACHE_DURATIONS['permissions']`.
Confidentiality only, and limited to page-tree metadata of other sites — page titles, slugs, URLs and structure. Plugin content is not rendered by these endpoints, no page is modified, and the issue is not reachable anonymously.
Note that within a single site the page tree and the page-link autocomplete list every page to any staff user who may edit at least one page. That is documented, intended behaviour; view restrictions do not conceal page titles and URLs from staff editors. This advisory concerns the crossing of the *site* boundary only.
Reproduction summary
- Configure two sites, A and B, with `CMS_PERMISSION=True`.
- Give a staff editor the `change_page` model permission and a `can_change` `PagePermission` on one page of site A, and no permissions at all on site B. Put a distinctly titled page on site B.
- As that editor, request `/admin/cms/pagecontent/get-tree/?site=<B>` on a cold cache. The response is 403.
- Request the page tree of site A, which is legitimate and warms the cache.
- Request `/admin/cms/pagecontent/get-tree/?site=<B>` again. On vulnerable code the response is 200 and contains the site-B page.
Fix behavior
The site is now part of the cache key, and the helpers in `cms.cache.permissions` take it as their second argument:
def get_cache_key(user, site, key):
return "%s:permission:%d:%d:%s" % (get_cms_setting('CACHE_PREFIX'), user.pk or 0, site.pk, key)`get_permission_cache(user, site, key)` and `set_permission_cache(user, site, key, value)` follow, and `cms.utils.page_permissions._get_page_permission_tuples_for_action` passes the site it was called with on both the read and the write. `clear_user_permission_cache(user)` keeps its signature and now clears the user's entries for every site in one `delete_many`. `PageContentAdmin.response_add`, which busts the `change_page` key directly, passes the site of the page it just created.
This is an internal API, but a project or package that warms or inspects the permission cache itself must be updated: the previous two-argument calls now raise `TypeError`.
The unused `PageContentAdmin.user_can_access_site` and `raise_site_permission_denied` are deprecated and will be removed in django CMS 6.0. Fixing the cache key was preferred over the reporter's alternative suggestions: passing `use_cache=False` at the gate would have corrected only the call sites someone thought to check and would cost a query per request, and wiring up `user_can_access_site` would have added nothing, since it reads the same cached value.
Workarounds
Single-site installations, and installations running with `CMS_PERMISSION=False`, are not affected. Otherwise, until a patched release is available, reduce `CMS_CACHE_DURATIONS['permissions']` to shorten the window, or grant a `GlobalPagePermission` scoped to the appropriate sites instead of per-page permissions, since global permissions bypass this cache.
Validation and scope
Reproduced on `5.2.0dev1` using the project test harness without djangocms-versioning: cold-cache 403 for site B, 200 with the site-B page disclosed after warming site A, and the absence of write escalation confirmed with a deliberate same-slug page on both sites. Covered by regression tests in `cms/tests/test_permissions.py`. The site-less key was inspected in local tags 5.1.2, 5.0.11 and 4.1.0; those releases were not independently runtime-tested in this review.
Reported by @fatihsugar, whose root-cause analysis and impact assessment, including the absence of write escalation, matched the maintainers' findings.
Desglose de métricas
Rangos afectados
Estado del parche por paquete
| Paquete / producto | Estado | Corregida en | Desde divulgación | Última versión |
|---|---|---|---|---|
pypidjango-cms |
Sin parche | — | — | 5.1.3 afectada |
5.2.0Arsenal 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-m7hp-ffpv-6jhvLas referencias externas se muestran para copiar: cve.llama.ec no lo redirige a otros sitios.
