0
0
Fork 1
mirror of https://mau.dev/maunium/synapse.git synced 2024-11-17 23:42:33 +01:00

Ensure email validation link parameters are URL-encoded (#6063)

The validation links sent via email had their query parameters inserted without any URL-encoding. Surprisingly this didn't seem to cause any issues, but if a user were to put a `/` in their client_secret it could lead to problems.
This commit is contained in:
Andrew Morgan 2019-09-20 10:46:59 +01:00 committed by GitHub
parent 3ac614eb6c
commit aeb40f355c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 4 deletions

1
changelog.d/6063.bugfix Normal file
View file

@ -0,0 +1 @@
Ensure query parameters in email validation links are URL-encoded.

View file

@ -136,10 +136,11 @@ class Mailer(object):
group together multiple email sending attempts group together multiple email sending attempts
sid (str): The generated session ID sid (str): The generated session ID
""" """
params = {"token": token, "client_secret": client_secret, "sid": sid}
link = ( link = (
self.hs.config.public_baseurl self.hs.config.public_baseurl
+ "_matrix/client/unstable/password_reset/email/submit_token" + "_matrix/client/unstable/password_reset/email/submit_token?%s"
"?token=%s&client_secret=%s&sid=%s" % (token, client_secret, sid) % urllib.parse.urlencode(params)
) )
template_vars = {"link": link} template_vars = {"link": link}
@ -163,10 +164,11 @@ class Mailer(object):
group together multiple email sending attempts group together multiple email sending attempts
sid (str): The generated session ID sid (str): The generated session ID
""" """
params = {"token": token, "client_secret": client_secret, "sid": sid}
link = ( link = (
self.hs.config.public_baseurl self.hs.config.public_baseurl
+ "_matrix/client/unstable/registration/email/submit_token" + "_matrix/client/unstable/registration/email/submit_token?%s"
"?token=%s&client_secret=%s&sid=%s" % (token, client_secret, sid) % urllib.parse.urlencode(params)
) )
template_vars = {"link": link} template_vars = {"link": link}