diff options
author | Nick Pope <nick@nickpope.me.uk> | 2023-01-25 12:21:48 +0100 |
---|---|---|
committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2023-02-01 09:44:04 +0100 |
commit | 8c660fb59239828583f17cdede3b64f208b8752c (patch) | |
tree | 443edc779e626ff26d94fd9652c5c504db572136 /tests/i18n | |
parent | 110b3b83567da22f19ec04210db134d0fe83d662 (diff) | |
download | django-8c660fb59239828583f17cdede3b64f208b8752c.tar.gz |
Fixed CVE-2023-23969 -- Prevented DoS with pathological values for Accept-Language.
The parsed values of Accept-Language headers are cached in order to
avoid repetitive parsing. This leads to a potential denial-of-service
vector via excessive memory usage if the raw value of Accept-Language
headers is very large.
Accept-Language headers are now limited to a maximum length in order
to avoid this issue.
Diffstat (limited to 'tests/i18n')
-rw-r--r-- | tests/i18n/tests.py | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/tests/i18n/tests.py b/tests/i18n/tests.py index e4f00fca48..a0e88e3211 100644 --- a/tests/i18n/tests.py +++ b/tests/i18n/tests.py @@ -1501,6 +1501,14 @@ class MiscTests(SimpleTestCase): ("de;q=0.", [("de", 0.0)]), ("en; q=1,", [("en", 1.0)]), ("en; q=1.0, * ; q=0.5", [("en", 1.0), ("*", 0.5)]), + ( + "en" + "-x" * 20, + [("en-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x", 1.0)], + ), + ( + ", ".join(["en; q=1.0"] * 20), + [("en", 1.0)] * 20, + ), # Bad headers ("en-gb;q=1.0000", []), ("en;q=0.1234", []), @@ -1517,6 +1525,10 @@ class MiscTests(SimpleTestCase): ("", []), ("en;q=1e0", []), ("en-au;q=1.0", []), + # Invalid as language-range value too long. + ("xxxxxxxx" + "-xxxxxxxx" * 500, []), + # Header value too long, only parse up to limit. + (", ".join(["en; q=1.0"] * 500), [("en", 1.0)] * 45), ] for value, expected in tests: with self.subTest(value=value): |