Skip to content

Commit cf9684d

Browse files
authored
HBASE-27812 Provide option in HBase UI to disable stack trace for security (#5205)
Signed-off-by: Duo Zhang <zhangduo@apache.org>
1 parent 71d7996 commit cf9684d

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

hbase-http/src/main/java/org/apache/hadoop/hbase/http/HttpServer.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@
8181
import org.apache.hbase.thirdparty.org.eclipse.jetty.server.ServerConnector;
8282
import org.apache.hbase.thirdparty.org.eclipse.jetty.server.SslConnectionFactory;
8383
import org.apache.hbase.thirdparty.org.eclipse.jetty.server.handler.ContextHandlerCollection;
84+
import org.apache.hbase.thirdparty.org.eclipse.jetty.server.handler.ErrorHandler;
8485
import org.apache.hbase.thirdparty.org.eclipse.jetty.server.handler.HandlerCollection;
8586
import org.apache.hbase.thirdparty.org.eclipse.jetty.server.handler.RequestLogHandler;
8687
import org.apache.hbase.thirdparty.org.eclipse.jetty.server.handler.gzip.GzipHandler;
@@ -153,6 +154,7 @@ public class HttpServer implements FilterContainer {
153154
public static final String SPNEGO_PROXYUSER_FILTER = "SpnegoProxyUserFilter";
154155
public static final String NO_CACHE_FILTER = "NoCacheFilter";
155156
public static final String APP_DIR = "webapps";
157+
public static final String HTTP_UI_SHOW_STACKTRACE_KEY = "hbase.ui.show-stack-traces";
156158

157159
public static final String METRIC_SERVLETS_CONF_KEY = "hbase.http.metrics.servlets";
158160
public static final String[] METRICS_SERVLETS_DEFAULT = { "jmx", "metrics", "prometheus" };
@@ -652,6 +654,14 @@ private void initializeWebServer(String name, String hostName, Configuration con
652654
addFilterPathMapping(path, webAppContext);
653655
}
654656
}
657+
// Check if disable stack trace property is configured
658+
if (!conf.getBoolean(HTTP_UI_SHOW_STACKTRACE_KEY, true)) {
659+
// Disable stack traces for server errors in UI
660+
webServer.setErrorHandler(new ErrorHandler());
661+
webServer.getErrorHandler().setShowStacks(false);
662+
// Disable stack traces for web app errors in UI
663+
webAppContext.getErrorHandler().setShowStacks(false);
664+
}
655665
}
656666

657667
private void addManagedListener(ServerConnector connector) {

src/main/asciidoc/_chapters/security.adoc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,15 @@ Users who wish to change this would set the following in their hbase-site.xml:
261261
</property>
262262
----
263263

264+
To disable showing stack traces in HBase UI for hiding sensitive information, set the following in hbase-site:
265+
[source,xml]
266+
----
267+
<property>
268+
<name>hbase.ui.show-stack-traces</name>
269+
<value>false</value>
270+
</property>
271+
----
272+
264273
[[hbase.secure.configuration]]
265274
== Secure Client Access to Apache HBase
266275

0 commit comments

Comments
 (0)