{"record":{"id":"40a14a401389a61b","repo":"santifer/career-ops","slug":"jobbankca-untrusted-hostname-parsed-hostname","errorCode":null,"errorMessage":"jobbankca: untrusted hostname \"${parsed.hostname}\" — must be ${TRUSTED_HOST}","messagePattern":"jobbankca: untrusted hostname \"(.+?)\" — must be (.+?)","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"providers/jobbankca.mjs","lineNumber":102,"sourceCode":"}\n\n/** @param {string} keyword @param {number} page */\nexport function buildFeedUrl(keyword, page) {\n  const params = new URLSearchParams({ searchstring: keyword, locationstring: '', page: String(page) });\n  return `${FEED_URL}?${params.toString()}`;\n}\n\n/** @param {string} url */\nexport function assertJobBankUrl(url) {\n  let parsed;\n  try {\n    parsed = new URL(url);\n  } catch {\n    throw new Error(`jobbankca: invalid URL: ${url}`);\n  }\n  if (parsed.protocol !== 'https:') throw new Error(`jobbankca: URL must use HTTPS: ${url}`);\n  if (parsed.hostname !== TRUSTED_HOST) {\n    throw new Error(`jobbankca: untrusted hostname \"${parsed.hostname}\" — must be ${TRUSTED_HOST}`);\n  }\n  return url;\n}\n\n// Resolve an Atom element's inner text: unwrap CDATA, else decode entities.\nfunction extractText(inner) {\n  const cdata = inner.match(/^\\s*<!\\[CDATA\\[([\\s\\S]*?)\\]\\]>\\s*$/);\n  if (cdata) return cdata[1].trim();\n  return decodeEntities(inner).trim();\n}\n\nfunction tagText(block, tag) {\n  const m = block.match(new RegExp(`<${tag}\\\\b[^>]*>([\\\\s\\\\S]*?)</${tag}>`, 'i'));\n  return m ? extractText(m[1]) : '';\n}\n\n// <link rel=\"alternate\" type=\"text/html\" href=\"...\"/> — an attribute here,\n// not inner text (Atom), unlike an RSS <link>text</link>. An Atom entry may","sourceCodeStart":84,"sourceCodeEnd":120,"githubUrl":"https://github.com/santifer/career-ops/blob/aac998c7ed7248ea853b720ceeb1fdbeb322fc5d/providers/jobbankca.mjs#L84-L120","documentation":"assertJobBankUrl enforces a single trusted hostname: the URL's parsed hostname must exactly equal TRUSTED_HOST ('www.jobbank.gc.ca'). Any other host — lookalike domains, subdomain variants, or internal addresses — is rejected as an SSRF guard, since this URL is fetched server-side by the scanner.","triggerScenarios":"Calling assertJobBankUrl with 'https://jobbank.gc.ca/...' (missing 'www'), 'https://evil.example.com/...', 'https://www.jobbank.gc.ca.evil.com/...', or 'https://127.0.0.1/...' — anything whose parsed hostname !== 'www.jobbank.gc.ca'.","commonSituations":"Omitting the 'www.' prefix in a hand-typed config; a redirect target or mirror domain pasted into portals.yml; an SSRF attempt supplying an internal host that this allowlist blocks.","solutions":["Set the entry's URL host to exactly https://www.jobbank.gc.ca/jobsearch/feed/jobSearchRSSfeed","Check for typos/extra suffixes (e.g. .evil.com, trailing host spoofing) in the configured URL","If you genuinely need another Job Bank host, that requires changing TRUSTED_HOST in the provider source — prefer keeping the allowlist strict"],"exampleFix":"// before\nurl: https://jobbank.gc.ca/jobsearch/feed/jobSearchRSSfeed\n// after\nurl: https://www.jobbank.gc.ca/jobsearch/feed/jobSearchRSSfeed","handlingStrategy":"validation","validationCode":"function isTrustedJobBankHost(url) {\n  try { return new URL(url).hostname === 'www.jobbank.gc.ca'; } catch { return false; }\n}","typeGuard":"function isTrustedHost(u, host) {\n  return URL.canParse(u) && new URL(u).hostname === host;\n}","tryCatchPattern":"try {\n  assertJobBankUrl(u);\n} catch (e) {\n  if (/untrusted hostname/.test(e.message)) {\n    console.error(`${e.message} — set the URL to https://www.jobbank.gc.ca/...`);\n    return [];\n  }\n  throw e;\n}","preventionTips":["Copy the canonical FEED_URL instead of typing hostnames by hand","Remember Job Bank uses the www. prefix — jobbank.gc.ca is rejected","Never relax host allowlists to accommodate untrusted input (SSRF risk)","Review any config-supplied URL in code review with the allowlist in mind"],"tags":["url-validation","ssrf-protection","allowlist","security"],"backgroundTag":"invalid-url-format","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"}