Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

XSS in select dropdowns #171

Closed
samupl opened this issue Feb 1, 2017 · 4 comments
Closed

XSS in select dropdowns #171

samupl opened this issue Feb 1, 2017 · 4 comments

Comments

@samupl
Copy link
Contributor

samupl commented Feb 1, 2017

During our testing, @KubaGorski found a XSS vulnerability in the select dropdown rendering.

The bug is found in chainedfk.js#L41 and chainedm2m.js#L54.

You can trigger the XSS while having a model with __str__ method that returns arbitrary javascript code, and can be dangerous if have chained models with __str__ methods using fields that are filled in by users, for example:

class Comment(models.Model):
    text = models.CharField(max_length=128)
    
    def __str__(self):
        return self.text

And if the text field contains something like Lorem ipsum <script>alert(123)</script>, the javascript code will be executed in the django admin interface, which can lead to data leak, credential stealing or attacks on particular browser vulnerabilities of the site admin.

@samupl
Copy link
Contributor Author

samupl commented Feb 1, 2017

I have created a pull request that fixes this bug: #172

@blag
Copy link
Collaborator

blag commented Feb 1, 2017

I will upload a new release to PyPI containing this fix, and remove previous (insecure) versions from PyPI.

Thanks for your help!

@samupl
Copy link
Contributor Author

samupl commented Feb 1, 2017

You're welcome ;)

@blag
Copy link
Collaborator

blag commented Feb 1, 2017

Your changes are in version 1.2.9 and are now on PyPI.

People reading this in the future

I dug through the history - this has been a security flaw since the first initial commit, so I removed all versions below 1.2.9 from PyPI. I know this will break people's builds, and I'm sorry. Please upgrade to version 1.2.9 or higher (whatever the latest version is). If you truly need to use any previous versions, you can specify the commit to use. See this Stack Overflow post for examples, but I am making this difficult for a reason: you should not do this.

@blag blag closed this as completed Feb 1, 2017
@nealscut nealscut mentioned this issue Apr 9, 2017
6 tasks
# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

No branches or pull requests

2 participants