-
-
Notifications
You must be signed in to change notification settings - Fork 6.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix XSS caused by disabled autoescaping in the default DRF Browsable API view templates #6330
Fix XSS caused by disabled autoescaping in the default DRF Browsable API view templates #6330
Conversation
Thanks for adding the test case @zyv. |
Hi @zyv. I need to dig in to this more fully, but I'm not 100% that the test demonstrates the correct behavior. Basically, this test ensures that I think what we need instead are tests for the browsable API templates. By default, the browsable API should escape links once. And from there, we would then need to fix the templates and how/when it autoescapes. Again, I'm not 100% on what the correct answer here is - I'd need to look at the base template and |
Hi @rpkilby, you are right that my test doesn't demonstrate the correct expected behaviour of Anyways, I've now finally managed to find some time to look into it, and have fixed the test, as well as (hopefully) found a solution to the problem. I would appreciate if you could have a look at my new commits. A more detailed explanation of what/why they do follows: I believe that the initial author of I have changed the function to correctly mark final string as safe and also got rid of the crazy escaping logic, so that hopefully it is now clearer what the function does (and what it does not). |
👌 nice. I'll take a look at this over the weekend. I really appreciate the effort you put into this. |
Thanks for the work @zyv! I will be preparing 3.9.1 next week. A fix here will be part of that. Your efforts are greatly appreciated. |
Looks correct to me, yup. |
Details in encode/django-rest-framework#6330 Change-Id: Icea25569b92c3559029ae1c93712e746684187f1
This resolves a XSS vulnerability (encode/django-rest-framework#6330).
…API view templates (encode#6330) * Add test that verifies that HTML is correctly escaped in Browsable API views * Fix `urlize_quoted_links` tag to avoid double escaping in autoescape mode * Fix XSS in default DRF Browsable API template by re-enabling autoescape
As requested in #6191.