Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/image.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,12 @@ export default class Image {
}

if(this.isRemoteUrl) {
// SSRF protection: block requests to private/internal IP ranges
const { hostname } = new URL(src);
if (/^(localhost|.*\.local)$/.test(hostname) || hostname === "::1" || /^(127\.|10\.|192\.168\.|169\.254\.|172\.(1[6-9]|2\d|3[01])\.)/.test(hostname)) {
throw new Error(`[eleventy-img] Fetching from private/internal network addresses is not allowed: ${hostname}`);
}

this.cacheOptions = Object.assign({
type: "buffer",
// deprecated in Eleventy Image, but we already prefer this.cacheOptions.duration automatically
Expand Down