Skip to content

Commit 7679f4d

Browse files
GiteaBotlafriks
andauthored
Fix open redirect check for more cases (#25143) (#25154)
Backport #25143 by @lafriks If redirect_to parameter has set value starting with `\\example.com` redirect will be created with header `Location: /\\example.com` that will redirect to example.com domain. Co-authored-by: Lauris BH <lauris@nix.lv>
1 parent 82a8c26 commit 7679f4d

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

modules/context/context_response.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,9 @@ func (ctx *Context) RedirectToFirst(location ...string) {
4949
continue
5050
}
5151

52-
// Unfortunately browsers consider a redirect Location with preceding "//" and "/\" as meaning redirect to "http(s)://REST_OF_PATH"
52+
// Unfortunately browsers consider a redirect Location with preceding "//", "\\" and "/\" as meaning redirect to "http(s)://REST_OF_PATH"
5353
// Therefore we should ignore these redirect locations to prevent open redirects
54-
if len(loc) > 1 && loc[0] == '/' && (loc[1] == '/' || loc[1] == '\\') {
54+
if len(loc) > 1 && (loc[0] == '/' || loc[0] == '\\') && (loc[1] == '/' || loc[1] == '\\') {
5555
continue
5656
}
5757

0 commit comments

Comments
 (0)