[ ezo labs // research ]

django-guardian’s get_objects_for_user returns every object when two models share a permission codename

django-guardian tests global permissions by the bare app_label.codename string. When two models in one app share a codename, a user holding only one model’s permission passes the other model’s check…

contentsSummary
  1. Summary
  2. The gap
  3. Reproduction
  4. Impact
  5. Affected versions
  6. Fix status
  7. The vendor’s record
  8. Timeline
  9. References
  10. Disclosure

abstract

Django keeps one Permission row per (content_type, codename), so two models in one app may both define can_publish. django-guardian’s get_objects_for_user resolves the requested codenames against the queried model’s content type but tests the user’s global permissions with user.has_perm("app.codename"), which cannot see the content type. A user holding only the other model’s global permission passes the test, the matching codename is removed, and with no codenames left the function returns the full queryset. We reproduced it on django-guardian 3.5.2, the current release, and on its PermissionListMixin. The sibling get_objects_for_group was fixed for this exact class in 3.5.2; the user-facing function was not. No advisory or CVE covers this collision.

Summary

A permission in Django is an app label and a codename. It does not name a model. django-guardian’s user-facing lookup treats that string as sufficient, while the group lookup it fixed in 3.5.2 does not.

The gap

get_objects_for_user tests a global permission with the bare app_label.codename string, so a permission row belonging to a different model in the same app satisfies it, the codename is dropped, and the function returns every object of the queried model.

  • guardian/shortcuts.py:691: The global-permission test is user.has_perm(ctype.app_label + "." + code), which cannot see the content type.
  • guardian/shortcuts.py:692-693: The matching codename is removed from the set once any codename matches.
  • guardian/shortcuts.py:700-701: With no codenames left, the function returns the full queryset.
  • guardian/shortcuts.py:887-889: The sibling get_objects_for_group (fixed in 3.5.2) filters content_type=ctype, codename__in=codenames, the model-aware form get_objects_for_user lacks.

Reproduction

A two-model app (Project, Article, both declaring can_publish) in in-memory SQLite; alice holds only Article.can_publish; get_objects_for_user(alice, ["can_publish"], klass=Project), the PermissionListMixin, and get_objects_for_group(team, ["can_publish"], klass=Project) are called in one run.

alice -> ['p1','p2']; dave (same, via his group) -> ['p1','p2']; carol (Project.can_publish, control) -> ['p1','p2']; bob (nothing) -> []; get_objects_for_group(team, ['can_publish'], klass=Project) -> []; PermissionListMixin for alice -> ['p1','p2'].

Impact

A user who holds a global permission belonging to a different model in the same app is granted every object of the queried model: list views, admin screens and bulk actions built on get_objects_for_user or PermissionListMixin show and operate on rows the user holds no permission on, so the user reads and can act on records outside their authorization boundary.

Affected versions

All releases through django-guardian 3.5.2 (still the latest release, uploaded 2026-10-20) that carry the model-blind global test; the same branch is present throughout the 3.x and 2.x lines. No patched version exists.

Fix status

No release carries the fix. The change is to scope the global-permission test to the queried content type, as get_objects_for_group does since 3.5.2 (commit 99867b8), instead of testing user.has_perm("<app_label>.<codename>").

The vendor’s record

The maintainer accepted the report and a draft advisory exists (GHSA-3m3v-3wmf-wr4c, submission.accepted: true); the draft is unpublished and no CVE is assigned. No vendor comment disputes the defect.

Timeline

  • 2026-11-09T08:07:43Z: Private report filed (GHSA-3m3v-3wmf-wr4c)
  • 2026-11-09T10:00:59Z: Draft accepted (inferred from updated_at)
  • 2026-11-12T01:04:33Z: Comment 369868 posted in the advisory thread with an empty body
  • 2026-11-12T15:30:56Z: Class-anchored publish ask added to comment 369868 by edit
  • 2026-11-18: The draft remained unpublished; no further notice was sent
  • 2026-11-23T10:00:59Z: Deadline passed with the draft unpublished
  • 2026-11-24T06:36:19Z: This write-up published
  • 2026-11-24: MITRE CNA-LR request submitted

References

Disclosure

This note is an independent write-up. It is published on 2026-11-24 as the public reference for a CVE request. The private advisory and this write-up describe the same defect; the vendor advisory named above is the authority where one exists.

revisionsfirst published , last updated
revisions to this post
datechange
First publication.

cite this

EZO Labs Security. django-guardian’s get_objects_for_user returns every object when two models share a permission codename. EZO Labs Inc, research report EZO-R-2026-25, 24 November 2026. https://ezolabs.net/research/django-guardian-codename-collision

@techreport{djangoguardiancodenamecollision,
  title       = {django-guardian's get\_objects\_for\_user returns every object when two models share a permission codename},
  author      = {{EZO Labs Security}},
  institution = {EZO Labs Inc},
  type        = {Research report},
  number      = {EZO-R-2026-25},
  year        = {2026},
  month       = nov,
  url         = {https://ezolabs.net/research/django-guardian-codename-collision}
}

licensed under CC BY 4.0.

authors

next

  1. The Relay Trap

    Trying to keep pace with your AI agents is a loop you cannot win. The fix is not reviewing faster; it is changing what reaches you.

all research