Repository navigation
Closed
Description
Summary
The Next.js image optimizer accepts any remote https host, but no product code uses it. Stop it from fetching remote hosts, so /_next/image cannot fetch and resize arbitrary images at our cost. Local images keep using /_next/image.
Benchmark
| Field | Value |
|---|---|
| Metric | Remote probe hosts for which /_next/image returns image bytes (count of 3). Also: entries in production images.remotePatterns (count). |
| Before | 2 of 2 probe hosts returned 200 image/png (638 B and 2,499 B), read 2026-11-11 on 0b302b222 in the v2.3.6 milestone review. Its 2 URLs are not in this issue, so the after uses the 3 fixed URLs below. Production images.remotePatterns: 3 entries (https **, two http loopback). On deploy day, before the push, the maintainer probes the 3 fixed URLs in How to run. The maintainer posts them in a Measured comment. |
| After | not measured yet |
| Condition | Production https://docs.plus, after the deploy. Same 3 remote URLs before and after. One machine, curl. Record the date, the deploy hash and who ran each probe. |
| How to run | Remote: curl -s -o /dev/null -w '%{http_code} %{content_type} %{size_download}\n' 'https://docs.plus/_next/image?url=<URL>&w=64&q=75', once for each fixed <URL>: https%3A%2F%2Fupload.wikimedia.org%2Fwikipedia%2Fcommons%2F4%2F47%2FPNG_transparency_demonstration_1.png, https%3A%2F%2Fwww.google.com%2Fimages%2Fbranding%2Fgooglelogo%2F2x%2Fgooglelogo_color_272x92dp.png and https%3A%2F%2Favatars.githubusercontent.com%2Fu%2F9919%3Fv%3D4. None of them is a docs.plus server. Local: the same with url=%2Fdemo-assets%2Fd0-intro.png&w=640&q=75. Code: grep -rln "next/image" apps/webapp/src | wc -l. |
| Pass rule | Remote probe: 400 for 3 of 3 hosts, 0 image bytes. Local probe: 200. Production remotePatterns: 0 entries. next/image imports under apps/webapp/src: 0. Revert if any page in the Guard row loses an image. |
| Guard | Home, /demo, a profile with an avatar, the chat image preview and /privacy show every image, in light and dark, at 390 px and 1280 px. |
| Owner | Agent in the repo: the edit and build:ci. Maintainer: the (build): front push, the probes and the Measured comment. |
| Claim | None for marketing; this is a security fix. Verification line: "/_next/image fetches 0 of 3 remote probe hosts (before: 2 of 2)." |
Facts (read from code, not measured)
apps/webapp/next.config.js:174-179sets the firstimages.remotePatternsentry toprotocol: 'https', hostname: '**', pathname: '/**'.apps/webapp/next.config.js:180-191adds twohttploopback entries (*.localhostand the loopback address). Production keeps them today.- No file under
apps/webapp/srcimportsnext/image(grep at0b302b222: 0 files). - The service worker keeps a same-origin
next-imagecache rule. It stays harmless once the route serves nothing remote.
Change
- Agent in the repo. Remove the
'**'entry atapps/webapp/next.config.js:174-179. - Agent in the repo. Keep the two
httploopback entries only whenprocess.env.NODE_ENV !== 'production'. ProductionremotePatternsis then empty. - Agent in the repo. CSP
img-srcstays as is. Pads load remote images as plain<img>, not through/_next/image.
If a later feature needs next/image for a remote host, add that one host then.
Decision
Ruled 2026-11-10: remove the '**' entry. Do not set images.unoptimized: true. See the maintainer ruling comment of 2026-11-10.
Acceptance
- Remote probe: 400 on 3 of 3 hosts, 0 image bytes.
- Local probe: 200.
- Production
remotePatterns: 0 entries (agent reads the built config). -
next/imageimports underapps/webapp/src: 0. - These pages show every image: Home,
/demo, a profile with an avatar, the chat image preview and/privacy. Check light and dark, at 390 px and 1280 px.- Signed-in hand check (profile avatar, chat image preview): not needed (review, 2026-11-16). No file under
apps/webapp/srcimportsnext/imageor names/_next/image(grep: 0 files), so neither can use the route.
- Signed-in hand check (profile avatar, chat image preview): not needed (review, 2026-11-16). No file under
-
build:cipasses before the push. - A
Measuredcomment posts the before and after probes, the date, the deploy hash and who ran them.
Rollback
Maintainer: restore the entry and push a (build): front tip.
Found by the proxy and cache map in the #242 architecture review (2026-10-26). Maintainer ruling, 2026-10-26: file it; do not build it in the #242 push.
Activity
HMarzban commentedon Nov 10, 2026
Maintainer ruling, 2026-11-10
Q1: remove the
'**'entry fromimages.remotePatterns. Answer: "agree".Do not set
images.unoptimized: true. Local images keep working through/_next/image. If a later feature needsnext/imagefor a remote host, add that one host then.[-]Turn off the Next.js image optimizer for remote hosts[/-][+]Stop /_next/image from fetching any remote host[/+]HMarzban commentedon Nov 14, 2026
Moved to v2.3.7 at the v2.3.6 release audit. The change has not shipped, and the before and after probes are not posted in a Measured comment.
fix(webapp): stop the image route fetching remote hosts
HMarzban commentedon Nov 16, 2026
Measured, 2026-11-16: production before and after
Commit
2033adf67: productionimages.remotePatternsis now empty; the two loopback hosts stay for local runs. Deployed with(build): front back(06f61ee44, run 43876524495, 2026-11-16 13:31Z).All probes: one laptop,
curl, the 3 fixed URLs from How to run, run by the agent.a3ef6e83f)build:ci,next start)06f61ee44)w=64image/png2,499 Bw=64image/png965 Bw=64image/png847 B/demo-assets/d0-intro.png,w=640image/png15,956 Bimage/png15,935 Bimage/png15,956 BremotePatternsentries.next/required-server-files.jsonof the local build)next/imageimports and/_next/imagestrings underapps/webapp/srcThe before is 3 of 3, not the issue's 2 of 2: the issue's earlier 2 URLs were not recorded, so this before uses the 3 fixed URLs.
Guard
/demoon production: 199<img>, 63 loaded after a full scroll, the rest lazy and not failed. 1 broken: the link icon forgithub-login.example.net, a fake demo domain served by/api/metadata/icon, not the image route. 0 images use/_next/image./privacy: 0<img>in the server HTML; 0 use/_next/image./_next/image, so the change cannot remove a picture. The light and dark, 390 px and 1280 px browser pass, the profile avatar and the chat image preview were not checked by hand.Gates
build:cipassed. Prettier passed.All acceptance boxes are met except the hand browser pass named above.
HMarzban commentedon Nov 16, 2026
Measured, 2026-11-16: the browser guard
Production
https://docs.plus/demoafter the deploy (06f61ee44), in a visible browser tab, signed out. Each case loaded the page, scrolled it to the end, waited 4 s, and counted every non-data:<img>.docsplus)docsplus-dark, andprefers-color-scheme: dark)github-login.example.net, a fake demo domain, served by/api/metadata/icon. It is not the image route, and it was broken before this change too./_next/image./_next/image, because no file underapps/webapp/srcimportsnext/imageor names the route.With the production probes posted earlier, every acceptance box is met except that signed-in hand check.
docs(changelog): record the v2.3.7 work of 2026-11-16
HMarzban commentedon Nov 16, 2026
Review, 2026-11-16 (maintainer approved).
Closed: the fix is live and every check passed. Commit
2033adf67shipped in(build): front back(06f61ee44, run 43876524495). The 2026-11-16 Measured comments show remote probes at 3 of 3 before and 0 of 3 after, with 400 and 30 B on each host. ProductionremotePatternswent from 3 entries to 0, and the local probe still answers 200. The browser guard on/demopassed at 390 px and 1280 px, in light and dark. The signed-in hand check is not needed: no file underapps/webapp/srcimportsnext/imageor names/_next/image(grep: 0 files). The body now says so. The #796 row stays as filed.