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 all commits
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
30 changes: 30 additions & 0 deletions tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,36 @@ 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_path_param_only(self):
"""
If we add malicious data to the path post attribute with an additional file attribute
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'),
data={'path': '<script>alert("attack!")</script>', 'file': file}
)

self.assertNotContains(response, '<script>alert("attack!")</script>')
self.assertEqual(response.status_code, 200)

def test_ajax_upload_clipboardadmin_xss_vulnerability_pathand_file_param(self):
"""
If we add malicious data to the path post attribute of an ajax upload request ensure it is stripped in response.
"""
with self.login_user_context(self.superuser):
response = self.client.post(
reverse('admin:filer-ajax_upload'),
data={'path': '<script>alert("attack!")</script>'}
)

self.assertFalse('<script>alert("attack!")</script>' in response.request.values())
self.assertEqual(response.status_code, 500)


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