mirror of
https://github.com/django/django.git
synced 2025-10-24 06:06:09 +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:
committed by
Carlton Gibson
parent
4b78420d25
commit
7deeabc7c7
@@ -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):
|
||||
|
||||
Reference in New Issue
Block a user