santifer/career-ops · warning
Blocked request to restricted destination
Error message
Blocked request to restricted destination: ${requestUrl} (${verdict.reason}) What it means
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.
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
Example fix
// before: page references internal asset, blocked <img src="http://127.0.0.1:8080/logo.png"> // after: serve assets from the public origin the guard allows <img src="https://cdn.company.example/logo.png">
Defensive patterns
Strategy: try-catch
Validate before calling
const url = new URL(requestUrl);
const PRIVATE = /^(localhost$|127\.|10\.|192\.168\.|169\.254\.|172\.(1[6-9]|2\d|3[01])\.)/;
if (!['http:', 'https:'].includes(url.protocol) || PRIVATE.test(url.hostname)) {
console.warn(`would be blocked: ${requestUrl}`);
} Type guard
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; } }; Try / catch
await context.route('**/*', async (route) => {
const verdict = rejectPrivateOrInvalid(route.request().url());
if (verdict) {
console.warn(`Blocked request to restricted destination: ${route.request().url()} (${verdict.reason})`);
return route.abort('blockedbyclient');
}
return route.continue();
}); Prevention
- 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)
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Access denied: Egress guard blocked private target IP
- Access denied: Egress guard blocked private target IP
- Blocked request to restricted destination (DNS)
- Blocked request to restricted destination (DNS)
- Blocked request to restricted destination
AI-assisted analysis of santifer/career-ops@aac998c7ed (2026-09-16).
Data as JSON: /api/errors/48709bbe0da5b1e1.
Report an issue: GitHub.
Appendix: source
Thrown at archive-posting.mjs:305
/**
* Register the egress guard on a Playwright context.
*
* Registered on the *context* rather than the page: a route bound to a single
* page doesn't cover requests the flow makes outside it, and the context is
* what owns the whole navigation. Both layers of the shared guard run here —
* the literal-host check first (cheap, no network), then the DNS re-check that
* catches a public hostname resolving into private space.
*
* @param {import('playwright').BrowserContext} context - Context to guard.
*/
export async function installEgressGuard(context) {
await context.route('**/*', async (route) => {
const requestUrl = route.request().url();
const verdict = rejectPrivateOrInvalid(requestUrl);
if (verdict) {
console.warn(` Blocked request to restricted destination: ${requestUrl} (${verdict.reason})`);
return route.abort('blockedbyclient');
}
try {
await validateUrlSecurity(requestUrl);
return route.continue();
} catch (err) {
console.warn(` Blocked request to restricted destination (DNS): ${requestUrl} - ${err.message}`);
return route.abort('blockedbyclient');
}
});
}
export async function archiveUrl(browser, url, { company: companyHint, role: roleHint } = {}) {
console.log(`\n🔗 ${url}`);
// Refuse before launching any navigation, so an obviously-internal target
// never reaches Playwright at all.View on GitHub (pinned to aac998c7ed)