Skip to content

Commit b27f38a

Browse files
committed
Disable covert redirects and CSRF token leaking
This disallows the url() function from returning any remote URLs. This prevents covert redirects, and also prevents us from leaking CSRF tokens to outside parties. Signed-off-by: Patrick Uiterwijk <[email protected]>
1 parent 6cf9094 commit b27f38a

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

fedora/tg/utils.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,11 @@ def url(tgpath, tgparams=None, **kwargs):
8181
'''
8282
if not isinstance(tgpath, six.string_types):
8383
tgpath = '/'.join(list(tgpath))
84+
if not tgpath.startswith('/'):
85+
# Do not allow the url() function to be used for external urls.
86+
# This function is primarily used in redirect() calls, so this prevents
87+
# covert redirects and thus CSRF leaking.
88+
tgpath = '/'
8489
if tgpath.startswith('/'):
8590
webpath = (config.get('server.webpath') or '').rstrip('/')
8691
if tg_util.request_available():

0 commit comments

Comments
 (0)