wagtail/wagtail
acrewdson 882f8f3cf8 Strip Unicode NULL chars when normalizing paths
After migrating a Wagtail-based site from MySQL to Postgres, we
noticed that malicious requests to the site that included percent-
encoded Unicode NULLs (`%00`) raised a `ValueError` exception that we
hadn't seen when using MySQL: `A string literal cannot contain NUL
(0x00) characters.` This appears to relate to `psycopg2`'s decision to
raise an exception in these situations, as discussed here:

    https://github.com/psycopg/psycopg2/issues/420

While newer versions of Django appear to provide some field validation
that addresses these characters, it doesn't look like Wagtail's
redirect middleware is making use of those validators, and so it seemed
reasonable to clean these characters in the context of 'normalizing'
the paths before looking for corresponding redirects -- especially
since a quick investigation on the internet suggests that U+0000 in
URLs can be used as a means of attack, and also since RFC 3986 says:

   Note, however, that the "%00" percent-encoding (NUL) may require
   special handling and should be rejected if the application is not
   expecting to receive raw data within a component.
2018-06-27 11:19:36 -04:00
..
admin Convert the page/collection privacy modal to use static onload handlers 2018-06-20 15:35:41 +01:00
api return none if page specific_class is not set in PageTypeField to_representation 2018-06-21 10:12:44 +01:00
bin
contrib Strip Unicode NULL chars when normalizing paths 2018-06-27 11:19:36 -04:00
core Fix queryset ordering and add a test to confirm ordering matches expectation in all setups 2018-06-18 16:18:10 +10:00
documents Convert the document chooser modal to use static onload handlers 2018-06-20 15:35:41 +01:00
embeds Convert the embed chooser modal to use static onload handlers 2018-06-20 15:35:41 +01:00
images Handle modal-workflow responses as JSON whenever no JS onload handler is supplied 2018-06-20 15:35:40 +01:00
project_template
search Convert the search query chooser to use static onload handlers 2018-06-20 15:35:40 +01:00
sites Fetch new translations from Transifex 2018-05-22 16:14:59 +01:00
snippets Convert the snippet chooser to use static onload handlers 2018-06-20 15:35:40 +01:00
tests Implemented facet() method on search results 2018-06-20 14:59:57 +02:00
users Move page chooser widget JS from _editor_js.html into widget media 2018-06-04 15:03:09 +01:00
utils Rotate deprecation warnings for 2.2 2018-05-18 11:43:28 +01:00
__init__.py