Skip to content

Commit

Permalink
Merge pull request #370 from IdentityPython/dev
Browse files Browse the repository at this point in the history
fix: [Security] XSS in the idp url parameter
  • Loading branch information
Giuseppe De Marco authored Apr 5, 2023
2 parents b835031 + df5c201 commit f1aa8e0
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
4 changes: 2 additions & 2 deletions djangosaml2/tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -308,8 +308,8 @@ def test_unknown_idp(self):
metadata_file="remote_metadata_three_idps.xml",
)

response = self.client.get(reverse("saml2_login") + "?idp=https://unknown.org")
self.assertEqual(response.status_code, 403)
response = self.client.get(reverse("saml2_login") + "?idp=<b>https://unknown.org</b>")
self.assertContains(response, "&lt;b&gt;https://unknown.org&lt;/b&gt;", status_code=403)

def test_login_authn_context(self):
sp_kwargs = {
Expand Down
5 changes: 3 additions & 2 deletions djangosaml2/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
from django.template import TemplateDoesNotExist
from django.urls import reverse
from django.utils.decorators import method_decorator
from django.utils.html import escape
from django.utils.module_loading import import_string
from django.utils.translation import gettext_lazy as _
from django.views.decorators.csrf import csrf_exempt
Expand Down Expand Up @@ -152,9 +153,9 @@ def get_next_path(self, request: HttpRequest) -> str:
return next_path

def unknown_idp(self, request, idp):
msg = f"Error: IdP EntityID {idp} was not found in metadata"
msg = f"Error: IdP EntityID {escape(idp)} was not found in metadata"
logger.error(msg)
return HttpResponse(msg.format("Please contact technical support."), status=403)
return HttpResponse(msg, status=403)

def load_sso_kwargs_scoping(self, sso_kwargs):
"""Performs IdP Scoping if scoping param is present."""
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def read(*rnames):

setup(
name="djangosaml2",
version="1.5.5",
version="1.5.6",
description="pysaml2 integration for Django",
long_description=read("README.md"),
long_description_content_type="text/markdown",
Expand Down

0 comments on commit f1aa8e0

Please sign in to comment.