Skip to content

Commit 6c2e700

Browse files
committed
Escape username to protect against xml injection vulnerability
1 parent a3ba722 commit 6c2e700

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

msal/wstrust_request.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ def send_request(
6060
return parse_response(resp.text)
6161

6262

63-
def escape_password(password):
64-
return (password.replace('&', '&').replace('"', '"')
63+
def escape_xml(s):
64+
return (s.replace('&', '&').replace('"', '"')
6565
.replace("'", ''') # the only one not provided by cgi.escape(s, True)
6666
.replace('<', '&lt;').replace('>', '&gt;'))
6767

@@ -116,7 +116,7 @@ def _build_rst(username, password, cloud_audience_urn, endpoint_address, soap_ac
116116
endpoint_address=endpoint_address,
117117
time_now=wsu_time_format(now),
118118
time_expire=wsu_time_format(now + timedelta(minutes=10)),
119-
username=username, password=escape_password(password),
119+
username=escape_xml(username), password=escape_xml(password),
120120
wst=Mex.NS["wst"] if soap_action == Mex.ACTION_13 else Mex.NS["wst2005"],
121121
applies_to=cloud_audience_urn,
122122
key_type='http://docs.oasis-open.org/ws-sx/ws-trust/200512/Bearer'

0 commit comments

Comments
 (0)