Skip to content

Commit eb7432d

Browse files
committed
LDKController: HTML-encode container-scope messages and redirect URL
The container-scoped-tables inspection view joined validation messages with StringUtils.join and rendered them via HtmlString.of, and the invalid-redirect error wrapped the user-supplied URL with HtmlString.unsafe. Both reflected unescaped user-controlled content into the page (reflected XSS). Each validation message is now passed through PageFlowUtil.filter before joining (the assembled string is then marked HtmlString.unsafe since its pieces are already encoded), and the redirect error now uses HtmlString.of so the URL is escaped.
1 parent 5a5bd07 commit eb7432d

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

LDK/src/org/labkey/ldk/LDKController.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@
9292
import java.util.Map;
9393
import java.util.Set;
9494
import java.util.function.Predicate;
95+
import java.util.stream.Collectors;
9596

9697
public class LDKController extends SpringActionController
9798
{
@@ -439,9 +440,9 @@ public ModelAndView getView(Object form, BindException errors) throws Exception
439440
List<String> messages = service.validateContainerScopedTables(false);
440441

441442
String sb = "This page is designed to inspect all registered container scoped tables and report any tables with duplicate keys in the same container. This should be enforced by the user schema; however, direct DB inserts will bypass this check.<p>" +
442-
StringUtils.join(messages, "<br>");
443+
messages.stream().map(PageFlowUtil::filter).collect(Collectors.joining("<br>"));
443444

444-
return new HtmlView(HtmlString.of(sb));
445+
return new HtmlView(HtmlString.unsafe(sb));
445446
}
446447

447448
@Override
@@ -912,7 +913,7 @@ public ModelAndView getView(Object form, BindException errors) throws Exception
912913
}
913914
catch (URISyntaxException e)
914915
{
915-
return new HtmlView(HtmlString.unsafe("Invalid redirect URL set: " + urlString));
916+
return new HtmlView(HtmlString.of("Invalid redirect URL set: " + urlString));
916917
}
917918
}
918919
}

0 commit comments

Comments
 (0)