Delivering code in production with debug features activated is security-sensitive. It has led in the past to the following vulnerabilities:
An application’s debug features enable developers to find bugs more easily and thus facilitate also the work of attackers. It often gives access to detailed information on both the system running the application and users.
There is a risk if you answered yes to any of those questions.
Do not enable debug features on production servers.
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
enable 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 { // ... }
Loggers should be used (instead of printStackTrace
) to print throwables:
try { /* ... */ } catch(Exception e) { LOGGER.log("context", e); // Compliant }
EnableWebSecurity
annotation for SpringFramework with debug
to false
disable debugging support:
import org.springframework.context.annotation.Configuration; import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; @Configuration @EnableWebSecurity(debug = false) // Compliant public class WebSecurityConfig extends WebSecurityConfigurerAdapter { // ... }