ベータ Shoulder はベータ版です — 結果が誤っている場合があります。皆さまのフィードバックが次に修正する内容を決定します。 フィードバックを送る
🐛

Active Debug Code

🛡️ 6 件のルールが検出します

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.

普及度
頻繁に悪用される
影響度
クリティカル
1 件の重大度クリティカルなルール
予防
文書化済み
6 件の修正例
2 予防
2 予防

この脆弱性の修正方法

6 件の Shoulder 検出ルールに基づく Active Debug Code の予防策。

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'));
+ }
  
3 検出
3 検出

コードの脆弱性を見つける

Shoulderを使用してコードのActive Debug Codeパターンをスキャンしましょう。 6 ルール.

ターミナル
# Scan with Shoulder CLI
npx @shoulderdev/cli trust --cwe=489

# Or scan entire project
npx @shoulderdev/cli trust .
4 警告サイン
4 警告サイン

コードレビューで注目すべき点

これらのパターンはActive Debug Codeの潜在的な脆弱性を示しています。コードレビューとセキュリティ監査中に探してください。

🟠
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
🔍

コードベースをスキャン: Active Debug Code

Shoulder CLI はコードベース全体から脆弱なパターンを見つけます。