Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Fix XSS caused by disabled autoescaping in the default DRF Browsable API view templates#6330

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
lovelydinosaur merged 3 commits intoencode:masterfrommoneymeets:moneymeets/html-escaping
Jan 16, 2019
Merged

Fix XSS caused by disabled autoescaping in the default DRF Browsable API view templates#6330

lovelydinosaur merged 3 commits intoencode:masterfrommoneymeets:moneymeets/html-escaping
Jan 16, 2019

Conversation

@zyv
Copy link
Contributor

@zyvzyv commentedNov 21, 2018

As requested in#6191.

sloria reacted with thumbs up emoji
@xordoquyxordoquy added this to the3.9.1 Release milestoneNov 21, 2018
@xordoquyxordoquy added the Bug labelNov 21, 2018
@rpkilby
Copy link
Contributor

Thanks for adding the test case@zyv.

@rpkilby
Copy link
Contributor

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 thaturlize_quoted_links escapes by default, ignoring the autoescape context, which conflicts with the intent of#6191. However, I'm inclined to agree w/#6191 thaturlize_quoted_links should obey theautoescape tag/context, and I think that the issues lie with the base template instead (i.e., the base template may need more selective auto escaping).

I think what we need instead are tests for the browsable API templates. By default, the browsable APIshould 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 andurlize_quoted_links more thoroughly.

@zyv
Copy link
ContributorAuthor

zyv commentedDec 14, 2018

Hi@rpkilby, you are right that my test doesn't demonstrate the correct expected behaviour ofurlize_quoted_links, my goal was to prove the point that PR#6191 introduced an XSS into the default DRF Browsable API templates, and I was hoping that the commit will get reverted and a new release will ensue quickly to fix this vulnerability, if a proper solution cannot be found on short notice due to limited maintainer capacity.

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 ofurlize_quoted_links made a mistake by not marking the resulting string as safe and faced the double quoting problem if autoescaping was enabled. To work around this issue, autoescaping was disabled in the templates. The "fix" in PR#6191 tipped the delicate balance of two mistakes compensating each other by making the function conform to Django API, which lead to HTML not being escaped at all in the default DRF templates.

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).

@zyvzyv changed the titleAdd test that verifies that HTML is correctly escaped in Browsable API viewsFix XSS caused by disabled autoescaping in the default DRF Browsable API view templatesDec 14, 2018
@rpkilby
Copy link
Contributor

👌 nice.

I'll take a look at this over the weekend. I really appreciate the effort you put into this.

nevelis reacted with thumbs up emoji

@carltongibson
Copy link
Collaborator

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.

remychvn, jerdna-regeiz, and TauPan reacted with thumbs up emoji

@lovelydinosaur
Copy link
Contributor

Looks correct to me, yup.

@lovelydinosaurlovelydinosaur merged commit4bb9a3c intoencode:masterJan 16, 2019
openstack-gerrit pushed a commit to recordsansible/ara-server that referenced this pull requestJan 17, 2019
Details inencode/django-rest-framework#6330Change-Id: Icea25569b92c3559029ae1c93712e746684187f1
martey added a commit to pydata/conf_site that referenced this pull requestMay 25, 2019
pchiquet pushed a commit to pchiquet/django-rest-framework that referenced this pull requestNov 17, 2020
…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
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Labels

Projects

None yet

Milestone

3.9.1 Release

Development

Successfully merging this pull request may close these issues.

5 participants

@zyv@rpkilby@carltongibson@lovelydinosaur@xordoquy

[8]ページ先頭

©2009-2025 Movatter.jp