Skip to content

[CRITICAL] Sensitive Data Exposure: Debug Mode Defaults to True with Full Traceback Leakage #2036

Description

@namann5

Vulnerability Summary

Severity: CRITICAL
Type: Sensitive Data Exposure / Information Disclosure
CVSS Score: ~8.5

Description

The application defaults to debug: bool = True in backend/secuscan/config.py, which causes:

  1. Full Python tracebacks to be returned as HTML to HTTP clients on any unhandled exception
  2. Hot reload mode enabled via uvicorn, exposing file-system side-channel risks
  3. API documentation always accessible at /docs and /openapi.json, providing attackers a complete endpoint map

Vulnerable Code

File: backend/secuscan/config.py:22

debug: bool = True  # defaults to True

File: backend/secuscan/main.py:277-284

@app.exception_handler(Exception)
async def custom_unhandled_exception_handler(request: Request, exc: Exception):
    logger.exception("Unhandled exception in request lifecycle")
    if settings.debug:
        import traceback
        html = f"<html><body><h1>500 Internal Server Error</h1><pre>{traceback.format_exc()}</pre></body></html>"
        response = HTMLResponse(html, status_code=500)
    else:
        response = PlainTextResponse("Internal Server Error", status_code=500)

File: backend/secuscan/main.py:355

uvicorn.run(
    "backend.secuscan.main:app",
    host=settings.bind_address,
    port=settings.bind_port,
    reload=settings.debug,  # hot reload when debug=True
    log_level=settings.log_level.lower()
)

File: .env.example:5

SECUSCAN_DEBUG=true  # encourages production use of debug mode

Impact

  1. Information Disclosure: Full tracebacks expose internal file paths, database schema, library versions, and environment variable names to attackers.
  2. Attack Surface Expansion: OpenAPI docs at /docs give attackers a complete map of every endpoint, parameter, and data model.
  3. Stability Risk: Uvicorn reload mode watches all source files, which can be abused for file-system side-channel timing attacks.
  4. Production Exposure: The .env.example encourages setting DEBUG=true, meaning most deployments will run in debug mode.

Suggested Fix

  1. Change default to False:
debug: bool = False  # must be explicitly enabled
  1. Conditionally disable docs in production:
app = FastAPI(
    ...,
    docs_url="/docs" if settings.debug else None,
    redoc_url="/redoc" if settings.debug else None,
    openapi_url="/openapi.json" if settings.debug else None,
)
  1. Update .env.example:
SECUSCAN_DEBUG=false

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions