File tree Expand file tree Collapse file tree 2 files changed +26
-0
lines changed
src/java/org/apache/hadoop/http Expand file tree Collapse file tree 2 files changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -1222,6 +1222,9 @@ Release 0.21.0 - Unreleased
12221222 HADOOP-6375. Sync documentation for FsShell du with its implementation.
12231223 (Todd Lipcon via cdouglas)
12241224
1225+ HADOOP-6441. Protect web ui from cross site scripting attacks (XSS) on
1226+ the host http header and using encoded utf-7. (omalley)
1227+
12251228Release 0.20.2 - Unreleased
12261229
12271230 NEW FEATURES
Original file line number Diff line number Diff line change @@ -624,6 +624,25 @@ public Map<String, String[]> getParameterMap() {
624624 }
625625 return result ;
626626 }
627+
628+ /**
629+ * Quote the url so that users specifying the HOST HTTP header
630+ * can't inject attacks.
631+ */
632+ @ Override
633+ public StringBuffer getRequestURL (){
634+ String url = rawRequest .getRequestURL ().toString ();
635+ return new StringBuffer (HtmlQuoting .quoteHtmlChars (url ));
636+ }
637+
638+ /**
639+ * Quote the server name so that users specifying the HOST HTTP header
640+ * can't inject attacks.
641+ */
642+ @ Override
643+ public String getServerName () {
644+ return HtmlQuoting .quoteHtmlChars (rawRequest .getServerName ());
645+ }
627646 }
628647
629648 @ Override
@@ -641,6 +660,10 @@ public void doFilter(ServletRequest request,
641660 ) throws IOException , ServletException {
642661 HttpServletRequestWrapper quoted =
643662 new RequestQuoter ((HttpServletRequest ) request );
663+ final HttpServletResponse httpResponse = (HttpServletResponse ) response ;
664+ // set the default to UTF-8 so that we don't need to worry about IE7
665+ // choosing to interpret the special characters as UTF-7
666+ httpResponse .setContentType ("text/html;charset=utf-8" );
644667 chain .doFilter (quoted , response );
645668 }
646669
You can’t perform that action at this time.
0 commit comments