ESLint InterlaceESLint Interlace
Plugin: lambda-securityRules

no-exposed-debug-endpoints

ESLint rule documentation for no-exposed-debug-endpoints

📡 Live from GitHub — This documentation is fetched directly from no-exposed-debug-endpoints.md and cached for 6 hours.

Keywords: debug endpoint, admin endpoint, authentication, CWE-489, Lambda, serverless CWE: CWE-489
OWASP: A05:2021-Security Misconfiguration

Detect debug endpoints without authentication in Lambda handlers

Detects debug and admin endpoints in Lambda handlers that may be exposed without authentication. This rule is part of eslint-plugin-lambda-security and provides LLM-optimized error messages.

🚨 Security rule | ⚠️ Set to error in recommended

Quick Summary

AspectDetails
CWE ReferenceCWE-489 (Active Debug)
SeverityHigh (security vulnerability)
Auto-Fix❌ No auto-fix (requires auth implementation)
CategorySecurity
Best ForLambda functions with HTTP triggers

Vulnerability and Risk

Vulnerability: Debug endpoints like /debug, /admin, /__debug__, /health may expose sensitive internal information or administrative functionality if left accessible in production without authentication.

Risk: Exposed debug endpoints can:

  • Reveal application internals and configuration
  • Provide admin functionality to attackers
  • Expose health check details useful for reconnaissance
  • Allow state manipulation in development modes

Rule Details

This rule detects:

  • Path literals like /debug, /admin, /_admin, /__debug__, /test
  • Route comparisons: event.path === '/debug'
  • Serverless Framework path configurations

Why This Matters

RiskImpactSolution
🔓 Admin AccessAttackers gain administrative functionsAdd authentication
🔍 Information LeakInternal state/config exposedRemove from production
🛠️ Debug ToolsDevelopment tools in productionEnvironment-based disabling

Configuration

OptionTypeDefaultDescription
endpointsstring[]['/debug', '/__debug__', '/admin', ...]Debug paths to flag
ignoreFilesstring[][]Files/patterns to ignore
{
  rules: {
    'lambda-security/no-exposed-debug-endpoints': ['error', {
      endpoints: ['/debug', '/__debug__', '/admin', '/_admin', '/test', '/health'],
      ignoreFiles: ['health-check.ts']  // Allow specific health check handlers
    }]
  }
}

Examples

❌ Incorrect

// Direct debug endpoint check
export const handler = async (event) => {
  if (event.path === '/debug') {
    // ❌ Debug endpoint without auth
    return {
      statusCode: 200,
      body: JSON.stringify({
        env: process.env,
        memory: process.memoryUsage(),
      }),
    };
  }
};

// Serverless Framework config
export const serverless = {
  functions: {
    admin: {
      handler: 'handler.admin',
      events: [
        {
          http: {
            path: '/admin', // ❌ Admin endpoint
            method: 'get',
          },
        },
      ],
    },
  },
};

✅ Correct

import { verifyJwt } from './auth';

export const handler = async (event) => {
  // Authenticate all admin requests
  if (event.path === '/admin') {
    const authResult = await verifyJwt(event.headers.authorization); // ✅ Auth check
    if (!authResult.valid) {
      return { statusCode: 401, body: 'Unauthorized' };
    }

    return handleAdminRequest(event);
  }
};

// Environment-based debug endpoints
export const handler = async (event) => {
  if (event.path === '/debug') {
    if (process.env.NODE_ENV === 'production') {
      // ✅ Disabled in prod
      return { statusCode: 404, body: 'Not Found' };
    }

    return getDebugInfo();
  }
};

// Health check with limited information
export const healthHandler = async () => {
  return {
    statusCode: 200,
    body: JSON.stringify({
      status: 'healthy',
      version: process.env.APP_VERSION, // ✅ Only safe info
      // NOT: env, memory, internal state
    }),
  };
};

Default Flagged Endpoints

EndpointRisk LevelCommon Purpose
/debugHighDebug information
/__debug__HighInternal debug
/adminCriticalAdministrative functions
/_adminCriticalHidden admin
/testMediumTest endpoints
/healthLowHealth checks (may reveal info)

Security Impact

VulnerabilityCWEOWASPCVSSImpact
Active Debug Code489A05:20217.5 HighInformation disclosure
Missing Auth306A07:20219.8 CriticalUnauthorized access

Ignore Patterns for Legitimate Use

// Disable for specific health check handler
/* eslint-disable lambda-security/no-exposed-debug-endpoints */

// Or use rule configuration
{
  rules: {
    'lambda-security/no-exposed-debug-endpoints': ['error', {
      ignoreFiles: ['health.ts', 'readiness.ts']
    }]
  }
}

Further Reading

On this page

No Headings