diff options
| author | Jacob Walls <jacobtylerwalls@gmail.com> | 2026-03-16 18:05:22 -0400 |
|---|---|---|
| committer | Jacob Walls <jacobtylerwalls@gmail.com> | 2026-04-07 07:42:18 -0400 |
| commit | abfe1a1c57a57cfaf6dd4a0571c029401a0fe743 (patch) | |
| tree | 684c02a58479b5364ecf919250b61dc328818b09 /tests/admin_views/tests.py | |
| parent | 051f3909e820360bbe84a21350e82f4961e3d917 (diff) | |
[4.2.x] Fixed CVE-2026-4292 -- Disallowed instance creation via ModelAdmin.list_editable.
Thanks Natalia Bidart, Jake Howard, and Markus Holtermann for reviews.
Backport of 6afe7ce93964f56e33a29d477c269436f9b60cbf from main.
Diffstat (limited to 'tests/admin_views/tests.py')
| -rw-r--r-- | tests/admin_views/tests.py | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/tests/admin_views/tests.py b/tests/admin_views/tests.py index f40415681a..ddc7254958 100644 --- a/tests/admin_views/tests.py +++ b/tests/admin_views/tests.py @@ -2,6 +2,7 @@ import datetime import os import re import unittest +from http import HTTPStatus from unittest import mock from urllib.parse import parse_qsl, urljoin, urlparse @@ -4100,6 +4101,22 @@ class AdminViewListEditable(TestCase): self.assertIs(Person.objects.get(name="John Mauchly").alive, False) + def test_forged_post_submission_when_no_add_permission(self): + before_count = ParentWithUUIDPK.objects.count() + data = { + "form-TOTAL_FORMS": "1", + "form-INITIAL_FORMS": "0", + "form-MAX_NUM_FORMS": "0", + "form-0-title": "The News", + "form-0-id": "", + "_save": "Save", + } + # This model admin allows no add permissions. + changelist_url = reverse("admin:admin_views_parentwithuuidpk_changelist") + response = self.client.post(changelist_url, data) + self.assertEqual(response.status_code, HTTPStatus.BAD_REQUEST) + self.assertEqual(ParentWithUUIDPK.objects.count(), before_count) + def test_non_field_errors(self): """ Non-field errors are displayed for each of the forms in the |
