Skip to content
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

OPENCMS-1019: XSS vulnerability testing flagged a parameter in clipboard admin #66

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,20 @@ def test_ajax_upload_clipboardadmin_same_name_as_existing_file_in_moderation(sel
error_msg = 'Cannot archive existing test1.jpg file version'
self.assertEqual(response.json()['error'], error_msg)

def test_ajax_upload_clipboardadmin_xss_vulnerability(self):
"""
If we add malicious data to an ajax upload request ensure it is stripped in response.
"""
file = self.create_file('test2.pdf')

with self.login_user_context(self.superuser):
response = self.client.post(
reverse('admin:filer-ajax_upload', kwargs={'folder_id': self.folder.id}),
data={'file': file, 'script': '<script>alert("Attack!")</script>'},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure that this test is doing anything, I don't think that this endpoint ever looks for "data". I don't think that the response would have the word alert in it anywhere too. The issue is that path is brought in un sanitised and then used later: https://github.com/divio/djangocms-versioning-filer/blob/master/djangocms_versioning_filer/monkeypatch/admin/clipboardadmin.py#L30

)

self.assertNotContains(response, '<script>alert("Attack")</script>')

def test_folderadmin_directory_listing(self):
folder = Folder.objects.create(name='test folder 9')
file_grouper_1 = FileGrouper.objects.create()
Expand Down