{"record":{"id":"48709bbe0da5b1e1","repo":"santifer/career-ops","slug":"blocked-request-to-restricted-destination-re","errorCode":null,"errorMessage":"   Blocked request to restricted destination: ${requestUrl} (${verdict.reason})","messagePattern":"   Blocked request to restricted destination: (.+?) \\((.+?)\\)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"archive-posting.mjs","lineNumber":305,"sourceCode":"\n/**\n * Register the egress guard on a Playwright context.\n *\n * Registered on the *context* rather than the page: a route bound to a single\n * page doesn't cover requests the flow makes outside it, and the context is\n * what owns the whole navigation. Both layers of the shared guard run here —\n * the literal-host check first (cheap, no network), then the DNS re-check that\n * catches a public hostname resolving into private space.\n *\n * @param {import('playwright').BrowserContext} context - Context to guard.\n */\nexport async function installEgressGuard(context) {\n  await context.route('**/*', async (route) => {\n    const requestUrl = route.request().url();\n\n    const verdict = rejectPrivateOrInvalid(requestUrl);\n    if (verdict) {\n      console.warn(`   Blocked request to restricted destination: ${requestUrl} (${verdict.reason})`);\n      return route.abort('blockedbyclient');\n    }\n\n    try {\n      await validateUrlSecurity(requestUrl);\n      return route.continue();\n    } catch (err) {\n      console.warn(`   Blocked request to restricted destination (DNS): ${requestUrl} - ${err.message}`);\n      return route.abort('blockedbyclient');\n    }\n  });\n}\n\nexport async function archiveUrl(browser, url, { company: companyHint, role: roleHint } = {}) {\n  console.log(`\\n🔗  ${url}`);\n\n  // Refuse before launching any navigation, so an obviously-internal target\n  // never reaches Playwright at all.","sourceCodeStart":287,"sourceCodeEnd":323,"githubUrl":"https://github.com/santifer/career-ops/blob/aac998c7ed7248ea853b720ceeb1fdbeb322fc5d/archive-posting.mjs#L287-L323","documentation":"installEgressGuard() in archive-posting.mjs registers a Playwright route interceptor on '**/*' and inspects every request the page makes. If rejectPrivateOrInvalid(requestUrl) returns a verdict, the request is aborted with 'blockedbyclient' and a warning is logged: 'Blocked request to restricted destination: <url> (<reason>)'. It guards against SSRF: private/loopback/link-local IPs, metadata endpoints, and invalid URLs.","triggerScenarios":"An archived job-posting page (or its scripts/assets) requesting localhost, 127.0.0.1, 169.254.169.254 (cloud metadata), 10.x/192.168.x hosts, file: URLs, or malformed URLs. Also fires when a company CDN or tracking pixel resolves to a private address.","commonSituations":"Scraping a posting whose scripts beacon to internal hosts; an attacker-crafted JD page attempting SSRF; corporate proxies rewriting URLs to internal addresses; localhost-referencing assets in a captured HTML snapshot.","solutions":["Read the warning's reason to identify why the URL was rejected (private IP range, invalid URL, metadata endpoint)","If the blocked URL is a benign first-party asset, serve it locally from an allowlisted host instead","Ensure archive-posting only loads the posting URL from public DNS; avoid pages that redirect into internal networks","Do not bypass the guard for pages you don't control — it prevents SSRF against your machine"],"exampleFix":"// before: page references internal asset, blocked\n<img src=\"http://127.0.0.1:8080/logo.png\">\n// after: serve assets from the public origin the guard allows\n<img src=\"https://cdn.company.example/logo.png\">","handlingStrategy":"try-catch","validationCode":"const url = new URL(requestUrl);\nconst PRIVATE = /^(localhost$|127\\.|10\\.|192\\.168\\.|169\\.254\\.|172\\.(1[6-9]|2\\d|3[01])\\.)/;\nif (!['http:', 'https:'].includes(url.protocol) || PRIVATE.test(url.hostname)) {\n  console.warn(`would be blocked: ${requestUrl}`);\n}","typeGuard":"const isPublicHttpUrl = (u) => { try { const url = new URL(u); return (url.protocol === 'http:' || url.protocol === 'https:') && !/^localhost$|^127\\.|^10\\.|^192\\.168\\.|^169\\.254\\./.test(url.hostname); } catch { return false; } };","tryCatchPattern":"await context.route('**/*', async (route) => {\n  const verdict = rejectPrivateOrInvalid(route.request().url());\n  if (verdict) {\n    console.warn(`Blocked request to restricted destination: ${route.request().url()} (${verdict.reason})`);\n    return route.abort('blockedbyclient');\n  }\n  return route.continue();\n});","preventionTips":["Only archive postings from public HTTPS URLs you trust","Never point the scraper at internal hostnames, localhost, or link-local addresses","Treat the blocked-request warning as a signal the page may be hostile (SSRF attempt)","Keep rejectPrivateOrInvalid's IP blocklist current, including cloud metadata endpoints (169.254.169.254)"],"tags":["security","network","playwright","ssrf"],"backgroundTag":"network-request-blocked","analyzedSha":"aac998c7ed7248ea853b720ceeb1fdbeb322fc5d","analyzedAt":"2026-09-16T06:35:29.214Z","contentChangedAt":"2026-09-16T06:35:29.214Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}