{"record":{"id":"de721dc69a08c9a2","repo":"santifer/career-ops","slug":"larajobs-untrusted-hostname-parsed-hostname","errorCode":null,"errorMessage":"larajobs: untrusted hostname \"${parsed.hostname}\" - must be ${TRUSTED_HOST}","messagePattern":"larajobs: untrusted hostname \"(.+?)\" - must be (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"providers/larajobs.mjs","lineNumber":28,"sourceCode":"// `<job:company>` and `<job:location>`, so company and location come straight\n// from the feed (no title-splitting heuristics needed).\n//\n// Wire in via a `job_boards:` entry with `provider: larajobs`.\n\nconst FEED_URL = 'https://larajobs.com/feed';\nconst TRUSTED_HOST = 'larajobs.com';\n\n/** @param {string} url */\nfunction assertLarajobsUrl(url) {\n  let parsed;\n  try {\n    parsed = new URL(url);\n  } catch {\n    throw new Error(`larajobs: invalid URL: ${url}`);\n  }\n  if (parsed.protocol !== 'https:') throw new Error(`larajobs: URL must use HTTPS: ${url}`);\n  if (parsed.hostname !== TRUSTED_HOST) {\n    throw new Error(`larajobs: untrusted hostname \"${parsed.hostname}\" - must be ${TRUSTED_HOST}`);\n  }\n  return url;\n}\n\n// NaN-safe Date.parse - `|| undefined` would also coerce a valid epoch 0.\nfunction toEpochMs(value) {\n  if (!value) return undefined;\n  const parsed = Date.parse(value);\n  return Number.isNaN(parsed) ? undefined : parsed;\n}\n\nfunction fallbackCompany(entry) {\n  return typeof entry?.name === 'string' && entry.name.trim() ? entry.name.trim() : 'LaraJobs';\n}\n\n/** @type {Provider} */\nexport default {\n  id: 'larajobs',","sourceCodeStart":10,"sourceCodeEnd":46,"githubUrl":"https://github.com/santifer/career-ops/blob/9b17a8ac97b398a496b38e423ae24e433b43254f/providers/larajobs.mjs#L10-L46","documentation":"The third guard in assertLarajobsUrl: even a valid HTTPS URL must have hostname exactly equal to TRUSTED_HOST ('larajobs.com'). Any other host — including look-alikes or subdomains — is rejected. This is an SSRF defence: it stops a config change from making the scanner fetch an attacker-controlled or off-brand endpoint.","triggerScenarios":"An HTTPS URL whose hostname is not 'larajobs.com' — e.g. www.larajobs.com, api.larajobs.com, larajobs.com.evil.com, feed.larajobs.net, or an internal IP/host. The offending hostname is interpolated into the message.","commonSituations":"Someone added a www. prefix or a subdomain; a copy-paste brought in a similar domain; a malicious or mistaken config points the feed elsewhere; the trusted host genuinely moved and the constant needs updating.","solutions":["Correct the URL to use exactly https://larajobs.com (no subdomain).","If the feed legitimately moved hosts, update TRUSTED_HOST in providers/larajobs.mjs after verifying the new host is the official Larajobs endpoint.","Audit git history of portals.yml for the offending change."],"exampleFix":"// before\napi: https://www.larajobs.com/feed\n\n// after\napi: https://larajobs.com/feed","handlingStrategy":"validation","validationCode":"import { URL } from 'node:url';\nconst TRUSTED = new Set(['larajobs.com']);\nexport function isTrustedLarajobsHost(value) {\n  try { return TRUSTED.has(new URL(value).hostname); } catch { return false; }\n}","typeGuard":"/** @param {string} url */\nfunction isLarajobsHost(url) {\n  try { return new URL(url).hostname === 'larajobs.com'; } catch { return false; }\n}","tryCatchPattern":"try {\n  assertLarajobsUrl(url);\n} catch (err) {\n  // an untrusted-host error is a security signal — log loudly, do not silently fall back\n  if (err.message.includes('untrusted hostname')) console.error(`[security] ${err.message}`);\n  throw err;\n}","preventionTips":["Never override TRUSTED_HOST to silence the error without verifying the new host is the official Larajobs endpoint.","Audit portals.yml for look-alike domains (larajobs.net, larajob.com) in CI.","Treat an untrusted-hostname failure as a potential SSRF attempt, not a routine config typo."],"tags":["url-validation","ssrf","host-allowlist","larajobs","security"],"backgroundTag":null,"analyzedSha":"9b17a8ac97b398a496b38e423ae24e433b43254f","analyzedAt":"2026-08-13T00:48:39.135Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}