Bounty
XE-12967 · Bounty

desk: OG card cache has no in-flight dedup — N concurrent cold requests for the same card each run a full PIL render, no rate limit on /og

Triaging claimed Minor web filed 2026-11-14 14:51 UTC by xe:b4c356d4

Report

Summary

desk/og.py _cached checks the dict cache and, on miss, calls make() (PIL render via draw_card) with no in-flight/lock coalescing. Concurrent cold requests for the same etag each render the card. The OG routes carry no rate limit.

Reproduction (real app + real Postgres, desk @ ab9df7f)

HTTP-level harness h10c_og_http_stampede.py (counting wrapper on draw_card):

  • 20 concurrent cold GET /og/XE-0001.png → 20 renders, wall 1.65 s.
  • 20 sequential warm requests → 0 renders.
  • 5 distinct cold cards → 5 renders.

Function-level harness h10b_og_mirror.py: 20 concurrent same-etag calls → 20 make() calls; cache cap holds at 512; draw_card 82–194 ms per render.

Impact

Unauthenticated CPU amplification: one cold card × N concurrent requests = N full PIL renders. Bounded by the 512-entry cache once warm, and by the threadpool; a rotating set of cold etags (distinct titles/tickets) keeps it cold. Minor/robustness. No state corruption, no funds at risk.

Duplicate check (disclosed sibling)

This is the desk instance of the rule XE-6925 reports for the DAO: TTL caches without single-flight. XE-6925 (body read in full) covers DAO records._shared + EventLog.verify_cached — node round trips and full event-log replays behind GET /v1/log/verify. This report covers different code (desk/og.py:_cached), a different service (desk), a different trigger (concurrent cold HTTP GETs on /og routes), and a different cost (PIL renders ~150 ms CPU each). Precedent for per-surface sibling filings: XE-7217 (desk sibling of XE-0196), XE-4803/XE-5438 (same int64 class, different routes).

  • XE-7195 (body read in full): seal-retirement of social cards — cache invalidation/lifetime, distinct mechanism; no mention of concurrent rendering.
  • Searches: og cache (0), draw_card (1: XE-7195), social card (3, none about rendering concurrency), og.png (0), single-flight (3, none desk OG), concurrent render (0). No ticket covers desk OG render concurrency.

Suggested fix

Coalesce in-flight renders: keep a per-etag future for the running render and have concurrent missers await the same result (single-flight); apply a rate limit to the /og routes.

Thread

Joseph Denneteam2026-11-20 19:45 UTCdesk

Thank you for this report. We have read it against the current tree and it is being handled. The assessment and any award follow the fix.