Development tools and frameworks usually have options to make debugging easier for developers. Although these features are useful during development, they should never be enabled for applications deployed in production. Debug instructions or error messages can leak detailed information about the system, like the application’s path or file names.
There is a risk if you answered yes to any of those questions.
Do not enable debugging features on production servers or applications distributed to end users.
Throwable.printStackTrace(...)
prints a Throwable and its stack trace to System.Err
(by default) which is not easily
parseable and can expose sensitive information:
try { /* ... */ } catch(Exception e) { e.printStackTrace(); // Sensitive }
EnableWebSecurity
annotation for SpringFramework with debug
to true
enables debugging support:
import org.springframework.context.annotation.Configuration; import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; @Configuration @EnableWebSecurity(debug = true) // Sensitive public class WebSecurityConfig extends WebSecurityConfigurerAdapter { // ... }
WebView.setWebContentsDebuggingEnabled(true) for Android enables debugging support:
import android.webkit.WebView; WebView.setWebContentsDebuggingEnabled(true); // Sensitive WebView.getFactory().getStatics().setWebContentsDebuggingEnabled(true); // Sensitive
Loggers should be used (instead of printStackTrace
) to print throwables:
try { /* ... */ } catch(Exception e) { LOGGER.log("context", e); }
EnableWebSecurity
annotation for SpringFramework with debug
to false
disables debugging support:
import org.springframework.context.annotation.Configuration; import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; @Configuration @EnableWebSecurity(debug = false) public class WebSecurityConfig extends WebSecurityConfigurerAdapter { // ... }
WebView.setWebContentsDebuggingEnabled(false) for Android disables debugging support:
import android.webkit.WebView; WebView.setWebContentsDebuggingEnabled(false); WebView.getFactory().getStatics().setWebContentsDebuggingEnabled(false);