The vulnerability is a stored Cross-site Scripting (XSS) issue within the wagtail.contrib.simple_translation module of Wagtail. The root cause is the improper handling of user-supplied input, specifically page and snippet titles, when generating confirmation messages in the admin interface.
The analysis of the provided patches reveals that the vulnerability was fixed by making two key changes:
- In
wagtail/contrib/simple_translation/views.py, the code was changed to use wagtail.admin.messages instead of django.contrib.messages. The wagtail.admin.messages framework is designed to handle HTML escaping by default, which is crucial for preventing XSS.
- In the global admin template
wagtail/admin/templates/wagtailadmin/base.html, the |safe filter was removed from the rendering of messages ({{ message|safe }} became {{ message }}). This ensures that even if a message contains HTML, it will be treated as plain text and escaped by the template engine, preventing it from being executed by the browser.
The vulnerable functions are the post methods of SubmitPageTranslationView and SubmitSnippetTranslationView. These methods are the entry points that are triggered when a user submits a translation. They are responsible for creating the success messages that contained the unescaped, user-controlled titles, leading to the XSS vulnerability. The new tests added in wagtail/contrib/simple_translation/tests/test_views.py explicitly demonstrate how a malicious title with an <img onerror...> payload would have been rendered, confirming that these views were the source of the vulnerability.