diff options
| author | Carl Meyer <carl@oddbird.net> | 2013-02-04 16:57:59 -0700 |
|---|---|---|
| committer | Aymeric Augustin <aymeric.augustin@m4x.org> | 2013-02-12 12:13:42 +0100 |
| commit | d3a45e10c8ac8268899999129daa27652ec0da35 (patch) | |
| tree | c987017d361480a4850e2a525629e52974c3c6b8 /django | |
| parent | d19a27066b2247102e65412aa66917aff0091112 (diff) | |
[1.3.x] Checked object permissions on admin history view.
This is a security fix. Disclosure and advisory coming shortly.
Patch by Russell Keith-Magee.
Diffstat (limited to 'django')
| -rw-r--r-- | django/contrib/admin/options.py | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/django/contrib/admin/options.py b/django/contrib/admin/options.py index 3d06050c54..c30394edb6 100644 --- a/django/contrib/admin/options.py +++ b/django/contrib/admin/options.py @@ -1242,15 +1242,21 @@ class ModelAdmin(BaseModelAdmin): def history_view(self, request, object_id, extra_context=None): "The 'history' admin view for this model." from django.contrib.admin.models import LogEntry + # First check if the user can see this history. model = self.model + obj = get_object_or_404(model, pk=unquote(object_id)) + + if not self.has_change_permission(request, obj): + raise PermissionDenied + + # Then get the history for this object. opts = model._meta app_label = opts.app_label action_list = LogEntry.objects.filter( object_id = object_id, content_type__id__exact = ContentType.objects.get_for_model(model).id ).select_related().order_by('action_time') - # If no history was found, see whether this object even exists. - obj = get_object_or_404(model, pk=unquote(object_id)) + context = { 'title': _('Change history: %s') % force_unicode(obj), 'action_list': action_list, |
