{"record":{"id":"1de9726e94688110","repo":"santifer/career-ops","slug":"bamboohr-untrusted-hostname-parsed-hostname","errorCode":null,"errorMessage":"bamboohr: untrusted hostname \"${parsed.hostname}\" — must match <tenant>.bamboohr.com","messagePattern":"bamboohr: untrusted hostname \"(.+?)\" — must match <tenant>\\.bamboohr\\.com","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"providers/bamboohr.mjs","lineNumber":27,"sourceCode":"//\n// The list endpoint (`/careers/list`) returns lightweight metadata — enough for\n// the Job contract (title, url, location) at zero token cost. The full JD lives\n// behind a second `/careers/<id>/detail` request, which the scanner deliberately\n// skips to stay zero-token (so `description`/`postedAt` are omitted).\n\nconst BAMBOOHR_HOST_RE = /^[a-z0-9][a-z0-9-]*\\.bamboohr\\.com$/;\n\n/** @param {string} url */\nfunction assertBambooHRUrl(url) {\n  let parsed;\n  try {\n    parsed = new URL(url);\n  } catch {\n    throw new Error(`bamboohr: invalid URL: ${url}`);\n  }\n  if (parsed.protocol !== 'https:') throw new Error(`bamboohr: URL must use HTTPS: ${url}`);\n  if (!BAMBOOHR_HOST_RE.test(parsed.hostname)) {\n    throw new Error(`bamboohr: untrusted hostname \"${parsed.hostname}\" — must match <tenant>.bamboohr.com`);\n  }\n  return url;\n}\n\n/**\n * Resolve the tenant origin (`https://<tenant>.bamboohr.com`) from an entry.\n * Honours an explicit `api:` URL, else parses `careers_url`.\n * @param {import('./_types.js').PortalEntry} entry\n * @returns {string | null}\n */\nfunction resolveOrigin(entry) {\n  const rawApi = typeof entry.api === 'string' ? entry.api : '';\n  const rawCareers = typeof entry.careers_url === 'string' ? entry.careers_url : '';\n  const raw = (rawApi || rawCareers).trim();\n  if (!raw) return null;\n  let parsed;\n  try {\n    parsed = new URL(raw);","sourceCodeStart":9,"sourceCodeEnd":45,"githubUrl":"https://github.com/santifer/career-ops/blob/9b17a8ac97b398a496b38e423ae24e433b43254f/providers/bamboohr.mjs#L9-L45","documentation":"The host-allowlist step of BambooHR's SSRF guard. The hostname must match `/^[a-z0-9][a-z0-9-]*\\.bamboohr\\.com$/` — i.e. a single lowercase tenant label (alphanumeric + hyphens, not starting with a hyphen) followed by `.bamboohr.com`. Uppercase, multi-label tenants, or other domains are rejected.","triggerScenarios":"`BAMBOOHR_HOST_RE.test(parsed.hostname)` is false: hostname is uppercase (`Acme.bamboohr.com`), has a multi-part tenant (`jobs.acme.bamboohr.com`), uses a different domain, or is the apex (`bamboohr.com`).","commonSituations":"A tenant name with uppercase letters, a deep subdomain, a typo in the domain, or a URL pointing at a non-BambooHR host.","solutions":["Use a single lowercase tenant label: `https://acme.bamboohr.com`.","If the tenant legitimately has subdomains, lower-case the host and adjust the regex to permit extra labels only if you trust them.","Confirm the host is actually a BambooHR tenant before assigning the provider."],"exampleFix":"# before (rejected — uppercase + subdomain)\n- name: Acme\n  api: https://Jobs.Acme.bamboohr.com\n\n# after\n- name: Acme\n  api: https://acme.bamboohr.com","handlingStrategy":"validation","validationCode":"const RE = /^[a-z0-9][a-z0-9-]*\\.bamboohr\\.com$/;\nfunction assertBambooHost(u) {\n  const h = new URL(u).hostname;\n  if (!RE.test(h)) throw new Error(`bamboohr: host ${h} must match <tenant>.bamboohr.com (lowercase, single label)`);\n}\nif (entry.api) assertBambooHost(entry.api);\nif (entry.careers_url) assertBambooHost(entry.careers_url);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Lowercase tenant names in config before validation.","Reject multi-label or uppercase hosts at config lint time.","Confirm the host is a real BambooHR tenant before assigning the provider."],"tags":["bamboohr","ssrf","host-allowlist","security","regex"],"backgroundTag":null,"analyzedSha":"9b17a8ac97b398a496b38e423ae24e433b43254f","analyzedAt":"2026-08-13T00:48:39.135Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}