BETA Shoulder jest w wersji beta — Wyniki mogą czasami być błędne. Twoja opinia kształtuje to, co naprawimy w następnej kolejności. Podziel się opinią
🐛

Active Debug Code

🛡️ 6 reguł wykrywa to

Active Debug Code

The product is deployed to unauthorized actors with debugging code still enabled or active, which can create unintended entry points or information leaks.

Debug code is often written to allow easier testing and debugging. This code is not intended to be shipped to production but is sometimes inadvertently left in the product. Debug code often exposes information about the product's internal structure or creates additional attack surface.

Rozpowszechnienie
Wysoka
Często wykorzystywana
Wplyw
Krytyczny
1 reguł o krytycznym poziomie
Zapobieganie
Udokumentowane
6 przykładów poprawek
2 Zapobieganie
2 Zapobieganie

Jak naprawić tę podatność

Strategie zapobiegania dla Active Debug Code oparte na 6 regułach detekcji Shoulder.

Django Debug Mode in Production CRITICAL

Load DEBUG from environment variables, defaulting to False in production

+4 -2 python
  # settings.py
- DEBUG = True
- ALLOWED_HOSTS = ['*']
+ import os
+ 
+ DEBUG = os.getenv('DJANGO_DEBUG', 'False').lower() == 'true'
+ ALLOWED_HOSTS = os.getenv('ALLOWED_HOSTS', '').split(',')
  
Flask Debug Mode in Production HIGH

Load Flask debug mode from environment variables, defaulting to False

+8 -6 python
- from flask import Flask
- 
- app = Flask(__name__)
- 
- if __name__ == '__main__':
-     app.run(debug=True)
+ import os
+ from flask import Flask
+ 
+ app = Flask(__name__)
+ 
+ if __name__ == '__main__':
+     debug = os.getenv('FLASK_DEBUG', 'False').lower() == 'true'
+     app.run(debug=debug)
  
Echo Debug Mode in Production MEDIUM

Disable Echo debug mode in production to prevent stack trace exposure

+8 -5 go
  package main
  
- import "github.com/labstack/echo/v4"
- 
- func main() {
-     e := echo.New()
-     e.Debug = true
+ import (
+     "os"
+     "github.com/labstack/echo/v4"
+ )
+ 
+ func main() {
+     e := echo.New()
+     e.Debug = os.Getenv("ECHO_DEBUG") == "true"
      e.GET("/api/users", getUsers)
      e.Start(":8080")
  }
  
Fiber Debug Mode in Production MEDIUM

Disable Fiber debug output and route printing in production

+3 -2 go
  package main
  
  import "github.com/gofiber/fiber/v2"
  
  func main() {
      app := fiber.New(fiber.Config{
-         EnablePrintRoutes: true,
-         EnableStackTrace:  true,
+         DisableStartupMessage: true,
+         EnablePrintRoutes:     false,
+         Prefork:               true,
      })
      app.Get("/api/users", getUsers)
      app.Listen(":8080")
  }
  
Gin Debug Mode in Production MEDIUM

Set Gin to release mode in production to suppress debug output

+9 -4 go
  package main
  
- import "github.com/gin-gonic/gin"
- 
- func main() {
-     gin.SetMode(gin.DebugMode)
+ import (
+     "os"
+     "github.com/gin-gonic/gin"
+ )
+ 
+ func main() {
+     if os.Getenv("GIN_MODE") == "" {
+         gin.SetMode(gin.ReleaseMode)
+     }
      r := gin.Default()
      r.GET("/api/users", getUsers)
      r.Run(":8080")
  }
  
Debug Mode Enabled in Production MEDIUM

Use environment variables for debug configuration instead of hardcoded flags

+6 -2 javascript
- const DEBUG = true;
- app.use(morgan('dev'));
+ const DEBUG = process.env.DEBUG === 'true';
+ const isProduction = process.env.NODE_ENV === 'production';
+ 
+ if (!isProduction) {
+   app.use(morgan('dev'));
+ }
  
4 Sygnaly Ostrzegawcze
4 Sygnaly Ostrzegawcze

Na co zwracac uwage podczas przegladu kodu

Te wzorce wskazuja na potencjalne podatnosci Active Debug Code. Szukaj ich podczas przegladow kodu i audytow bezpieczenstwa.

🟠
Flask applications running with debug mode enabled flask-debug-mode-production
🟡
Debug flag at line ... is hardcoded to true javascript-debug-mode-production
🟡
hardcoded debug flags that expose sensitive information or enable debugging features in production javascript-debug-mode-production
🔴
Django applications with DEBUG = True in settings django-debug-mode-production
🔍

Przeskanuj swój kod w poszukiwaniu Active Debug Code

Shoulder CLI znajduje podatne wzorce w całym Twoim kodzie.