{"record":{"id":"f6873f68ae0d3dde","repo":"santifer/career-ops","slug":"wttj-untrusted-label-hostname-parsed-hostna","errorCode":null,"errorMessage":"wttj: untrusted ${label} hostname \"${parsed.hostname}\" — must be ${host}","messagePattern":"wttj: untrusted (.+?) hostname \"(.+?)\" — must be (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"providers/wttj.mjs","lineNumber":42,"sourceCode":"// salary_filter can gate on it.\n\nconst ENV_URL = 'https://www.welcometothejungle.com/api/env';\nconst SITE_ORIGIN = 'https://www.welcometothejungle.com';\nconst INDEX = 'wttj_jobs_production_en';\nconst DEFAULT_MAX_HITS = 100;\nconst MAX_HITS_CAP = 200;\n\n/** Pin a URL to an expected https host. */\nfunction assertHost(url, host, label) {\n  let parsed;\n  try {\n    parsed = new URL(url);\n  } catch {\n    throw new Error(`wttj: invalid URL: ${url}`);\n  }\n  if (parsed.protocol !== 'https:') throw new Error(`wttj: URL must use HTTPS: ${url}`);\n  if (parsed.hostname !== host.toLowerCase()) {\n    throw new Error(`wttj: untrusted ${label} hostname \"${parsed.hostname}\" — must be ${host}`);\n  }\n  return url;\n}\n\n/**\n * Parse the `window.env = {...}` payload served by /api/env and extract the\n * Algolia application id + client search key.\n * @param {string} text\n * @returns {{ appId: string, apiKey: string }}\n */\nexport function parseEnvPayload(text) {\n  const start = text.indexOf('{');\n  const end = text.lastIndexOf('}');\n  if (start === -1 || end <= start) throw new Error('wttj: /api/env payload has no JSON object');\n  let env;\n  try {\n    env = JSON.parse(text.slice(start, end + 1));\n  } catch {","sourceCodeStart":24,"sourceCodeEnd":60,"githubUrl":"https://github.com/santifer/career-ops/blob/9b17a8ac97b398a496b38e423ae24e433b43254f/providers/wttj.mjs#L24-L60","documentation":"SSRF guard: the hostname does not match the expected host. For the env URL the expected host is www.welcometothejungle.com; for Algolia queries it is the derived ${appId}-dsn.algolia.net. The Algolia case can legitimately fire if WTTJ changes how it routes Algolia (different domain or suffix).","triggerScenarios":"ENV_URL constant pointed at a different host; OR WTTJ rotated its Algolia routing so the actual Algolia host no longer matches ${appId}-dsn.algolia.net; OR the appId regex matched a value that does not correspond to a real Algolia app id.","commonSituations":"WTTJ migrates Algolia hosts (e.g. a regional domain or a different -dsn suffix); a maintainer edits ENV_URL host.","solutions":["Confirm ENV_URL host is www.welcometothejungle.com.","For Algolia host mismatches, inspect the appId parsed from /api/env and verify WTTJ still routes via ${appId}-dsn.algolia.net; update the host construction if WTTJ changed routing.","Re-fetch /api/env to confirm credentials are still valid."],"exampleFix":"// if WTTJ moves to a regional Algolia host:\n// before\nconst algoliaHost = `${appId}-dsn.algolia.net`;\n// after\nconst algoliaHost = `${appId}-dsn.algolia.eu`;","handlingStrategy":"validation","validationCode":"if (new URL(ENV_URL).hostname !== \"www.welcometothejungle.com\")\n  throw new Error(\"wttj: ENV_URL hostname drift\");\nif (new URL(`https://${algoliaHost}/`).hostname !== algoliaHost)\n  throw new Error(\"wttj: derived Algolia host mismatch\");","typeGuard":"const matchesExpectedHost = (url, host) => { try { return new URL(url).hostname === host.toLowerCase(); } catch { return false; } };","tryCatchPattern":null,"preventionTips":["Alert on this error to catch a WTTJ Algolia routing change.","Re-derive the algolia host from the validated appId each run."],"tags":["validation","url","ssrf-guard","hostname","wttj","algolia"],"backgroundTag":null,"analyzedSha":"9b17a8ac97b398a496b38e423ae24e433b43254f","analyzedAt":"2026-08-13T00:48:39.135Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}