Fix unescaped attributes in Stylesheet.__str__
This was originally reported by Mustafa Barakat as a potential security issue but no vulnerability was identified, hence tracking this publicly
The django.utils.feedgenerator.Stylesheet class (introduced in #12978) has a __str__ method which is used when outputting a <?xml-stylesheet ... ?>. The method uses f-strings with three different attributes: url, mimetype, and media.
However these attributes are not escaped, which could potentially lead to invalid markup if any of those attributes were to contain a quote for example.
Escaping using Django's escape (or even format_html) should work even though those functions are meant for HTML and not XML.
Change History
(9)
| Description: |
modified (diff)
|
| Severity: |
Normal → Release blocker
|
| Summary: |
Fix unescape attributes in Stylesheet.__str__ → Fix unescaped attributes in Stylesheet.__str__
|
| Triage Stage: |
Unreviewed → Accepted
|
| Owner: |
set to Varun Kasyap Pentamaraju
|
| Status: |
new → assigned
|
| Patch needs improvement: |
set
|
| Patch needs improvement: |
unset
|
| Triage Stage: |
Accepted → Ready for checkin
|
| Resolution: |
→ fixed
|
| Status: |
assigned → closed
|
Willing to contribute