Skip to content
This repository was archived by the owner on Dec 9, 2025. It is now read-only.

Commit b1360c0

Browse files
committed
Sanitize / ensure domains other than topcoder.com or topcoder-dev.com can't be used.
1 parent e3baa9a commit b1360c0

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

src/main/java/com/appirio/tech/core/service/identity/resource/UserResource.java

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1360,9 +1360,22 @@ protected boolean isValidStatusValue(String status) {
13601360

13611361
protected String getResetPasswordUrlPrefix(HttpServletRequest request) {
13621362
String resetPasswordUrlPrefix = request.getParameter("resetPasswordUrlPrefix");
1363-
if(resetPasswordUrlPrefix!=null)
1363+
if(resetPasswordUrlPrefix!=null) {
1364+
// Sanitize / ensure domains other than topcoder.com or topcoder-dev.com can't be used.
1365+
int i = resetPasswordUrlPrefix.indexOf("://") + 3;
1366+
String domainName = resetPasswordUrlPrefix.substring(i);
1367+
i = domainName.indexOf("/");
1368+
domainName = domainName.substring(0, i);
1369+
i = domainName.lastIndexOf(".");
1370+
i = domainName.lastIndexOf(".", i - 1);
1371+
domainName = domainName.substring(i + 1);
1372+
if (!(domainName.equals("topcoder.com") || domainName.equals("topcoder-dev.com"))) {
1373+
resetPasswordUrlPrefix = null;
1374+
}
1375+
13641376
return resetPasswordUrlPrefix;
1365-
1377+
}
1378+
13661379
String source = request.getParameter("source");
13671380
String domain = getDomain()!=null ? getDomain() : "topcoder.com";
13681381
String template = "https://%s.%s/reset-password";

0 commit comments

Comments
 (0)