{"record":{"id":"daf81efe20054a79","repo":"santifer/career-ops","slug":"torre-untrusted-hostname-parsed-hostname-m","errorCode":null,"errorMessage":"torre: untrusted hostname \"${parsed.hostname}\" — must be ${TRUSTED_API_HOST}","messagePattern":"torre: untrusted hostname \"(.+?)\" — must be (.+?)","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"providers/torre.mjs","lineNumber":94,"sourceCode":"  'potential-to-develop',\n  '1-plus-year',\n  '2-plus-years',\n  '3-plus-years',\n  '5-plus-years',\n]);\nconst DEFAULT_EXPERIENCE = '1-plus-year';\n\n/** @param {string} url */\nfunction assertTorreUrl(url) {\n  let parsed;\n  try {\n    parsed = new URL(url);\n  } catch {\n    throw new Error(`torre: invalid URL: ${url}`);\n  }\n  if (parsed.protocol !== 'https:') throw new Error(`torre: URL must use HTTPS: ${url}`);\n  if (parsed.hostname !== TRUSTED_API_HOST) {\n    throw new Error(`torre: untrusted hostname \"${parsed.hostname}\" — must be ${TRUSTED_API_HOST}`);\n  }\n  return url;\n}\n\n/**\n * Build the search body from the portal entry. Only filters proven to affect\n * `total` are emitted — see the header note. Exported for tests.\n *\n * @param {any} entry\n * @returns {object}\n */\nexport function buildTorreQuery(entry) {\n  /** @type {Record<string, unknown>} */\n  const body = {};\n\n  const search = typeof entry?.search === 'string' ? entry.search.trim() : '';\n  if (search) {\n    // `experience` is mandatory here — omitting it is a hard 500, so it is","sourceCodeStart":76,"sourceCodeEnd":112,"githubUrl":"https://github.com/santifer/career-ops/blob/aac998c7ed7248ea853b720ceeb1fdbeb322fc5d/providers/torre.mjs#L76-L112","documentation":"The torre provider restricts requests to a single trusted API host (search.torre.co). assertTorreUrl parses the URL and compares parsed.hostname against TRUSTED_API_HOST; any other hostname is rejected. This prevents the provider from being pointed at arbitrary hosts (SSRF/injection defense) — even a valid https URL to a look-alike domain is refused.","triggerScenarios":"A portals.yml entry for provider torre carries a careers_url whose hostname is not exactly 'search.torre.co' — e.g. 'https://api.torre.co/...', 'https://search.torre.co.evil.example/...', 'https://www.torre.co/...', or a typo'd host like 'search.torre.co0'. The URL is well-formed and https, so only the hostname check fires.","commonSituations":"Typos in the config host, copying the posting permalink host (torre.ai) instead of the API host (search.torre.co), subdomain confusion (www. prefix), or an attacker-influenced value reaching the URL field (the check exists precisely for this).","solutions":["Set the careers_url host to exactly https://search.torre.co (no www, no extra subdomains)","Use the provider default endpoint instead of overriding careers_url — the torre provider builds its own POST https://search.torre.co/opportunities/_search URL","Check for typos or trailing characters in the configured hostname (e.g. .co0, a space, a port suffix)","If you genuinely need another host, it requires a code change to TRUSTED_API_HOST in providers/torre.mjs — do not attempt to work around it in config"],"exampleFix":"// before\ncareers_url: https://www.torre.co/opportunities/_search\n// after\ncareers_url: https://search.torre.co/opportunities/_search","handlingStrategy":"validation","validationCode":"const TRUSTED_API_HOST = 'search.torre.co';\nfunction isTrustedTorreUrl(url) {\n  try {\n    const parsed = new URL(url);\n    return parsed.protocol === 'https:' && parsed.hostname === TRUSTED_API_HOST;\n  } catch { return false; }\n}","typeGuard":"const isTorreApiUrl = (u) => { try { return new URL(u).hostname === 'search.torre.co'; } catch { return false; } };","tryCatchPattern":"try {\n  await torreProvider.fetch(entry);\n} catch (err) {\n  if (err.message.includes('untrusted hostname')) {\n    const host = new URL(entry.careers_url).hostname;\n    console.error(`${entry.name}: host \"${host}\" not allowed for torre — use search.torre.co`);\n    return;\n  }\n  throw err;\n}","preventionTips":["Never override careers_url for torre unless you mean the exact host search.torre.co","Remember torre.ai (posting permalinks) is NOT the API host — do not confuse them in config","Treat untrusted-hostname errors as a possible injected/tampered URL and audit the config source","Check for accidental www. prefixes and extra subdomains when hand-editing hosts"],"tags":["url-validation","ssrf","allowlist","security","config"],"backgroundTag":"invalid-url","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"}