Skip to content
Snippets Groups Projects
Commit 19c5bdd7 authored by GitLab Release Tools Bot's avatar GitLab Release Tools Bot
Browse files

Merge branch 'security-open-redirect-internalredirect-12-2' into '12-2-stable'

Use the '\A' and '\z' regex anchors in `InternalRedirect` to mitigate an Open Redirect issue.

See merge request gitlab/gitlabhq!3476
parents 89183bfd 811b7247
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -6,7 +6,7 @@ module InternalRedirect
def safe_redirect_path(path)
return unless path
# Verify that the string starts with a `/` and a known route character.
return unless path =~ %r{^/[-\w].*$}
return unless path =~ %r{\A/[-\w].*\z}
 
uri = URI(path)
# Ignore anything path of the redirect except for the path, querystring and,
Loading
Loading
---
title: Fixes a Open Redirect issue in `InternalRedirect`.
merge_request:
author:
type: security
Loading
Loading
@@ -19,7 +19,8 @@ describe InternalRedirect do
[
'Hello world',
'//example.com/hello/world',
'https://example.com/hello/world'
'https://example.com/hello/world',
"not-starting-with-a-slash\n/starting/with/slash"
]
end
 
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment