Skip to content

security: /openapi.json enumerates admin + API-key-gated routes unauthenticated #2166

@andrew-bierman

Description

@andrew-bierman

Discovered during review of #2083.

Files:

  • packages/api/src/index.ts:27 (mount point)
  • packages/api/src/utils/openapi.ts (packratOpenApi setup)

@elysiajs/openapi is mounted before any auth plugins apply and has no exclude list. Every route in the app graph — including /api/admin/* and API-key-gated cron routes — is emitted to the public /openapi.json (and the Scalar UI). Unauthenticated enumeration exposes the admin surface and ETL/queue paths.

Fix options:

  1. Pass exclude: [/^\/api\/admin/] to @elysiajs/openapi (plus any API-key-only patterns)
  2. Add detail: { hide: true } on individual admin / API-key routes
  3. Gate /openapi.json and /scalar behind the admin basic-auth guard, or an env flag (OPENAPI_PUBLIC=false in prod)

Option 1 is the cleanest; option 3 is defense-in-depth.

Also verify: no API-key or secret value is baked into route description / summary strings (spot-check the schema after fixing).

Related: #2083 (new OpenAPI surface introduced with the Elysia migration)

Metadata

Metadata

Assignees

No one assigned

    Labels

    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