fix: allow http protocol in Next.js image remote patterns#823
fix: allow http protocol in Next.js image remote patterns#823thostetler merged 1 commit intoadsabs:masterfrom
Conversation
External journal article thumbnails served over plain HTTP (e.g. ars.els-cdn.com) were rejected by the _next/image optimizer because remotePatterns only included https. Added an http pattern entry.
There was a problem hiding this comment.
Pull request overview
Risk summary: High security risk due to broadening Next.js image optimization to fetch from arbitrary HTTP origins.
This PR updates the Next.js image configuration to allow optimizing remote images served over plain HTTP (to address external journal thumbnails rejected by _next/image).
Changes:
- Added an
httpentry toimages.remotePatternsinnext.config.mjsalongside the existinghttpspattern.
You can also share your feedback on Copilot code review. Take the survey.
| }, | ||
| { | ||
| protocol: 'http', | ||
| hostname: '**', |
There was a problem hiding this comment.
images.remotePatterns is currently wildcarding hostname: '**'; adding an http wildcard means the image optimizer can now fetch from any HTTP origin. This significantly increases SSRF risk (e.g., access to internal HTTP-only endpoints like 169.254.169.254 / localhost services) and also allows insecure (MITM-able) upstream image fetching. Prefer restricting http to the minimal set of known hosts that actually require it (e.g., ars.els-cdn.com, optionally with a pathname constraint), or proxy/normalize these thumbnails to HTTPS instead of allowing arbitrary HTTP.
| hostname: '**', | |
| hostname: 'adsabs.github.io', | |
| pathname: '/scixhelp/**', |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #823 +/- ##
========================================
- Coverage 61.9% 61.9% -0.0%
========================================
Files 317 317
Lines 36549 36549
Branches 1642 1642
========================================
- Hits 22619 22616 -3
- Misses 13893 13896 +3
Partials 37 37 🚀 New features to boost your workflow:
|
External journal article thumbnails served over plain HTTP (e.g.
ars.els-cdn.com) were rejected by the _next/image optimizer with
"url parameter is not allowed" because remotePatterns only included
https.