Accepted Input Formats
Input formats accepted by a self-hosted Roboflow Inference server, and how to disable the less secure ones such as pickled numpy payloads and URL image fetching.
Why this matters
The Inference server is designed to be straightforward to integrate, which is why some convenient but potentially less secure data loading methods are available. For production deployments, configuration options let you disable those behaviors.
This page explains how to configure the server to either harden it or enable more flexible behavior, depending on your needs.
Deserialization of pickled numpy objects
One way to send requests to the Inference server is with serialized numpy objects:
import cv2
import pickle
import requests
image = cv2.imread("...")
img_str = pickle.dumps(image)
infer_payload = {
"model_id": "{project_id}/{model_version}",
"image": {
"type": "numpy",
"value": img_str,
},
}
res = requests.post(
"http://localhost:9001/infer/{task}",
headers={"Authorization": "Bearer YOUR_API_KEY"},
json=infer_payload,
)Starting with version v0.14.0, deserialization of this payload type is disabled by default. You can enable it by setting ALLOW_NUMPY_INPUT=True. See the Inference CLI docs for how to run the server with that flag. This option is not available in Roboflow's hosted APIs.
Sending URLs to inference images
Fetching images from URLs is convenient, but it can expose the server to server-side request forgery (SSRF) attacks:
Inference can load images straight from a URL supplied in the request ({"image": {"type": "url", "value": "https://..."}}). Any time a server fetches a URL that a caller controls, the caller can try to steer it into making requests on their behalf, a class of attack called server-side request forgery (SSRF). Someone who cannot reach your internal network directly can ask your server to fetch, for example:
http://169.254.169.254/latest/meta-data/, the cloud metadata service (AWS, GCP, Azure), which can hand back instance credentials.http://127.0.0.1:9001/...and other localhost services: admin panels, databases, or the Inference server's own unauthenticated endpoints.http://10.0.0.5/,http://192.168.1.1/, and other private (RFC1918), link-local, CGNAT, or IPv6 ULA hosts that sit behind your perimeter.
A public-looking hostname is not proof of a public target: it may resolve to a private IP, redirect to one, or use DNS rebinding (resolve to a public IP for the validation check, then a private IP for the actual connection). Inference ships controls for all of these.
Turn URL input off if you don't need it
The strongest control is to not accept URL images at all. If your clients always send images as base64 or file uploads, disable URL fetching outright:
Harden URL input when you do need it
When URL images are required, these flags narrow what the server is allowed to fetch. Together they reject internal targets, pin the connection to the validated IP (defeating DNS rebinding), and re-check every redirect hop.
ALLOW_URL_INPUT
True
Master switch for URL image input. False rejects all URL images.
ALLOW_LOADING_IMAGES_FROM_LOCAL_FILESYSTEM
True
Set to False to disable local filesystem image loading.
ALLOW_URL_TO_NON_GLOBAL_ADDRESSES
True
When False, a URL whose host resolves to a non-global address (loopback, private, link-local/metadata, CGNAT, IPv6 ULA, and so on) is rejected, and the connection is pinned to the validated IP so a second DNS answer cannot swap the target.
VALIDATE_IMAGE_URL_REDIRECTS
False
When True, redirects are followed one hop at a time and each hop URL is re-validated, instead of being followed blindly.
MAX_IMAGE_URL_REDIRECTS
30
Hard cap on redirect hops, enforced regardless of the flag above.
ALLOW_NON_HTTPS_URL_INPUT
False
When False, only https:// URLs are accepted.
ALLOW_URL_INPUT_WITHOUT_FQDN
False
When False, URLs whose host is a bare IP or has no public suffix are rejected, so callers must use a real domain name.
WHITELISTED_DESTINATIONS_FOR_URL_INPUT
unset
Comma-separated allow-list of destinations (subdomain.domain.suffix). When set, only these are permitted.
BLACKLISTED_DESTINATIONS_FOR_URL_INPUT
unset
Comma-separated block-list of destinations that are always rejected.
A hardened configuration that still allows public HTTPS image URLs:
For the tightest control, add an allow-list so the server can only reach the exact hosts you serve images from:
For server-side video sources, see Video Configuration. Return to server security for network access and authentication.
Last updated
Was this helpful?