Skip to content

Commit 2e19c54

Browse files
authored
Merge pull request #234 from AikidoSec/fix-bypass-ssrf-case-insensitive-host
Add additional test cases for case-insensitive hostname detection in …
2 parents e0d71ce + ecc8bcd commit 2e19c54

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

lib/request-processor/helpers/tryParseURL.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,20 @@ package helpers
22

33
import (
44
"net/url"
5+
6+
"golang.org/x/net/idna"
57
)
68

79
func TryParseURL(input string) *url.URL {
810
parsedURL, err := url.ParseRequestURI(input)
911
if err != nil {
1012
return nil
1113
}
14+
15+
// Convert the host to Unicode if it's an IDN (https://www.rfc-editor.org/rfc/rfc3492)
16+
parsedHost, err := idna.ToUnicode(parsedURL.Host)
17+
if err == nil {
18+
parsedURL.Host = parsedHost
19+
}
1220
return parsedURL
1321
}

lib/request-processor/vulnerabilities/ssrf/findHostnameInUserInput_test.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,13 @@ func TestFindHostnameInUserInput(t *testing.T) {
1111
port uint32
1212
expected bool
1313
}{
14+
{"https://m%C3%BCnchen.de", "münchen.de", 0, true},
15+
{"https://münchen.de", "xn--mnchen-3ya.de", 0, true},
16+
{"https://xn--mnchen-3ya.de", "münchen.de", 0, true},
1417
{"hTTps://lOcalhosT:8081", "Localhost", 8081, true},
18+
{"MÜNCHEN.DE", "münchen.de", 0, true},
19+
{"HTTP://localhost", "loCalhost", 0, true},
20+
{"http://LOCALHOST", "loCalhOst", 0, true},
1521
{"", "", 0, false},
1622
{"", "example.com", 0, false},
1723
{"http://example.com", "", 0, false},

0 commit comments

Comments
 (0)