{"record":{"id":"6c578e538f58973d","repo":"BerriAI/litellm","slug":"rejected-polling-url-scheme-must-be-https","errorCode":null,"errorMessage":"Rejected polling URL: scheme must be https","messagePattern":"Rejected polling URL: scheme must be https","errorType":"http","errorClass":"BlackForestLabsError","httpStatus":502,"severity":"error","filePath":"litellm/llms/black_forest_labs/common_utils.py","lineNumber":42,"sourceCode":"\n\ndef assert_bfl_polling_url(polling_url: str) -> None:\n    \"\"\"Validate that a polling URL points to a BFL-controlled host.\n\n    BFL returns polling URLs on subdomains like ``gateway.bfl.ai`` that differ\n    from the submission host ``api.bfl.ai``. A strict same-origin check would\n    reject these legitimate URLs. Instead we verify the host is ``bfl.ai`` or\n    any subdomain of it, which keeps the SSRF guarantee (credentials only go\n    to BFL-controlled infrastructure) without false-positives on regional hosts.\n\n    Raises:\n        BlackForestLabsError: If the polling URL scheme or host is not trusted.\n    \"\"\"\n    parsed: Final = urlparse(polling_url)\n    host: Final = (parsed.hostname or \"\").lower()\n\n    if parsed.scheme != \"https\":\n        raise BlackForestLabsError(\n            status_code=502,\n            message=\"Rejected polling URL: scheme must be https\",\n        )\n\n    if host != _BFL_REGISTERED_DOMAIN and not host.endswith(\".\" + _BFL_REGISTERED_DOMAIN):\n        raise BlackForestLabsError(\n            status_code=502,\n            message=\"Rejected polling URL: host is not within the bfl.ai domain\",\n        )\n\n\n# Polling configuration\nDEFAULT_POLLING_INTERVAL: Final = 1.5  # seconds\nDEFAULT_MAX_POLLING_TIME: Final = 300  # 5 minutes\n\n# Model to endpoint mapping for image edit\nIMAGE_EDIT_MODELS: Final[dict[str, str]] = {\n    \"flux-kontext-pro\": \"/v1/flux-kontext-pro\",","sourceCodeStart":24,"sourceCodeEnd":60,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/llms/black_forest_labs/common_utils.py#L24-L60","documentation":"After submitting a Black Forest Labs (FLUX) image job, LiteLLM polls the polling_url returned by the API; assert_bfl_polling_url enforces an SSRF guard that requires the https scheme. A non-https polling_url is rejected with BlackForestLabsError(502) so signed requests and credentials are never sent over plaintext or to an attacker-influenced URL. The guard deliberately allows any bfl.ai subdomain because regional endpoints differ from the submission host.","triggerScenarios":"A BFL image/edit submission whose response contains a polling_url with http:// (or another scheme): typically a mock/stub server, a custom api_base proxy returning non-https URLs, or a tampered upstream response. The real api.bfl.ai always returns https URLs.","commonSituations":"Pointing api_base at a local test double for BFL, corporate proxies rewriting returned URLs to http, or an upstream that is not actually BFL.","solutions":["If you use a custom api_base/proxy for BFL, make every URL it returns (including polling_url) use https","Remove the custom api_base and call api.bfl.ai directly","If this fires against the real endpoint, treat it as a compromised or misrouted upstream and investigate the response source"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"from litellm.llms.black_forest_labs.common_utils import BlackForestLabsError\n\ntry:\n    img = litellm.image(model=\"bedrock/...\", ...)  # or the BFL image route\nexcept BlackForestLabsError as e:\n    if e.status_code == 502 and \"polling URL\" in str(e):\n        # server-controlled polling_url failed the https SSRF guard\n        log.error(\"BFL returned a non-https polling_url; check api_base/proxy integrity\")\n    raise","preventionTips":["Call BFL directly at https api.bfl.ai rather than through custom api_base proxies","If you stub BFL in tests, return https polling URLs on a bfl.ai host pattern","Never disable or catch-and-ignore the guard; a rejection means the response path is untrusted"],"tags":["bfl","flux","image-generation","ssrf","url-validation"],"backgroundTag":"ssrf-url-rejected","analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}