Opened 2 months ago

Closed 3 weeks ago

#37160 closed Cleanup/optimization (fixed)

Make admin views consistently raise PermissionDenied (403) when lacking model permissions

Reported by: Jacob Walls Owned by: Natalia Bidart
Component: contrib.admin Version: dev
Severity: Normal Keywords: not-security, enumeration
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

The Security Team occasionally gets reports about PK enumeration in admin views. We close them, since:

  • admin users are trusted
  • if PK obscurity is important, then you should choose unguessable PKs

Usually the reports ask us to consider models for which a staff user lacks view permission.

We would evaluate a public cleanup that makes the various admin views consistent in how they treat nonexistent PKs for staff users lacking view permissions.

Two cases were recently called to our attention:

  • The "view_on_site" route (wrapping the contenttypes shortcut) redirects without checking permissions, giving either a 302 or 404, instead of a 403.
  • The "history_view" route calls self.get_object() and returns the "does not exist" redirect *before* checking has_view_or_change_permission(), giving a 302 for a missing PK and 403 for an existing one.

These are both in contrast to the autocomplete_view and changeform view, which are more careful to return 403 when users lack view permissions.

Change History (6)

comment:1 by Natalia Bidart, 2 months ago

Owner: set to Natalia Bidart
Status: newassigned
Triage Stage: UnreviewedAccepted

comment:2 by Natalia Bidart, 8 weeks ago

Has patch: set

comment:3 by blighj, 3 weeks ago

This is a great little improvement.

in reply to:  3 comment:4 by Natalia Bidart, 3 weeks ago

Replying to blighj:

This is a great little improvement.

Thank you James! when you have a moment, would you please mark the ticket as ready for checkin? (I can also do it later today if you haven't by then.)

comment:5 by Natalia Bidart, 3 weeks ago

Triage Stage: AcceptedReady for checkin

comment:6 by nessita <124304+nessita@…>, 3 weeks ago

Resolution: fixed
Status: assignedclosed

In 4ea38d54:

Fixed #37160 -- Made admin views raise PermissionDenied consistently.

The admin view_on_site and history views now return an HTTP 403 response
when a staff user lacks view or change permission for the target model,
consistent with the changeform and autocomplete views.

Thanks Bence Nagy for the report.

Note: See TracTickets for help on using tickets.
Back to Top