远程浏览器 TOCTOU SSRF 和无限制的工作进程内存 DoS
作者: codeCraft-Ritik创建于 2026年9月28日更新于 2026年9月28日
标签bug
Overview
In apps/worker/lib/protectPageRequests.ts and apps/worker/lib/preservationScheme/handleScreenshotAndPdf.ts:
- Remote Browser TOCTOU/SSRF Rebinding: When running with
PLAYWRIGHT_WS_URL(the standard Docker/production architecture for remote Chromium browsers),assertUrlIsSafeForServerSideFetch(request.url())validates the URL on the Linkwarden worker host. Once validated,route.continue()instructs the remote Chromium instance to fetch the asset. Chromium performs its own DNS lookup. An attacker using DNS rebinding (low TTL DNS pointing to a public IP first, then resolving to127.0.0.1or169.254.169.254) bypasses SSRF restrictions and accesses internal networks and cloud instance metadata. - Worker Memory Exhaustion (OOM DoS): In local browser mode, all sub-resources on an archived page are intercepted and fetched via
safeFetch, followed byawait response.buffer(). There is no response size limit or streaming cap. Any webpage embedding large assets (such as multiple 4K videos or large binary blobs) forces the worker process to buffer hundreds of megabytes directly into Node.js heap memory, leading toJavaScript heap out of memoryprocess crashes. - Leaked Interval in
autoScroll: InhandleScreenshotAndPdf.ts, whentimeoutPromiseresolves inPromise.race([scrollingPromise, timeoutPromise]),clearInterval(scrollDown)is never called. The timer continues executingwindow.scrollByevery 100ms in the page background while screenshots and PDFs are actively captured, causing visual tearing and resource leakage.
Impact
- Security: Private network and cloud metadata access via remote Playwright browser workers.
- Reliability: Uncontrolled Node.js worker crashes resulting in stuck queues and unarchived links for all users.
- Preservation Quality: Corrupted screenshots and fragmented PDF archives due to scrolling races during rendering.
Affected Files & Locations
apps/worker/lib/protectPageRequests.ts(Lines 27–65)apps/worker/lib/preservationScheme/handleScreenshotAndPdf.ts(Lines 96–119)
// apps/worker/lib/protectPageRequests.ts
27: if (remoteBrowser) {
28: try {
29: await assertUrlIsSafeForServerSideFetch(request.url());
30: await route.continue(); // ❌ TOCTOU: Remote browser re-resolves DNS independently!
31: } catch (error) { ... }
...
45: const response = await safeFetch(request.url(), { ... });
...
56: await route.fulfill({
57: status: response.status,
58: headers: responseHeaders,
59: body: await response.buffer(), // ❌ UNBOUNDED BUFFER: Can exhaust Node.js heap!
60: });// apps/worker/lib/preservationScheme/handleScreenshotAndPdf.ts
96: const autoScroll = async (AUTOSCROLL_TIMEOUT: number) => {
97: const timeoutPromise = new Promise<void>((resolve) => {
98: setTimeout(() => resolve(), AUTOSCROLL_TIMEOUT * 1000);
99: });
100: const scrollingPromise = new Promise<void>((resolve) => {
...
106:
…内容来源: linkwarden/linkwarden