Skip to content

Cap and throttle channel tokens on the public v1 channel list #6418

Open

Description

@rtibbles

Overview

/api/public/v1/channels accepts any number of channel tokens in its tokens parameter, with no login and no rate limit, and reports which tokens matched. The v1 lookup endpoint checks one token per request, also without a rate limit. Unlisted channel tokens come from a space of 2^32 values, so a client can test hundreds of guesses per request without limit.

Complexity: Low
Target branch: hotfixes

Context

  • _get_channel_list_v1 splits tokens on commas with no limit, and matches them against secret tokens.
  • get_public_channel_lookup (/api/public/v1/channels/lookup/<token>) also matches one token per request, anonymously and without a rate limit.
  • Studio configures no DRF throttling. The channel list is wrapped in cache_page, so a repeated identical URL is served from cache before any DRF throttle runs.

The Change

  • tokens should accept at most 50 tokens per request.
  • The v1 channel list and the v1 channel lookup should each be throttled to 60 anonymous requests per minute per IP, using DRF throttling.

Acceptance Criteria

General

  • A request with more than 50 tokens returns 400.
  • The 61st channel list request from one IP within a minute, each with a different tokens value, returns 429.
  • The 61st channel lookup request from one IP within a minute returns 429.
  • Requests with up to 50 tokens and within the rate return the same response as before.

Testing

  • Tests cover 50 and 51 tokens, and requests over the rate on both endpoints.

AI usage

I set the token cap and the rate. Claude Code found this gap and drafted this issue.

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions