{"record":{"id":"91274b60048cc9b0","repo":"santifer/career-ops","slug":"nodesk-untrusted-hostname-parsed-hostname","errorCode":null,"errorMessage":"nodesk: untrusted hostname \"${parsed.hostname}\" - must be ${TRUSTED_HOST}","messagePattern":"nodesk: untrusted hostname \"(.+?)\" - must be (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"providers/nodesk.mjs","lineNumber":24,"sourceCode":"// and XML, so it is parsed in-process with the same tiny tag extractor\n// approach as providers/personio.mjs rather than adding an XML dependency.\n//\n// Wire in via a `job_boards:` entry with `provider: nodesk`.\n\nconst FEED_URL = 'https://nodesk.co/remote-jobs/index.xml';\nconst TRUSTED_HOST = 'nodesk.co';\n\n/** @param {string} url */\nfunction assertNodeskUrl(url) {\n  let parsed;\n  try {\n    parsed = new URL(url);\n  } catch {\n    throw new Error(`nodesk: invalid URL: ${url}`);\n  }\n  if (parsed.protocol !== 'https:') throw new Error(`nodesk: URL must use HTTPS: ${url}`);\n  if (parsed.hostname !== TRUSTED_HOST) {\n    throw new Error(`nodesk: 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() : 'NoDesk';\n}\n\n/** @type {Provider} */\nexport default {\n  id: 'nodesk',","sourceCodeStart":6,"sourceCodeEnd":42,"githubUrl":"https://github.com/santifer/career-ops/blob/9b17a8ac97b398a496b38e423ae24e433b43254f/providers/nodesk.mjs#L6-L42","documentation":"Thrown by nodesk's assertNodeskUrl() when the parsed URL's hostname is not exactly 'nodesk.co' (the TRUSTED_HOST constant). This is the third and final SSRF gate, ensuring the request stays on the legitimate nodesk.co origin regardless of redirects. It prevents DNS-rebinding and open-redirect-based SSRF by pinning the hostname before the fetch.","triggerScenarios":"The URL is valid and HTTPS but points to a different host: e.g. 'https://www.nodesk.co/...' (note the www subdomain), 'https://evil.com/...' or 'https://nodesk.co.evil.com/...'. Also triggered by a misconfigured careers_url that has been changed to a proxy, a mirror, or a different job board domain entirely. The strict equality check rejects any subdomain variant.","commonSituations":"Someone adds 'www.' to the hostname (www.nodesk.co). The entry was copied from another provider and the domain wasn't updated. A well-meaning admin pointed the URL at a caching proxy or corporate gateway on a different domain. DNS-rebinding attacks where an attacker-controlled hostname resolves to an internal IP are blocked here.","solutions":["Set the URL hostname to exactly 'nodesk.co' — remove any subdomain like www., api., or feed..","If a subdomain variant is legitimately needed (e.g. api.nodesk.co), update the TRUSTED_HOST constant or switch to a hostname allowlist Set like other providers use.","Verify the entry was not copy-pasted from a different provider block — the provider field and URL domain must match."],"exampleFix":"// before\nconst TRUSTED_HOST = 'nodesk.co';\n// entry has: https://www.nodesk.co/remote-jobs/index.xml\n// → throws: untrusted hostname \"www.nodesk.co\"\n\n// after — either fix the URL to drop www, or allowlist variants:\nconst TRUSTED_HOSTS = new Set(['nodesk.co', 'www.nodesk.co']);\nif (!TRUSTED_HOSTS.has(parsed.hostname)) {\n  throw new Error(`nodesk: untrusted hostname \"${parsed.hostname}\" - must be nodesk.co`);\n}","handlingStrategy":"validation","validationCode":"const TRUSTED_HOST = 'nodesk.co';\n\n/** Check hostname matches the trusted host before calling the provider. */\nfunction isTrustedNodeskUrl(url) {\n  try {\n    return new URL(url).hostname === TRUSTED_HOST;\n  } catch {\n    return false;\n  }\n}\n\nif (!isTrustedNodeskUrl(entry.api)) {\n  console.warn(`nodesk entry ${entry.name} has untrusted host`);\n  continue;\n}","typeGuard":"/** @param {string} url @returns {boolean} */\nfunction isNodeskHost(url) {\n  try { return new URL(url).hostname === 'nodesk.co'; } catch { return false; }\n}","tryCatchPattern":"try {\n  await nodeskProvider.fetch(entry, ctx);\n} catch (err) {\n  if (String(err.message).includes('untrusted hostname')) {\n    console.warn(`nodesk entry ${entry.name} points to wrong host — fix portals.yml`);\n    continue;\n  }\n  throw err;\n}","preventionTips":["Ensure portal URLs use exactly 'nodesk.co' without subdomains.","Run a config audit that checks each provider entry's URL hostname against the provider's trusted host.","Document the exact allowed hostname(s) per provider in a config reference."],"tags":["url-validation","ssrf-guard","hostname-allowlist","nodesk","security"],"backgroundTag":null,"analyzedSha":"9b17a8ac97b398a496b38e423ae24e433b43254f","analyzedAt":"2026-08-13T00:48:39.135Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}