Skip to content

fix: bound pending and unused service types #246

Closed

Description

@uniqueg

Why?

The pre-release review for 0.5.0 found that in moderated mode any logged-in user can add pending service types without limit, through POST /services/types or failed POST /services requests (the pending type is stored before the registration is validated). Every non-admin read (GET /services, GET /services/{id}, the verification reads, and admin GET /approvals) then builds a filter with one clause per pending type, used or not. Reads slow down as the count grows and fail with 500 above about 20,000 long types, because the query exceeds MongoDB's 16 MiB limit (reproduced on MongoDB 7.0 with 25,000 types). service_types.pending has no index.

In open mode (the default), the public, unpaginated GET /services/types grows the same way, and only admins can remove types, one at a time.

What?

  • Build the visibility filter only from pending types that stored services use, e.g. a derived, indexed pending flag on services that registration sets and approval clears with an idempotent update_many (no transactions needed), or a distinct over the services' types.
  • Index service_types.pending.
  • A configurable cap on the unused types a non-admin may have added (pending in moderated, approved in open); above it, 409 with a clear detail.
  • Don't store a pending type when the registration that would create it fails validation, where that's possible without transactions; otherwise document it.
  • Fix docs/configuration.md: 0.4.0 stores no types; existing types are approved by the startup backfill.
  • Document the remaining abuse vector next to the modes and recommend rate limits for POST /services/types.

Acceptance criteria

  • Read cost no longer grows with unused pending types; a test with many pending types stays well under the BSON limit.
  • The cap is enforced and tested in both modes; admins are exempt.

Activity

  1. added
    priority: high
    status: triage
    type: security
    workload: hours
    status: in progress
    and removed
    status: triage
    on Oct 25, 2026
  2. removed
    status: in progress
    on Oct 26, 2026
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

    priority: hightype: securityworkload: hours

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions