This repository was archived by the owner on Dec 9, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +18
-3
lines changed
main/java/com/appirio/tech/core/service/identity/resource
test/java/com/appirio/tech/core/service/identity/resource Expand file tree Collapse file tree 2 files changed +18
-3
lines changed Original file line number Diff line number Diff line change @@ -1360,9 +1360,24 @@ 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 ("://" );
1366+ i = i < 0 ? 0 : i + 3 ;
1367+ String domainName = resetPasswordUrlPrefix .substring (i );
1368+ i = domainName .indexOf ("/" );
1369+ i = i < 0 ? domainName .length () : i ;
1370+ domainName = domainName .substring (0 , i );
1371+ i = domainName .lastIndexOf ("." );
1372+ i = domainName .lastIndexOf ("." , i - 1 );
1373+ domainName = domainName .substring (i + 1 );
1374+ if (!(domainName .equals ("topcoder.com" ) || domainName .equals ("topcoder-dev.com" ))) {
1375+ resetPasswordUrlPrefix = null ;
1376+ }
1377+
13641378 return resetPasswordUrlPrefix ;
1365-
1379+ }
1380+
13661381 String source = request .getParameter ("source" );
13671382 String domain = getDomain ()!=null ? getDomain () : "topcoder.com" ;
13681383 String template = "https://%s.%s/reset-password" ;
Original file line number Diff line number Diff line change @@ -3678,7 +3678,7 @@ public void testGetResetPasswordUrlPrefix_SpecificDomain_Connect() {
36783678 public void testGetResetPasswordUrlPrefix_UrlSpecified () {
36793679 // mock
36803680 String source = "connect" ;
3681- String prefix = "DUMMY-PREFIX " ;
3681+ String prefix = "DUMMY-HOST.topcoder-dev.com " ;
36823682 HttpServletRequest request = mock (HttpServletRequest .class );
36833683 doReturn (source ).when (request ).getParameter ("source" );
36843684 doReturn (prefix ).when (request ).getParameter ("resetPasswordUrlPrefix" );
You can’t perform that action at this time.
0 commit comments