santifer/career-ops · error · Error

jobbankca: untrusted hostname

Error message

jobbankca: untrusted hostname "${parsed.hostname}" — must be ${TRUSTED_HOST}

What it means

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.

Solutions

  1. Set the entry's URL host to exactly https://www.jobbank.gc.ca/jobsearch/feed/jobSearchRSSfeed
  2. Check for typos/extra suffixes (e.g. .evil.com, trailing host spoofing) in the configured URL
  3. If you genuinely need another Job Bank host, that requires changing TRUSTED_HOST in the provider source — prefer keeping the allowlist strict

Example fix

// before
url: https://jobbank.gc.ca/jobsearch/feed/jobSearchRSSfeed
// after
url: https://www.jobbank.gc.ca/jobsearch/feed/jobSearchRSSfeed
Defensive patterns

Strategy: validation

Validate before calling

function isTrustedJobBankHost(url) {
  try { return new URL(url).hostname === 'www.jobbank.gc.ca'; } catch { return false; }
}

Type guard

function isTrustedHost(u, host) {
  return URL.canParse(u) && new URL(u).hostname === host;
}

Try / catch

try {
  assertJobBankUrl(u);
} catch (e) {
  if (/untrusted hostname/.test(e.message)) {
    console.error(`${e.message} — set the URL to https://www.jobbank.gc.ca/...`);
    return [];
  }
  throw e;
}

Prevention

When it happens

Trigger: 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'.

Common situations: 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.

Understand the failure class

Background: "Invalid URL" errors: why new URL(), URI.parse, and reqwest::Url reject your string — missing scheme, whitespace, and bad path format — this error's family across 39 libraries.

Related errors


AI-assisted analysis of santifer/career-ops@aac998c7ed (2026-09-16). Data as JSON: /api/errors/40a14a401389a61b. Report an issue: GitHub.

Appendix: source

Thrown at providers/jobbankca.mjs:102

}

/** @param {string} keyword @param {number} page */
export function buildFeedUrl(keyword, page) {
  const params = new URLSearchParams({ searchstring: keyword, locationstring: '', page: String(page) });
  return `${FEED_URL}?${params.toString()}`;
}

/** @param {string} url */
export function assertJobBankUrl(url) {
  let parsed;
  try {
    parsed = new URL(url);
  } catch {
    throw new Error(`jobbankca: invalid URL: ${url}`);
  }
  if (parsed.protocol !== 'https:') throw new Error(`jobbankca: URL must use HTTPS: ${url}`);
  if (parsed.hostname !== TRUSTED_HOST) {
    throw new Error(`jobbankca: untrusted hostname "${parsed.hostname}" — must be ${TRUSTED_HOST}`);
  }
  return url;
}

// Resolve an Atom element's inner text: unwrap CDATA, else decode entities.
function extractText(inner) {
  const cdata = inner.match(/^\s*<!\[CDATA\[([\s\S]*?)\]\]>\s*$/);
  if (cdata) return cdata[1].trim();
  return decodeEntities(inner).trim();
}

function tagText(block, tag) {
  const m = block.match(new RegExp(`<${tag}\\b[^>]*>([\\s\\S]*?)</${tag}>`, 'i'));
  return m ? extractText(m[1]) : '';
}

// <link rel="alternate" type="text/html" href="..."/> — an attribute here,
// not inner text (Atom), unlike an RSS <link>text</link>. An Atom entry may

View on GitHub (pinned to aac998c7ed)