Skip to content

playback: re-stream detection (C16 fan-out) — the fingerprints are not consumable as-is #522

Closed as not planned

Description

@CoffeeKnyte

Split out of #305. PR #306 delivered every other batch of the stream-abuse work; this is the one piece it deliberately did not build, because scoping it against the real code showed the premise it was planned on was wrong.

Why this isn't "just add a consumer"

The architecture plan and both coverage matrices said the raw material already flowed through streammonitor and only needed a rule to consume it. That is false, and PR #306 corrects it in the docs (commit 2bbe6021, abuse-matrix correction #9).

ClientIP is one value per session, not a set:

  • Integrated mode stamps it when the playback session is created and no media request ever updates it — internal/api/handlers/stream.go contains no ClientIP reference at all. Five devices pulling the same integrated session all present as the address of whoever started it.
  • The edge tracker overwrites records[sessionID] on every Track/EnsureEphemeral (internal/nodesessions/tracker.go), so concurrent pours leave only the last writer's address.
  • mergeStreams then collapses multi-node records to a single winner and only backfills an address when the winner has none (internal/streammonitor/monitor.go).

So no consumer of the existing snapshot can detect fan-out, and a polling loop additionally misses short-lived pulls. Observations have to be collected at authenticated media-serve time, which puts this on the hot path of every media request — the same territory that made the #15 projection queue worth deferring rather than rushing (a naive fire-and-forget projection is what caused the ghost-session defect fixed in that batch).

What this signal can and cannot catch

  • Can: shared credential / shared session-URL fan-out — one session id pulled by many viewer devices directly from Silo (matrix story C16's fan-out mode).
  • Cannot: C14, the classic proxy re-broadcast, where one client pulls a single stream and a downstream proxy fans it out. Silo sees exactly one address and one session; no IP-based signal can distinguish that from ordinary viewing. C14 must stay scored ❌/❌ — please don't let a future PR quietly claim otherwise.

Settled product decisions (already made, don't re-litigate)

  • Signal: distinct viewer IPs per session.
  • Retention: Redis with a ~24h TTL when Redis is configured; in-memory when it isn't.
  • Privacy: detection on by default, alert-only. Chosen over operator opt-in and over hashing/truncating IPs, because operator investigability was the point. Consequence to disclose in operator docs: per-viewer IP history is retained on every deployment.
  • Enforcement: alert first, plus an operator-configurable auto-kill defaulting to off.

Design constraints found during planning

These came out of an adversarial review of the draft plan; each is a real hazard, not a style note.

  • Observe at authenticated media-serve time, not by polling the snapshot. Prefer observing only after verified delivery — edge transcode records are created before the upstream response succeeds, so token scanners and failed manifest fetches would otherwise contribute viewer addresses.
  • Do not delete state when a session leaves a snapshot. MultiSource swallows per-source errors and can return a partial snapshot (internal/streammonitor/monitor.go), so a Redis blip on one replica would wipe every remote session's shared history. Let expiry own retention.
  • The store needs an atomic threshold-crossing transition. SADD + SCARD plus process-local dedupe means every replica alerts and auto-kills. streamenforcer's Redis lease coordinator (added in feat(playback): stream abuse control — authoritative monitoring + kill switch #306) is the shape to reuse.
  • Bound the Redis store, not just the in-memory one — a Lua op that conditionally adds below a cardinality cap, sets retention, and reports the crossing. Define behaviour for keys that already exceed a newly lowered cap.
  • Trust boundary. Default trusted proxies include all RFC1918 (internal/config/admin_settings.go), so a client on a private network can forge X-Forwarded-For. With auto-kill enabled that is a spoofable kill primitive. One consistent trust model for API and proxy modes, with tests for trusted ingress, untrusted XFF, and direct private-network clients. (The edge's own RemoteAddr problem is split out separately — see below.)
  • Alert state and enforcement state are separate transitions. RevokeSessionForIfAbsent returns (created, error): marking dedupe before a failed revoke permanently suppresses auto-kill; marking it after repeats the alert.
  • Normalize addresses carefully. IPv6 → /64 (privacy extensions rotate the low 64 bits, so counting full addresses manufactures false positives for one well-behaved phone), and Unmap IPv4-mapped IPv6 first or ::ffff:192.0.2.1 gets truncated as IPv6 and collapses unrelated IPv4 viewers.
  • Retention mismatch to disclose: alerts carrying addresses land in opslog, whose default retention is 7 days — longer than the detector's 24h store TTL.
  • Admin UI is a product call. Following playback.over_cap_revocation_ttl's backend-only precedent means the settings are absent from PlaybackSettings.tsx's KEYS and ordinary operators can't change them from the shipped UI. Decide that deliberately.

Known false-positive sources

A 24h distinct-address total measures historical network changes, not concurrent viewers: VPN exit rotation, wifi↔cellular transitions, CGNAT reassignment, and IPv6 prefix delegation changes all raise the count for a single legitimate device. Alerts should say "suspected shared session URL", not assert re-streaming.

Testing note

This repository currently runs no go test job in CI (.github/workflows/ has only build, labeler and bot jobs). Any Redis-gated tests will skip everywhere until a Redis service is added, which would make the most important concurrency/atomicity coverage vacuous. Worth fixing alongside this.

Part of #305

Activity

  1. added
    triaged
    and removed
    triaged
    on Sep 20, 2026
  2. CoffeeKnyte commented on Oct 28, 2026

    @CoffeeKnyte
    ContributorAuthor

    Closing as not planned. A shared session URL reaches only one title, so this is a rare edge case:

    • The native stream token is tied to one playback session, and the server serves only that session's file (internal/api/handlers/stream.go:701) for at most 24 hours.
    • A jellycompat PlaySessionId authenticates only the item and source it was negotiated for (internal/jellycompat/auth.go:351).

    Fan-out is therefore limited to several devices watching one title through one leaked link until the token expires. Sharing the account itself, where each device starts its own sessions, falls under the concurrency caps in #305.

    If this comes back, the signal already exists: since #667, internal/streamtelemetry records up to 32 viewer IPs per session at serve time (session.go:112) and merges them across publishers. The design constraints above still apply to any detector built on it.

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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions