Status: Accepted (2026-11-28). Amends 0702 (nameRegex). Doc side agreed with DC2 (FindBudget, checkNameRegex in packages/doc).
Security finding SR-01 (HIGH): one nameRegex search could block a shared doc worker for tens of seconds. checkRegex only test-compiled the pattern with the linear engine’s l flag. find() then ran it on the backtracking engine, and V8’s “fallback on excessive backtracks” restarts each name only after it has already backtracked a lot. Measured on Node 26.4 (M4 Pro), ^(a+)+$ over 600K distinct 200-char names:
Pages are routed by rendezvous hash, so a worker is shared across tenants, and one user could stall search, outline, render and MCP reads for everyone. Linear time is necessary but not sufficient: about 20 µs per 256-char name still adds up to seconds on a big page.
nameRegex only with l and tests only the first 256 UTF-16 units of each name (packages/doc). The worker’s checkRegex delegates to packages/doc’s checkNameRegex, so the validator and the executor cannot drift. Rejected patterns (backreferences, lookahead, inline flags, large counts) get 400 fields.nameRegex. The flag is set at startup with v8.setFlagsFromString (NODE_OPTIONS does not allow it).{ timeMs: LINORA_DOCWORKER_FIND_BUDGET_MS } (default 100) to find(). When the budget runs out, the answer has truncated: true and a nextCursor that resumes the scan where it stopped. total is then a lower bound. Clients page as usual; every call makes progress.vm Script with timeout = LINORA_DOCWORKER_QUERY_TIMEOUT_MS (default 2000). This covers summary, outline, nodes/get, nodes/search and render’s region + toSvg. V8 terminates the running JS (loops and regex execution included), and the worker answers 503 + Retry-After: 5 and counts linora_docworker_query_timeouts_total{route}.
changes (async, journal reads) checks the same deadline between journal batches.LINORA_API_RATE_SEARCH_PER_SEC/_BURST (5/s, burst 20), plus one request in flight per user (LINORA_API_SEARCH_USER_INFLIGHT) and 4 per IP (LINORA_API_SEARCH_IP_INFLIGHT), per replica. Over a cap: 429 + Retry-After. Other query routes are not gated (bounded by the guard).vm context after --enable-experimental-regexp-engine is set at runtime is a V8 fatal error (Node 26.4, Check failed: IsCompatibleCode in InitializeGlobal_regexp_linear_flag). The guard’s single context is therefore created before the flag (prepareGuard() in enableLinearRegexFallback()). The worker must never create another vm context.terminate(): needs a copy of the doc per thread (hundreds of MB).nextCursor when truncated is true, even if fewer than limit rows came back.apps/docworker/test/guard.test.ts covers catastrophic patterns over 5,000 long distinct names (paged, each call < 800 ms), the 503 path, unsupported constructs and the validator/executor parity. apps/api/test/queries.test.ts covers the admission caps.