{"record":{"id":"bcd95b182d24389c","repo":"santifer/career-ops","slug":"himalayas-untrusted-hostname-parsed-hostname","errorCode":null,"errorMessage":"himalayas: untrusted hostname \"${parsed.hostname}\" - must be ${TRUSTED_HOST}","messagePattern":"himalayas: untrusted hostname \"(.+?)\" - must be (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"providers/himalayas.mjs","lineNumber":24,"sourceCode":"// full feed is fetched so scan.mjs's title_filter / location_filter can do\n// the local gating consistently with other zero-token board providers.\n//\n// Wire in via a `job_boards:` entry with `provider: himalayas`.\n\nconst FEED_URL = 'https://himalayas.app/jobs/api?limit=50';\nconst TRUSTED_HOST = 'himalayas.app';\n\n/** @param {string} url */\nfunction assertHimalayasUrl(url) {\n  let parsed;\n  try {\n    parsed = new URL(url);\n  } catch {\n    throw new Error(`himalayas: invalid URL: ${url}`);\n  }\n  if (parsed.protocol !== 'https:') throw new Error(`himalayas: URL must use HTTPS: ${url}`);\n  if (parsed.hostname !== TRUSTED_HOST) {\n    throw new Error(`himalayas: untrusted hostname \"${parsed.hostname}\" - must be ${TRUSTED_HOST}`);\n  }\n  return url;\n}\n\nfunction cleanText(value) {\n  return typeof value === 'string' ? value.trim() : '';\n}\n\nfunction cleanHimalayasUrl(value) {\n  const raw = cleanText(value);\n  if (!raw) return '';\n  try {\n    const parsed = new URL(raw);\n    const host = parsed.hostname.toLowerCase();\n    const trusted = host === TRUSTED_HOST || host.endsWith(`.${TRUSTED_HOST}`);\n    return parsed.protocol === 'https:' && trusted ? parsed.href : '';\n  } catch {\n    return '';","sourceCodeStart":6,"sourceCodeEnd":42,"githubUrl":"https://github.com/santifer/career-ops/blob/9b17a8ac97b398a496b38e423ae24e433b43254f/providers/himalayas.mjs#L6-L42","documentation":"Thrown by assertHimalayasUrl when the URL's hostname is not exactly himalayas.app (subdomains are NOT allowed here — the check is strict equality, unlike the cleanHimalayasUrl helper which tolerates *.himalayas.app). This is the core SSRF allowlist guard. Shipped fetch() passes only the hardcoded himalayas.app constant, so it cannot fire unless the constant or the function's input changes.","triggerScenarios":"Editing FEED_URL to a different host (e.g. a CDN or mirror domain); reusing assertHimalayasUrl on entry.api that points at a subdomain like api.himalayas.app (the strict equality rejects subdomains even though cleanHimalayasUrl would accept them); a DNS-rebinding-style attempt to route the request off-host.","commonSituations":"Switching to a subdomain endpoint and assuming the assert allows it; a fork adding a configurable host without widening the allowlist; a malicious/typo entry URL routed through the assert.","solutions":["Keep FEED_URL on the bare himalayas.app host, or if a subdomain is genuinely required, update the assert to allow *.himalayas.app (mirror cleanHimalayasUrl's logic).","Never route untrusted entry input through assertHimalayasUrl without first confirming the host is allowlisted.","Document any host allowlist change next to TRUSTED_HOST so the SSRF posture stays explicit."],"exampleFix":"// before (strict — rejects subdomains)\nif (parsed.hostname !== TRUSTED_HOST) { throw ... }\n\n// after (allow subdomains, mirroring cleanHimalayasUrl)\nif (parsed.hostname !== TRUSTED_HOST && !parsed.hostname.endsWith('.' + TRUSTED_HOST)) { throw ... }","handlingStrategy":"validation","validationCode":"// For caller input, confirm the host is allowlisted before the assert throws.\nconst TRUSTED_HOST = 'himalayas.app';\nfunction isTrustedHimalayasHost(url) {\n  const u = new URL(url);\n  return u.hostname === TRUSTED_HOST; // assert is strict — subdomains NOT allowed\n}","typeGuard":"/** True for a URL on exactly himalayas.app (no subdomains, per the assert). */\nfunction isHimalayasTrusted(url) {\n  try {\n    const u = new URL(url);\n    return u.protocol === 'https:' && u.hostname === 'himalayas.app';\n  } catch { return false; }\n}","tryCatchPattern":"try {\n  return await himalayasProvider.fetch(entry, ctx);\n} catch (err) {\n  if (/untrusted hostname/.test(err.message)) {\n    console.error(`himalayas: host not allowlisted — ${err.message}`);\n  }\n  throw err;\n}","preventionTips":["Keep FEED_URL on the bare himalayas.app host; if a subdomain is genuinely needed, widen the assert to *.himalayas.app deliberately and document it.","Treat the SSRF allowlist as load-bearing — never widen it casually or route untrusted input through it.","Note cleanHimalayasUrl (the per-job helper) DOES allow subdomains; the request assert does not. Do not assume parity."],"tags":["ssrf","url-validation","allowlist","himalayas","defense-in-depth"],"backgroundTag":null,"analyzedSha":"9b17a8ac97b398a496b38e423ae24e433b43254f","analyzedAt":"2026-08-13T00:48:39.135Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}