mirror of
https://github.com/django/django.git
synced 2025-11-03 05:13:23 +00:00
Fixed CVE-2019-14234 -- Protected JSONField/HStoreField key and index lookups against SQL injection.
Thanks to Sage M. Abdullah for the report and initial patch. Thanks Florian Apolloner for reviews.
This commit is contained in:
parent
4b78420d25
commit
7deeabc7c7
7 changed files with 59 additions and 8 deletions
|
|
@ -1,8 +1,9 @@
|
|||
import json
|
||||
|
||||
from django.core import checks, exceptions, serializers
|
||||
from django.db import connection
|
||||
from django.forms import Form
|
||||
from django.test.utils import isolate_apps
|
||||
from django.test.utils import CaptureQueriesContext, isolate_apps
|
||||
|
||||
from . import PostgreSQLSimpleTestCase, PostgreSQLTestCase
|
||||
from .models import HStoreModel, PostgreSQLModel
|
||||
|
|
@ -185,6 +186,18 @@ class TestQuerying(PostgreSQLTestCase):
|
|||
self.objs[:2]
|
||||
)
|
||||
|
||||
def test_key_sql_injection(self):
|
||||
with CaptureQueriesContext(connection) as queries:
|
||||
self.assertFalse(
|
||||
HStoreModel.objects.filter(**{
|
||||
"field__test' = 'a') OR 1 = 1 OR ('d": 'x',
|
||||
}).exists()
|
||||
)
|
||||
self.assertIn(
|
||||
"""."field" -> 'test'' = ''a'') OR 1 = 1 OR (''d') = 'x' """,
|
||||
queries[0]['sql'],
|
||||
)
|
||||
|
||||
|
||||
@isolate_apps('postgres_tests')
|
||||
class TestChecks(PostgreSQLSimpleTestCase):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue