matej@portfolio ~/blog

published ·

One missing hostname: debugging failed ChatGPT uploads in Konvertira

Some files sent from ChatGPT to Konvertira failed instantly while others worked. One log line revealed the cause: the download allowlist knew only one Azure region. Here is what the request and the log showed, and how I fixed it.

Cover image for One missing hostname: debugging failed ChatGPT uploads in Konvertira

A few days ago some of those requests started failing instantly. Not all of them, only some.

How a file reaches the server

ChatGPT doesn't send the file itself. It sends a short-lived signed link to the file in OpenAI's Azure storage:

{
  "file_name": "photo.jpg",
  "mime_type": "image/jpeg",
  "download_url": "https://oaisdmntprdenmarkeast.blob.core.windows.net/files/...?sig=..."
}

The server downloads the file from that link, processes it and returns a new download link.

Downloading from a URL a client sends you is risky. Without limits, anyone could make the server fetch arbitrary addresses, an attack known as SSRF. So the server only downloads from an allowlist of known hostnames.

What the logs said

The answer was right there in the MCP container's logs (docker logs konvertira-mcp-1):

operation_failed {"operation":"download_openai_file","stage":"url_validation", ... "status_code":400}
ValueError: Disallowed download host: oaisdmntprdenmarkeast.blob.core.windows.net
  • stage: url_validation: the request failed on the URL check, before anything was downloaded.
  • Disallowed download host: the hostname wasn't on the allowlist.

The cause

The allowlist had exactly one storage account: oaisdmntprnortheu (North Europe). ChatGPT had started storing some uploads in another region, Denmark East (oaisdmntprdenmarkeast). Uploads still stored in North Europe worked. Uploads stored in Denmark East were rejected.

The code was working as designed. The allowlist was simply too narrow.

The fix

Right away: the allowlist is read from an environment variable, so I added the new host to the server's .env and recreated the container. No rebuild needed. Note that a plain docker restart doesn't reload .env, so the container has to be recreated.

Permanently: the code default now covers ChatGPT's upload accounts in every Azure region in Europe, so the next region change won't break uploads again.

I deliberately didn't allow all of *.blob.core.windows.net. Anyone can create a storage account on that domain, so a wildcard would undo the protection. The allowlist stays a list of exact hostnames.