A marketplace on Cloudflare finds strangers using its /cdn-cgi/image/ URLs to transform photos hosted on other sites; why is that possible, and how do you lock it down?
answer
- who may be a source
- Sources: allowed origins vs any origin
- root domain excludes subdomains
- only the first URL is checked
- every unique transformation is billed
basics
~20 sThe zone's transformation Sources were most likely set to Any origin, so any public image can be transformed on the marketplace's bill. Switch back to allowed origins, list only real hosts, close their open redirects, and cap sizes with presets.
solid answer
~50 sUnder **Images > Transformations > Sources**, the default is **allowed origins**: the zone itself plus listed hosts. Most likely someone switched it to **Any origin**, so `shop.example/cdn-cgi/image/width=2000/https://elsewhere.example/pic.jpg` works for anyone, and each unique source-and-options pair is a billable transformation on the marketplace's account; on the Free plan new transformations start failing with 9422 once 5,000 are used. Switch back to allowed origins and add only the hosts that hold seller photos: `b.com` does not cover `media.b.com`, `*.b.com` covers both, and a Path narrows further. Only the initial URL is checked and redirects are followed, so an open redirect on an allowed host still lets foreign images in. Then cap the parameter space with a Worker that maps presets to sizes, layer WAF custom rules or rate limiting rules in front, and watch the transformation analytics for unexpected origin hosts.
go deeper
Recall that the Sources setting decides which hosts may supply images, and that allowed origins is the default.
Explain the matching rules: root versus subdomain, the wildcard form, path prefixes, and that redirects are followed after the first check.
Show the full diagnosis and fix: the Any origin switch, the unique-transformation bill or 9422 failures, analytics by origin host, presets in a Worker and edge rules.
Treat Sources as a reviewed control with a cost: who may change it, how temporary exceptions expire, and how abuse shows up in monitoring.
## Why strangers can do it A `/cdn-cgi/image/` URL names its own source: `https://<ZONE>/cdn-cgi/image/<OPTIONS>/<SOURCE-IMAGE>`, where the source may be an absolute URL on another host. What decides whether that foreign host is acceptable is the zone's **Sources** setting under **Images > Transformations**: | Accepted sources | Behaviour | |---|---| | **Allowed origins** (the default) | the zone itself, always, plus the hosts on the list | | **Any origin** | any publicly available image; the docs warn it is less secure and may let third parties serve transformations on your zone | When the marketplace finds outside sites' photos being resized on its domain, the setting has most likely been switched to Any origin, perhaps during a migration when photos briefly lived elsewhere; an over-broad wildcard or an open redirect on an allowed host are the other suspects. Switching to Any origin also **clears** the allowed list, so nobody can simply flip it back without re-adding the real origins. ## Why it costs money - Each distinct combination of source image and parameters requested in a calendar month is one **unique transformation**. Strangers choose both, so they can create as many as they like. - On the **Images Free plan**, after 5,000 unique transformations in a month, cached transformations keep working but new ones fail with **error 9422**, so the marketplace's own new listings stop getting thumbnails. - On the **Paid plan**, beyond the first 5,000, each further 1,000 unique transformations costs $0.50. ## Locking it down 1. **Return to allowed origins.** List only the hosts that really hold seller photos, such as the storage bucket's custom domain. The rules are exact: - adding the root `b.com` does **not** admit `media.b.com`; - adding `media.b.com` does not admit `b.com` or `cdn.b.com`; - `*.b.com` admits the root and all its subdomains; - an optional **Path** must match the start of the source path (`/themes` admits `b.com/themes/x.png`, not `b.com/media/themes/x.png`). Changes take effect immediately. 2. **Review allowed hosts for open redirects.** Only the **initial** source URL is checked; redirects are followed, even off your zone, and the final image is transformed. An allowed host with an open redirect endpoint is a way back in, so fix or exclude such endpoints. 3. **Shrink the parameter space.** Serve product photos through a Worker that maps a preset name (`thumb`, `card`, `zoom`) to fixed sizes with `fetch()`'s `cf.image`, validates the source host itself, and rejects anything else. The docs note that the allowed-origins setting also applies to requests from Workers and can conflict with a Worker's own source handling, so keep the two consistent. 4. **Add edge controls.** The Images docs point to WAF custom rules, rate limiting rules and Bot Management as further protection for image optimization requests. 5. **Watch the evidence.** Since 2026-09-23, transformation analytics under **Images & Stream > Transformations > Analytics** show sampled traffic with the top zones, transformation configurations and **origin hosts** for URL-based requests, and the top Worker scripts for binding requests. Origin hosts you do not recognise confirm the diagnosis; a flattening curve after the fix confirms the cure. ## A review checklist for the image pipeline After the incident, put these on the list a reviewer walks through whenever image settings change: - Sources is **allowed origins**, and every listed host has an owner and a reason. - No listed host exposes an open redirect, and wildcards such as `*.b.com` are used only where every subdomain is trusted. - Public pages reach images through presets, not free-form widths. - Analytics by origin host and configuration are checked after each release and alert on unknown hosts. - The monthly unique-transformation count is tracked against the plan, so a jump is noticed before error 9422 or a large invoice. ## What the fix does not change - Derivatives already in cache keep serving until they expire, and requests already counted this month stay counted. - Hosted images on `imagedelivery.net` are governed by variants and signed URLs, not by Sources; this setting protects remote-image transformations only. - Mitigation must not break legitimate traffic: before tightening, list every host the marketplace's own pages use as a source, including the hosts that older listings still reference. The lasting lesson is ownership. Sources is a zone-wide security setting with a cost attached, so treat a change to Any origin like any other control change: reviewed, recorded and reverted when the migration that needed it ends.
- Why do the abusers' requests keep counting even after the cached derivatives exist?They do not need cache misses to cost money: each new combination of source and options is a new unique transformation that month. Abusers vary the width or the source, so every variation is billed once, whether or not anyone requests it again.
- How do you tighten Sources without breaking the marketplace's own older listings?Inventory every host the pages use as a source first, from page templates and the transformation analytics' origin hosts, then add exactly those hosts, with wildcards or paths only where needed, before switching back to allowed origins. The change takes effect immediately, so verify a sample of listings right after.
- Does a Transform Rule that serves /images/ instead of /cdn-cgi/image/ close the hole?No. It only adds a friendlier path; `/cdn-cgi/image/` itself still answers on the zone. The Sources setting is what decides which source hosts are accepted.
- Believing Any origin is the default Sources setting
- Assuming an allowed root domain also covers its subdomains
- Assuming redirects from an allowed host are checked against the list
- Thinking hiding /cdn-cgi/image/ behind a Transform Rule stops abuse
- Expecting the Free plan to bill overage instead of failing new transformations
Assumes Cloudflare's platform as of 2026-10-10: transformation analytics showing top origin hosts and configurations were added on 2026-09-23; before that, finding the offending sources meant reading logs.