Skip to content

Commit

Permalink
Sanitize input used in error template (#5498)
Browse files Browse the repository at this point in the history
As error template is html, and the input used in it is taken from the path, which can be anything, the input needs to be sanitized before added to the template to avoid possible XSS injection.
  • Loading branch information
TatuLund authored and caalador committed Apr 18, 2019
1 parent 9f56157 commit 71e14f2
Showing 1 changed file with 4 additions and 0 deletions.
Expand Up @@ -23,7 +23,9 @@
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.io.IOUtils;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Element;
import org.jsoup.safety.Whitelist;
import org.slf4j.LoggerFactory;

import com.vaadin.flow.component.Component;
Expand All @@ -47,6 +49,8 @@ public int setErrorParameter(BeforeEnterEvent event,
if (parameter.hasCustomMessage()) {
additionalInfo = "Reason: " + parameter.getCustomMessage();
}
path = Jsoup.clean(path, Whitelist.none());
additionalInfo = Jsoup.clean(additionalInfo, Whitelist.none());

boolean productionMode = event.getUI().getSession().getConfiguration()
.isProductionMode();
Expand Down

0 comments on commit 71e14f2

Please sign in to comment.