Skip to content
This repository was archived by the owner on Feb 26, 2026. It is now read-only.
This repository was archived by the owner on Feb 26, 2026. It is now read-only.

[LOW] Swagger UI is enabled in all environments including production #11

@aatmmr

Description

@aatmmr

Summary

Swagger/OpenAPI documentation UI is unconditionally enabled for all environments, including production. This exposes the full API surface, endpoint schemas, and parameter details to potential attackers.

Description

In src/Program.cs (lines 121–122):

app.UseSwagger();
app.UseSwaggerUI();

These calls are not wrapped in an environment check. In production:

  • Attackers can browse the full API schema at /swagger.
  • All endpoint parameters, types, and response shapes are visible.
  • This information aids in crafting targeted attacks against the API.
  • Internal or admin endpoints (like DELETE /api/v1/gods) are publicly documented.

Implementation

  1. Wrap Swagger registration in a development environment check:
    if (app.Environment.IsDevelopment())
    {
        app.UseSwagger();
        app.UseSwaggerUI();
    }
  2. If Swagger is needed in staging/QA environments, use a more targeted check:
    if (!app.Environment.IsProduction())
    {
        app.UseSwagger();
        app.UseSwaggerUI();
    }
  3. Alternatively, protect the Swagger endpoint with authentication in production.
  4. Verify the change by running the app with ASPNETCORE_ENVIRONMENT=Production and confirming /swagger returns 404.

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions