Development tools and frameworks usually have options to make debugging easier for developers, but these features should never be enabled for applications deployed in production.
Debug instructions or error messages can leak detailed information about the system, such as the application’s path, file names, or stack traces. The rule flags configurations and API calls that enable debug features, including stack trace printing, verbose logging, debug mode flags, and remote debugging endpoints.
Attackers can exploit debug output to learn internal application details, file paths, stack traces, and configuration data that can be leveraged to craft further attacks.
Debug features may expose remote debugging endpoints, profiling APIs, or detailed error pages that significantly increase the attack surface of the application.
Debug features should be disabled or guarded by environment checks before deploying to production.
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(); // Noncompliant
}
Loggers should be used (instead of printStackTrace) to print throwables:
try {
/* ... */
} catch(Exception e) {
LOGGER.log("context", e);
}
Debug features should be disabled or guarded by environment checks before deploying to production.
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) // Noncompliant
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
// ...
}
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 {
// ...
}
Debug features should be disabled or guarded by environment checks before deploying to production.
WebView.setWebContentsDebuggingEnabled(true) for Android enables debugging support:
import android.webkit.WebView; WebView.setWebContentsDebuggingEnabled(true); // Noncompliant WebView.getFactory().getStatics().setWebContentsDebuggingEnabled(true); // Noncompliant
WebView.setWebContentsDebuggingEnabled(false) for Android disables debugging support:
import android.webkit.WebView; WebView.setWebContentsDebuggingEnabled(false); WebView.getFactory().getStatics().setWebContentsDebuggingEnabled(false);