@@ -91,7 +91,7 @@ func TestGetIPAddress(t *tst.T) {
91
91
func TestGetReferrer (t * tst.T ) {
92
92
config := conf.GlobalConfiguration {
93
93
SiteURL : "https://example.com" ,
94
- URIAllowList : []string {"http://localhost:8000/*" , "http://*.localhost:8000/*" },
94
+ URIAllowList : []string {"http://localhost:8000/*" , "http://*.localhost:8000/*" , "http://*:12345/*" , "http://**:12345/*" },
95
95
JWT : conf.JWTConfiguration {
96
96
Secret : "testsecret" ,
97
97
},
@@ -128,10 +128,35 @@ func TestGetReferrer(t *tst.T) {
128
128
expected : "http://localhost:8000/path?param=1" ,
129
129
},
130
130
{
131
- desc : "invalid redirect url via query smurfing " ,
131
+ desc : "invalid redirect url due to decimal IP address " ,
132
132
redirectURL : "http://123?.localhost:8000/path" ,
133
133
expected : config .SiteURL ,
134
134
},
135
+ {
136
+ desc : "invalid redirect url due to IPv4 address" ,
137
+ redirectURL : "http://123.123.123.123?localhost:8000/path" ,
138
+ expected : config .SiteURL ,
139
+ },
140
+ {
141
+ desc : "invalid redirect url due to IPv6 address" ,
142
+ redirectURL : "http://[65e7:9410:d8b6:e227:58cd:e55b:8fc0:206d]?localhost:8000/path" ,
143
+ expected : config .SiteURL ,
144
+ },
145
+ {
146
+ desc : "invalid redirect url due to bad URL" ,
147
+ redirectURL : "http://65e7:9410:d8b6:e227:58cd:e55b:8fc0:206d?localhost:8000/path" ,
148
+ expected : config .SiteURL ,
149
+ },
150
+ {
151
+ desc : "valid loopback IPv4 address" ,
152
+ redirectURL : "http://127.0.0.1:12345/path" ,
153
+ expected : "http://127.0.0.1:12345/path" ,
154
+ },
155
+ {
156
+ desc : "valid loopback IPv6 address" ,
157
+ redirectURL : "http://[0:0:0:0:0:0:0:1]:12345/path" ,
158
+ expected : "http://[0:0:0:0:0:0:0:1]:12345/path" ,
159
+ },
135
160
}
136
161
137
162
for _ , c := range cases {
0 commit comments