Skip to content

Open-source platform for 3D AI agents. Turn text or a photo into a rigged, animated GLB avatar, give it an LLM brain, memory and a wallet, and embed it anywhere with one web component. Remote MCP server, x402 payments, Three.js, browser-native.

fix(ssrf): classify IPv6 by the address it reaches, not by how it is spelled

nirholas36984db00532
diff --git a/api/_lib/ip-classify.js b/api/_lib/ip-classify.js
new file mode 100644
index 000000000..1e41a6f5b
--- /dev/null
+++ b/api/_lib/ip-classify.js
@@ -0,0 +1,99 @@
+// Address classification shared by every SSRF guard (api/_lib/ssrf.js,
+// api/_lib/ssrf-guard.js and the callers that pre-check literal hosts).
+// Dependency-free on purpose so any guard can import it without pulling in a
+// network stack, and so a test that mocks one guard module cannot silently
+// change how another guard classifies an address.
+
+export function isPrivateIPv4(ip) {
+ const p = ip.split('.').map(Number);
+ if (p.length !== 4 || p.some((n) => !Number.isInteger(n) || n < 0 || n > 255)) return true;
+ if (p[0] === 10) return true;
+ if (p[0] === 127) return true;
+ if (p[0] === 0) return true;
+ if (p[0] === 169 && p[1] === 254) return true; // link-local, cloud metadata
+ if (p[0] === 100 && p[1] >= 64 && p[1] <= 127) return true; // CGNAT 100.64.0.0/10 (incl. Alibaba metadata 100.100.100.200)
+ if (p[0] === 172 && p[1] >= 16 && p[1] <= 31) return true;
+ if (p[0] === 192 && p[1] === 168) return true;
+ if (p[0] === 192 && p[1] === 0 && p[2] === 0) return true; // IETF
+ if (p[0] === 192 && p[1] === 0 && p[2] === 2) return true; // docs
+ if (p[0] === 198 && (p[1] === 18 || p[1] === 19)) return true; // benchmark
+ if (p[0] === 198 && p[1] === 51 && p[2] === 100) return true; // docs
+ if (p[0] === 203 && p[1] === 0 && p[2] === 113) return true; // docs
+ if (p[0] >= 224) return true; // multicast + reserved
+ return false;
+}
+
+// Expand any textual IPv6 form (compressed `::`, embedded dotted IPv4 tail,
+// zone id, brackets) to its eight 16-bit groups. Returns null when the text is
+// not a valid IPv6 address. Prefix checks run on the numeric groups, never on
+// the string, because the same address has many spellings: `::ffff:127.0.0.1`
+// and `::ffff:7f00:1` are one address, and a string-prefix test that only knows
+// the dotted spelling lets the hex one through to loopback.
+export function parseIPv6Groups(ip) {
+ let s = String(ip).trim().toLowerCase().replace(/^\[|\]$/g, '');
+ const zone = s.indexOf('%');
+ if (zone !== -1) s = s.slice(0, zone);
+ let tail = [];
+ const dotted = s.match(/^(.*:)(\d{1,3}(?:\.\d{1,3}){3})$/);
+ if (dotted) {
+ const octets = dotted[2].split('.').map(Number);
+ if (octets.some((n) => n > 255)) return null;
+ tail = [(octets[0] << 8) | octets[1], (octets[2] << 8) | octets[3]];
+ s = dotted[1].endsWith('::') ? dotted[1] : dotted[1].slice(0, -1);
+ }
+ const halves = s.split('::');
+ if (halves.length > 2) return null;
+ const toGroups = (part) => (part ? part.split(':') : []);
+ const head = toGroups(halves[0]);
+ const rest = halves.length === 2 ? toGroups(halves[1]) : [];
+ const words = [...head, ...rest];
+ if (words.some((w) => !/^[0-9a-f]{1,4}$/.test(w))) return null;
+ const explicit = words.length + tail.length;
+ if (halves.length === 1 && explicit !== 8) return null;
+ if (halves.length === 2 && explicit > 7) return null;
+ const fill = new Array(8 - explicit).fill(0);
+ const groups = [
+ ...head.map((w) => parseInt(w, 16)),
+ ...(halves.length === 2 ? fill : []),
+ ...rest.map((w) => parseInt(w, 16)),
+ ...tail,
+ ];
+ return groups.length === 8 ? groups : null;
+}
+
+function embeddedIPv4(hi, lo) {
+ return `${hi >> 8}.${hi & 0xff}.${lo >> 8}.${lo & 0xff}`;
+}
+
+export function isPrivateIPv6(ip) {
+ const g = parseIPv6Groups(ip);
+ if (!g) return true; // unparseable: refuse rather than guess
+ const zeroPrefix = (n) => g.slice(0, n).every((w) => w === 0);
+ // ::/96 covers ::, ::1 and the deprecated IPv4-compatible ::a.b.c.d form.
+ if (zeroPrefix(6)) {
+ if (g[6] === 0 && g[7] <= 1) return true;
+ return isPrivateIPv4(embeddedIPv4(g[6], g[7]));
+ }
+ // ::ffff:0:0/96 IPv4-mapped, any spelling (::ffff:7f00:1 is 127.0.0.1).
+ if (zeroPrefix(5) && g[5] === 0xffff) return isPrivateIPv4(embeddedIPv4(g[6], g[7]));
+ // ::ffff:0:0:0/96 IPv4-translated (RFC 2765).
+ if (zeroPrefix(4) && g[4] === 0xffff && g[5] === 0) {
+ return isPrivateIPv4(embeddedIPv4(g[6], g[7]));
+ }
+ // 64:ff9b::/96 well-known NAT64 prefix: the IPv4 tail is what a NAT64
+ // gateway actually dials, so it gets the IPv4 verdict.
+ if (g[0] === 0x64 && g[1] === 0xff9b && g.slice(2, 6).every((w) => w === 0)) {
+ return isPrivateIPv4(embeddedIPv4(g[6], g[7]));
+ }
+ if (g[0] === 0x64 && g[1] === 0xff9b && g[2] === 1) return true; // 64:ff9b:1::/48 local-use NAT64
+ // 2002::/16 6to4 carries an IPv4 address in groups 1-2.
+ if (g[0] === 0x2002) return isPrivateIPv4(embeddedIPv4(g[1], g[2]));
+ if (g[0] === 0x2001 && g[1] === 0) return true; // 2001::/32 Teredo (obfuscated IPv4 inside)
+ if (g[0] === 0x2001 && g[1] === 0xdb8) return true; // 2001:db8::/32 documentation
+ if (g[0] === 0x100 && g[1] === 0 && g[2] === 0 && g[3] === 0) return true; // 100::/64 discard
+ if ((g[0] & 0xffc0) === 0xfe80) return true; // fe80::/10 link-local
+ if ((g[0] & 0xffc0) === 0xfec0) return true; // fec0::/10 deprecated site-local
+ if ((g[0] & 0xfe00) === 0xfc00) return true; // fc00::/7 ULA (incl. fd00:ec2::254 IMDS)
+ if ((g[0] & 0xff00) === 0xff00) return true; // ff00::/8 multicast
+ return false;
+}
diff --git a/api/_lib/ssrf-guard.js b/api/_lib/ssrf-guard.js
index b823dd61b..247a24d49 100644
--- a/api/_lib/ssrf-guard.js
+++ b/api/_lib/ssrf-guard.js
@@ -17,6 +17,7 @@ import { promises as dns } from 'node:dns';
import net from 'node:net';
import https from 'node:https';
import http from 'node:http';
+import { isPrivateIPv6 as isPrivateIPv6Shared } from './ip-classify.js';
// Cloud metadata services we never want a server-side fetch to reach.
const METADATA_IPS = new Set([
@@ -40,18 +41,12 @@ function isPrivateIPv4(ip) {
return false;
}
+// IPv6 classification is shared with api/_lib/ssrf.js via api/_lib/ip-classify.js,
+// which parses the address into numeric groups so every spelling of an
+// IPv4-mapped, NAT64, 6to4 or IPv4-compatible address is judged by the IPv4 it
+// actually reaches.
function isPrivateIPv6(ip) {
- const lower = ip.toLowerCase();
- if (lower === '::1' || lower === '::' || lower === '0:0:0:0:0:0:0:1') return true; // loopback / unspecified
- if (lower.startsWith('fe80:') || lower.startsWith('fe8') || lower.startsWith('fe9') ||
- lower.startsWith('fea') || lower.startsWith('feb')) return true; // link-local fe80::/10
- if (lower.startsWith('fc') || lower.startsWith('fd')) return true; // unique-local fc00::/7
- if (lower.startsWith('ff')) return true; // multicast ff00::/8
- if (lower.startsWith('::ffff:')) {
- const v4 = lower.slice(7);
- return isPrivateIPv4(v4);
- }
- return false;
+ return isPrivateIPv6Shared(ip);
}
function isBlockedAddress(ip) {
diff --git a/api/_lib/ssrf.js b/api/_lib/ssrf.js
index 64dab96de..290bece6d 100644
--- a/api/_lib/ssrf.js
+++ b/api/_lib/ssrf.js
@@ -14,6 +14,9 @@
import { lookup } from 'node:dns/promises';
import { Agent } from 'undici';
+import { isPrivateIPv4, isPrivateIPv6 } from './ip-classify.js';
+
+export { isPrivateIPv4, isPrivateIPv6, parseIPv6Groups } from './ip-classify.js';
const IS_DEV = process.env.NODE_ENV !== 'production';
@@ -25,45 +28,6 @@ export class SsrfError extends Error {
}
}
-export function isPrivateIPv4(ip) {
- const p = ip.split('.').map(Number);
- if (p.length !== 4 || p.some((n) => Number.isNaN(n))) return true;
- if (p[0] === 10) return true;
- if (p[0] === 127) return true;
- if (p[0] === 0) return true;
- if (p[0] === 169 && p[1] === 254) return true; // link-local, cloud metadata
- if (p[0] === 100 && p[1] >= 64 && p[1] <= 127) return true; // CGNAT 100.64.0.0/10 (incl. Alibaba metadata 100.100.100.200)
- if (p[0] === 172 && p[1] >= 16 && p[1] <= 31) return true;
- if (p[0] === 192 && p[1] === 168) return true;
- if (p[0] === 192 && p[1] === 0 && p[2] === 0) return true; // IETF
- if (p[0] === 192 && p[1] === 0 && p[2] === 2) return true; // docs
- if (p[0] === 198 && (p[1] === 18 || p[1] === 19)) return true; // benchmark
- if (p[0] === 198 && p[1] === 51 && p[2] === 100) return true; // docs
- if (p[0] === 203 && p[1] === 0 && p[2] === 113) return true; // docs
- if (p[0] >= 224) return true; // multicast + reserved
- return false;
-}
-
-export function isPrivateIPv6(ip) {
- const lower = ip.toLowerCase();
- if (lower === '::' || lower === '::1' || lower === '0:0:0:0:0:0:0:1') return true;
- if (
- lower.startsWith('fe8') ||
- lower.startsWith('fe9') ||
- lower.startsWith('fea') ||
- lower.startsWith('feb')
- )
- return true; // link-local fe80::/10
- if (lower.startsWith('fc') || lower.startsWith('fd')) return true; // ULA fc00::/7
- if (lower.startsWith('ff')) return true; // multicast ff00::/8
- if (lower.startsWith('::ffff:')) {
- const mapped = lower.replace(/^::ffff:/, '');
- if (/^\d+\.\d+\.\d+\.\d+$/.test(mapped)) return isPrivateIPv4(mapped);
- }
- if (lower.startsWith('2001:db8:')) return true; // docs
- return false;
-}
-
export function isPrivateAddress(address, family) {
if (family === 4) return isPrivateIPv4(address);
if (family === 6) return isPrivateIPv6(address);
diff --git a/api/avatars/_actions.js b/api/avatars/_actions.js
index 3afa1e2c2..9d4440fb4 100644
--- a/api/avatars/_actions.js
+++ b/api/avatars/_actions.js
@@ -15,6 +15,7 @@ import { requireCsrf } from '../_lib/csrf.js';
import { z } from 'zod';
import { randomUUID } from 'crypto';
import { isValidGlbHeader } from '../_lib/glb-inspect.js';
+import { isPrivateIPv4, isPrivateIPv6 } from '../_lib/ip-classify.js';
import { getRegenProviderCandidates, getRegenProviderByName, getRegenProviderForJob, BYOK_REGEN_PROVIDERS } from '../_lib/regen-provider.js';
import { resolveProviderKey } from '../_lib/forge-provider-key.js';
import { finalizeReconstructStage, pollRiggingStage } from '../_lib/reconstruct-finalize.js';
@@ -335,26 +336,12 @@ async function assertPublicHost(hostname) {
}
}
+// Shared classifier (api/_lib/ip-classify.js): a hand-rolled copy here only
+// recognised the dotted `::ffff:a.b.c.d` spelling, so `[::ffff:7f00:1]` (the
+// same loopback address, in the form the URL parser itself normalizes to)
+// sailed through to the fetch.
function isPrivateAddress(ip) {
- if (ip.includes(':')) {
- const v6 = ip.toLowerCase();
- if (v6 === '::1' || v6 === '::') return true;
- if (v6.startsWith('fe80') || v6.startsWith('fc') || v6.startsWith('fd')) return true;
- // IPv4-mapped IPv6 (::ffff:a.b.c.d) — unwrap and re-check.
- const mapped = v6.match(/::ffff:(\d+\.\d+\.\d+\.\d+)$/);
- if (mapped) return isPrivateAddress(mapped[1]);
- return false;
- }
- const p = ip.split('.').map(Number);
- if (p.length !== 4 || p.some((n) => !Number.isInteger(n) || n < 0 || n > 255)) return true;
- const [a, b] = p;
- if (a === 0 || a === 10 || a === 127) return true;
- if (a === 169 && b === 254) return true; // link-local incl. 169.254.169.254 metadata
- if (a === 172 && b >= 16 && b <= 31) return true;
- if (a === 192 && b === 168) return true;
- if (a === 100 && b >= 64 && b <= 127) return true; // CGNAT
- if (a >= 224) return true; // multicast / reserved
- return false;
+ return ip.includes(':') ? isPrivateIPv6(ip) : isPrivateIPv4(ip);
}
function readRawBody(req, limit) {
diff --git a/workers/avatar-pipeline-controller/worker_security.py b/workers/avatar-pipeline-controller/worker_security.py
index 1e569c4e2..b1c4dd4cd 100644
--- a/workers/avatar-pipeline-controller/worker_security.py
+++ b/workers/avatar-pipeline-controller/worker_security.py
@@ -64,7 +64,8 @@ def _is_blocked_ip(ip: ipaddress._BaseAddress) -> bool:
Covers loopback, RFC1918 private ranges, link-local (incl. the cloud
metadata server at 169.254.169.254), unique-local IPv6 (fc00::/7),
- multicast, reserved, and unspecified addresses. IPv4-mapped IPv6 addresses
+ multicast, reserved, unspecified, and any other non-global address (CGNAT
+ 100.64.0.0/10 included). IPv4-mapped IPv6 addresses
are unwrapped first so a mapped private v4 can't slip through.
"""
if isinstance(ip, ipaddress.IPv6Address) and ip.ipv4_mapped is not None:
@@ -76,6 +77,9 @@ def _is_blocked_ip(ip: ipaddress._BaseAddress) -> bool:
or ip.is_multicast
or ip.is_reserved
or ip.is_unspecified
+ # Anything not globally routable, which also covers the CGNAT shared
+ # space 100.64.0.0/10 that is_private does not flag.
+ or not ip.is_global
)
diff --git a/workers/avatar-reconstruction/worker_security.py b/workers/avatar-reconstruction/worker_security.py
index 1e569c4e2..b1c4dd4cd 100644
--- a/workers/avatar-reconstruction/worker_security.py
+++ b/workers/avatar-reconstruction/worker_security.py
@@ -64,7 +64,8 @@ def _is_blocked_ip(ip: ipaddress._BaseAddress) -> bool:
Covers loopback, RFC1918 private ranges, link-local (incl. the cloud
metadata server at 169.254.169.254), unique-local IPv6 (fc00::/7),
- multicast, reserved, and unspecified addresses. IPv4-mapped IPv6 addresses
+ multicast, reserved, unspecified, and any other non-global address (CGNAT
+ 100.64.0.0/10 included). IPv4-mapped IPv6 addresses
are unwrapped first so a mapped private v4 can't slip through.
"""
if isinstance(ip, ipaddress.IPv6Address) and ip.ipv4_mapped is not None:
@@ -76,6 +77,9 @@ def _is_blocked_ip(ip: ipaddress._BaseAddress) -> bool:
or ip.is_multicast
or ip.is_reserved
or ip.is_unspecified
+ # Anything not globally routable, which also covers the CGNAT shared
+ # space 100.64.0.0/10 that is_private does not flag.
+ or not ip.is_global
)
diff --git a/workers/garment-forge/worker_security.py b/workers/garment-forge/worker_security.py
index 1e569c4e2..b1c4dd4cd 100644
--- a/workers/garment-forge/worker_security.py
+++ b/workers/garment-forge/worker_security.py
@@ -64,7 +64,8 @@ def _is_blocked_ip(ip: ipaddress._BaseAddress) -> bool:
Covers loopback, RFC1918 private ranges, link-local (incl. the cloud
metadata server at 169.254.169.254), unique-local IPv6 (fc00::/7),
- multicast, reserved, and unspecified addresses. IPv4-mapped IPv6 addresses
+ multicast, reserved, unspecified, and any other non-global address (CGNAT
+ 100.64.0.0/10 included). IPv4-mapped IPv6 addresses
are unwrapped first so a mapped private v4 can't slip through.
"""
if isinstance(ip, ipaddress.IPv6Address) and ip.ipv4_mapped is not None:
@@ -76,6 +77,9 @@ def _is_blocked_ip(ip: ipaddress._BaseAddress) -> bool:
or ip.is_multicast
or ip.is_reserved
or ip.is_unspecified
+ # Anything not globally routable, which also covers the CGNAT shared
+ # space 100.64.0.0/10 that is_private does not flag.
+ or not ip.is_global
)
diff --git a/workers/longcat/worker_security.py b/workers/longcat/worker_security.py
index 1e569c4e2..b1c4dd4cd 100644
--- a/workers/longcat/worker_security.py
+++ b/workers/longcat/worker_security.py
@@ -64,7 +64,8 @@ def _is_blocked_ip(ip: ipaddress._BaseAddress) -> bool:
Covers loopback, RFC1918 private ranges, link-local (incl. the cloud
metadata server at 169.254.169.254), unique-local IPv6 (fc00::/7),
- multicast, reserved, and unspecified addresses. IPv4-mapped IPv6 addresses
+ multicast, reserved, unspecified, and any other non-global address (CGNAT
+ 100.64.0.0/10 included). IPv4-mapped IPv6 addresses
are unwrapped first so a mapped private v4 can't slip through.
"""
if isinstance(ip, ipaddress.IPv6Address) and ip.ipv4_mapped is not None:
@@ -76,6 +77,9 @@ def _is_blocked_ip(ip: ipaddress._BaseAddress) -> bool:
or ip.is_multicast
or ip.is_reserved
or ip.is_unspecified
+ # Anything not globally routable, which also covers the CGNAT shared
+ # space 100.64.0.0/10 that is_private does not flag.
+ or not ip.is_global
)
diff --git a/workers/model-hunyuan3d/worker_security.py b/workers/model-hunyuan3d/worker_security.py
index 1e569c4e2..b1c4dd4cd 100644
--- a/workers/model-hunyuan3d/worker_security.py
+++ b/workers/model-hunyuan3d/worker_security.py
@@ -64,7 +64,8 @@ def _is_blocked_ip(ip: ipaddress._BaseAddress) -> bool:
Covers loopback, RFC1918 private ranges, link-local (incl. the cloud
metadata server at 169.254.169.254), unique-local IPv6 (fc00::/7),
- multicast, reserved, and unspecified addresses. IPv4-mapped IPv6 addresses
+ multicast, reserved, unspecified, and any other non-global address (CGNAT
+ 100.64.0.0/10 included). IPv4-mapped IPv6 addresses
are unwrapped first so a mapped private v4 can't slip through.
"""
if isinstance(ip, ipaddress.IPv6Address) and ip.ipv4_mapped is not None:
@@ -76,6 +77,9 @@ def _is_blocked_ip(ip: ipaddress._BaseAddress) -> bool:
or ip.is_multicast
or ip.is_reserved
or ip.is_unspecified
+ # Anything not globally routable, which also covers the CGNAT shared
+ # space 100.64.0.0/10 that is_private does not flag.
+ or not ip.is_global
)
diff --git a/workers/model-text2motion/worker_security.py b/workers/model-text2motion/worker_security.py
index 1e569c4e2..b1c4dd4cd 100644
--- a/workers/model-text2motion/worker_security.py
+++ b/workers/model-text2motion/worker_security.py
@@ -64,7 +64,8 @@ def _is_blocked_ip(ip: ipaddress._BaseAddress) -> bool:
Covers loopback, RFC1918 private ranges, link-local (incl. the cloud
metadata server at 169.254.169.254), unique-local IPv6 (fc00::/7),
- multicast, reserved, and unspecified addresses. IPv4-mapped IPv6 addresses
+ multicast, reserved, unspecified, and any other non-global address (CGNAT
+ 100.64.0.0/10 included). IPv4-mapped IPv6 addresses
are unwrapped first so a mapped private v4 can't slip through.
"""
if isinstance(ip, ipaddress.IPv6Address) and ip.ipv4_mapped is not None:
@@ -76,6 +77,9 @@ def _is_blocked_ip(ip: ipaddress._BaseAddress) -> bool:
or ip.is_multicast
or ip.is_reserved
or ip.is_unspecified
+ # Anything not globally routable, which also covers the CGNAT shared
+ # space 100.64.0.0/10 that is_private does not flag.
+ or not ip.is_global
)
diff --git a/workers/model-trellis/worker_security.py b/workers/model-trellis/worker_security.py
index 1e569c4e2..b1c4dd4cd 100644
--- a/workers/model-trellis/worker_security.py
+++ b/workers/model-trellis/worker_security.py
@@ -64,7 +64,8 @@ def _is_blocked_ip(ip: ipaddress._BaseAddress) -> bool:
Covers loopback, RFC1918 private ranges, link-local (incl. the cloud
metadata server at 169.254.169.254), unique-local IPv6 (fc00::/7),
- multicast, reserved, and unspecified addresses. IPv4-mapped IPv6 addresses
+ multicast, reserved, unspecified, and any other non-global address (CGNAT
+ 100.64.0.0/10 included). IPv4-mapped IPv6 addresses
are unwrapped first so a mapped private v4 can't slip through.
"""
if isinstance(ip, ipaddress.IPv6Address) and ip.ipv4_mapped is not None:
@@ -76,6 +77,9 @@ def _is_blocked_ip(ip: ipaddress._BaseAddress) -> bool:
or ip.is_multicast
or ip.is_reserved
or ip.is_unspecified
+ # Anything not globally routable, which also covers the CGNAT shared
+ # space 100.64.0.0/10 that is_private does not flag.
+ or not ip.is_global
)
diff --git a/workers/model-triposg/worker_security.py b/workers/model-triposg/worker_security.py
index 1e569c4e2..b1c4dd4cd 100644
--- a/workers/model-triposg/worker_security.py
+++ b/workers/model-triposg/worker_security.py
@@ -64,7 +64,8 @@ def _is_blocked_ip(ip: ipaddress._BaseAddress) -> bool:
Covers loopback, RFC1918 private ranges, link-local (incl. the cloud
metadata server at 169.254.169.254), unique-local IPv6 (fc00::/7),
- multicast, reserved, and unspecified addresses. IPv4-mapped IPv6 addresses
+ multicast, reserved, unspecified, and any other non-global address (CGNAT
+ 100.64.0.0/10 included). IPv4-mapped IPv6 addresses
are unwrapped first so a mapped private v4 can't slip through.
"""
if isinstance(ip, ipaddress.IPv6Address) and ip.ipv4_mapped is not None:
@@ -76,6 +77,9 @@ def _is_blocked_ip(ip: ipaddress._BaseAddress) -> bool:
or ip.is_multicast
or ip.is_reserved
or ip.is_unspecified
+ # Anything not globally routable, which also covers the CGNAT shared
+ # space 100.64.0.0/10 that is_private does not flag.
+ or not ip.is_global
)
diff --git a/workers/model-triposr/worker_security.py b/workers/model-triposr/worker_security.py
index 1e569c4e2..b1c4dd4cd 100644
--- a/workers/model-triposr/worker_security.py
+++ b/workers/model-triposr/worker_security.py
@@ -64,7 +64,8 @@ def _is_blocked_ip(ip: ipaddress._BaseAddress) -> bool:
Covers loopback, RFC1918 private ranges, link-local (incl. the cloud
metadata server at 169.254.169.254), unique-local IPv6 (fc00::/7),
- multicast, reserved, and unspecified addresses. IPv4-mapped IPv6 addresses
+ multicast, reserved, unspecified, and any other non-global address (CGNAT
+ 100.64.0.0/10 included). IPv4-mapped IPv6 addresses
are unwrapped first so a mapped private v4 can't slip through.
"""
if isinstance(ip, ipaddress.IPv6Address) and ip.ipv4_mapped is not None:
@@ -76,6 +77,9 @@ def _is_blocked_ip(ip: ipaddress._BaseAddress) -> bool:
or ip.is_multicast
or ip.is_reserved
or ip.is_unspecified
+ # Anything not globally routable, which also covers the CGNAT shared
+ # space 100.64.0.0/10 that is_private does not flag.
+ or not ip.is_global
)
diff --git a/workers/model-video2motion/worker_security.py b/workers/model-video2motion/worker_security.py
index 1e569c4e2..b1c4dd4cd 100644
--- a/workers/model-video2motion/worker_security.py
+++ b/workers/model-video2motion/worker_security.py
@@ -64,7 +64,8 @@ def _is_blocked_ip(ip: ipaddress._BaseAddress) -> bool:
Covers loopback, RFC1918 private ranges, link-local (incl. the cloud
metadata server at 169.254.169.254), unique-local IPv6 (fc00::/7),
- multicast, reserved, and unspecified addresses. IPv4-mapped IPv6 addresses
+ multicast, reserved, unspecified, and any other non-global address (CGNAT
+ 100.64.0.0/10 included). IPv4-mapped IPv6 addresses
are unwrapped first so a mapped private v4 can't slip through.
"""
if isinstance(ip, ipaddress.IPv6Address) and ip.ipv4_mapped is not None:
@@ -76,6 +77,9 @@ def _is_blocked_ip(ip: ipaddress._BaseAddress) -> bool:
or ip.is_multicast
or ip.is_reserved
or ip.is_unspecified
+ # Anything not globally routable, which also covers the CGNAT shared
+ # space 100.64.0.0/10 that is_private does not flag.
+ or not ip.is_global
)
diff --git a/workers/model-video2scene/worker_security.py b/workers/model-video2scene/worker_security.py
index 1e569c4e2..b1c4dd4cd 100644
--- a/workers/model-video2scene/worker_security.py
+++ b/workers/model-video2scene/worker_security.py
@@ -64,7 +64,8 @@ def _is_blocked_ip(ip: ipaddress._BaseAddress) -> bool:
Covers loopback, RFC1918 private ranges, link-local (incl. the cloud
metadata server at 169.254.169.254), unique-local IPv6 (fc00::/7),
- multicast, reserved, and unspecified addresses. IPv4-mapped IPv6 addresses
+ multicast, reserved, unspecified, and any other non-global address (CGNAT
+ 100.64.0.0/10 included). IPv4-mapped IPv6 addresses
are unwrapped first so a mapped private v4 can't slip through.
"""
if isinstance(ip, ipaddress.IPv6Address) and ip.ipv4_mapped is not None:
@@ -76,6 +77,9 @@ def _is_blocked_ip(ip: ipaddress._BaseAddress) -> bool:
or ip.is_multicast
or ip.is_reserved
or ip.is_unspecified
+ # Anything not globally routable, which also covers the CGNAT shared
+ # space 100.64.0.0/10 that is_private does not flag.
+ or not ip.is_global
)
diff --git a/workers/rembg/worker_security.py b/workers/rembg/worker_security.py
index 1e569c4e2..b1c4dd4cd 100644
--- a/workers/rembg/worker_security.py
+++ b/workers/rembg/worker_security.py
@@ -64,7 +64,8 @@ def _is_blocked_ip(ip: ipaddress._BaseAddress) -> bool:
Covers loopback, RFC1918 private ranges, link-local (incl. the cloud
metadata server at 169.254.169.254), unique-local IPv6 (fc00::/7),
- multicast, reserved, and unspecified addresses. IPv4-mapped IPv6 addresses
+ multicast, reserved, unspecified, and any other non-global address (CGNAT
+ 100.64.0.0/10 included). IPv4-mapped IPv6 addresses
are unwrapped first so a mapped private v4 can't slip through.
"""
if isinstance(ip, ipaddress.IPv6Address) and ip.ipv4_mapped is not None:
@@ -76,6 +77,9 @@ def _is_blocked_ip(ip: ipaddress._BaseAddress) -> bool:
or ip.is_multicast
or ip.is_reserved
or ip.is_unspecified
+ # Anything not globally routable, which also covers the CGNAT shared
+ # space 100.64.0.0/10 that is_private does not flag.
+ or not ip.is_global
)
diff --git a/workers/remesh/worker_security.py b/workers/remesh/worker_security.py
index 1e569c4e2..b1c4dd4cd 100644
--- a/workers/remesh/worker_security.py
+++ b/workers/remesh/worker_security.py
@@ -64,7 +64,8 @@ def _is_blocked_ip(ip: ipaddress._BaseAddress) -> bool:
Covers loopback, RFC1918 private ranges, link-local (incl. the cloud
metadata server at 169.254.169.254), unique-local IPv6 (fc00::/7),
- multicast, reserved, and unspecified addresses. IPv4-mapped IPv6 addresses
+ multicast, reserved, unspecified, and any other non-global address (CGNAT
+ 100.64.0.0/10 included). IPv4-mapped IPv6 addresses
are unwrapped first so a mapped private v4 can't slip through.
"""
if isinstance(ip, ipaddress.IPv6Address) and ip.ipv4_mapped is not None:
@@ -76,6 +77,9 @@ def _is_blocked_ip(ip: ipaddress._BaseAddress) -> bool:
or ip.is_multicast
or ip.is_reserved
or ip.is_unspecified
+ # Anything not globally routable, which also covers the CGNAT shared
+ # space 100.64.0.0/10 that is_private does not flag.
+ or not ip.is_global
)
diff --git a/workers/rig/worker_security.py b/workers/rig/worker_security.py
index 1e569c4e2..b1c4dd4cd 100644
--- a/workers/rig/worker_security.py
+++ b/workers/rig/worker_security.py
@@ -64,7 +64,8 @@ def _is_blocked_ip(ip: ipaddress._BaseAddress) -> bool:
Covers loopback, RFC1918 private ranges, link-local (incl. the cloud
metadata server at 169.254.169.254), unique-local IPv6 (fc00::/7),
- multicast, reserved, and unspecified addresses. IPv4-mapped IPv6 addresses
+ multicast, reserved, unspecified, and any other non-global address (CGNAT
+ 100.64.0.0/10 included). IPv4-mapped IPv6 addresses
are unwrapped first so a mapped private v4 can't slip through.
"""
if isinstance(ip, ipaddress.IPv6Address) and ip.ipv4_mapped is not None:
@@ -76,6 +77,9 @@ def _is_blocked_ip(ip: ipaddress._BaseAddress) -> bool:
or ip.is_multicast
or ip.is_reserved
or ip.is_unspecified
+ # Anything not globally routable, which also covers the CGNAT shared
+ # space 100.64.0.0/10 that is_private does not flag.
+ or not ip.is_global
)
diff --git a/workers/segment/worker_security.py b/workers/segment/worker_security.py
index 1e569c4e2..b1c4dd4cd 100644
--- a/workers/segment/worker_security.py
+++ b/workers/segment/worker_security.py
@@ -64,7 +64,8 @@ def _is_blocked_ip(ip: ipaddress._BaseAddress) -> bool:
Covers loopback, RFC1918 private ranges, link-local (incl. the cloud
metadata server at 169.254.169.254), unique-local IPv6 (fc00::/7),
- multicast, reserved, and unspecified addresses. IPv4-mapped IPv6 addresses
+ multicast, reserved, unspecified, and any other non-global address (CGNAT
+ 100.64.0.0/10 included). IPv4-mapped IPv6 addresses
are unwrapped first so a mapped private v4 can't slip through.
"""
if isinstance(ip, ipaddress.IPv6Address) and ip.ipv4_mapped is not None:
@@ -76,6 +77,9 @@ def _is_blocked_ip(ip: ipaddress._BaseAddress) -> bool:
or ip.is_multicast
or ip.is_reserved
or ip.is_unspecified
+ # Anything not globally routable, which also covers the CGNAT shared
+ # space 100.64.0.0/10 that is_private does not flag.
+ or not ip.is_global
)
diff --git a/workers/stylize/worker_security.py b/workers/stylize/worker_security.py
index 1e569c4e2..b1c4dd4cd 100644
--- a/workers/stylize/worker_security.py
+++ b/workers/stylize/worker_security.py
@@ -64,7 +64,8 @@ def _is_blocked_ip(ip: ipaddress._BaseAddress) -> bool:
Covers loopback, RFC1918 private ranges, link-local (incl. the cloud
metadata server at 169.254.169.254), unique-local IPv6 (fc00::/7),
- multicast, reserved, and unspecified addresses. IPv4-mapped IPv6 addresses
+ multicast, reserved, unspecified, and any other non-global address (CGNAT
+ 100.64.0.0/10 included). IPv4-mapped IPv6 addresses
are unwrapped first so a mapped private v4 can't slip through.
"""
if isinstance(ip, ipaddress.IPv6Address) and ip.ipv4_mapped is not None:
@@ -76,6 +77,9 @@ def _is_blocked_ip(ip: ipaddress._BaseAddress) -> bool:
or ip.is_multicast
or ip.is_reserved
or ip.is_unspecified
+ # Anything not globally routable, which also covers the CGNAT shared
+ # space 100.64.0.0/10 that is_private does not flag.
+ or not ip.is_global
)
diff --git a/workers/texture/worker_security.py b/workers/texture/worker_security.py
index 1e569c4e2..b1c4dd4cd 100644
--- a/workers/texture/worker_security.py
+++ b/workers/texture/worker_security.py
@@ -64,7 +64,8 @@ def _is_blocked_ip(ip: ipaddress._BaseAddress) -> bool:
Covers loopback, RFC1918 private ranges, link-local (incl. the cloud
metadata server at 169.254.169.254), unique-local IPv6 (fc00::/7),
- multicast, reserved, and unspecified addresses. IPv4-mapped IPv6 addresses
+ multicast, reserved, unspecified, and any other non-global address (CGNAT
+ 100.64.0.0/10 included). IPv4-mapped IPv6 addresses
are unwrapped first so a mapped private v4 can't slip through.
"""
if isinstance(ip, ipaddress.IPv6Address) and ip.ipv4_mapped is not None:
@@ -76,6 +77,9 @@ def _is_blocked_ip(ip: ipaddress._BaseAddress) -> bool:
or ip.is_multicast
or ip.is_reserved
or ip.is_unspecified
+ # Anything not globally routable, which also covers the CGNAT shared
+ # space 100.64.0.0/10 that is_private does not flag.
+ or not ip.is_global
)