@@ -734,6 +734,8 @@ if not errors:
734734 request.session[' samlUserdata' ] = auth.get_attributes()
735735 if ' RelayState' in req[' post_data' ] and
736736 OneLogin_Saml2_Utils.get_self_url(req) != req[' post_data' ][' RelayState' ]:
737+ # To avoid 'Open Redirect' attacks, before execute the redirection confirm
738+ # the value of the req['post_data']['RelayState'] is a trusted URL.
737739 auth.redirect_to(req[' post_data' ][' RelayState' ])
738740 else :
739741 for attr_name in request.session[' samlUserdata' ].keys():
@@ -796,6 +798,8 @@ url = auth.process_slo(delete_session_cb=delete_session_callback)
796798errors = auth.get_errors()
797799if len (errors) == 0 :
798800 if url is not None :
801+ # To avoid 'Open Redirect' attacks, before execute the redirection confirm
802+ # the value of the url is a trusted URL.
799803 return redirect(url)
800804 else :
801805 print " Sucessfully Logged out"
@@ -932,7 +936,9 @@ elif 'acs' in request.args: # Assertion Consumer Service
932936 request.session[' samlSessionIndex' ] = auth.get_session_index()
933937 self_url = OneLogin_Saml2_Utils.get_self_url(req)
934938 if ' RelayState' in request.form and self_url != request.form[' RelayState' ]:
935- return redirect(auth.redirect_to(request.form[' RelayState' ])) # Redirect if there is a relayState
939+ # To avoid 'Open Redirect' attacks, before execute the redirection confirm
940+ # the value of the request.form['RelayState'] is a trusted URL.
941+ return redirect(request.form[' RelayState' ]) # Redirect if there is a relayState
936942 else : # If there is user data we save that to print it later.
937943 msg = ' '
938944 for attr_name in request.session[' samlUserdata' ].keys():
@@ -943,6 +949,8 @@ elif 'sls' in request.args: # Single
943949 errors = auth.get_errors() # Retrieves possible validation errors
944950 if len (errors) == 0 :
945951 if url is not None :
952+ # To avoid 'Open Redirect' attacks, before execute the redirection confirm
953+ # the value of the url is a trusted URL.
946954 return redirect(url)
947955 else :
948956 msg = " Sucessfully logged out"
0 commit comments