Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

harden: block Alibaba/AWS IPv6 cloud-metadata endpoints in shared ingest guard (#2513)

Adam Eivyc36bd2285855
diff --git a/server/lib/catalogValidation.js b/server/lib/catalogValidation.js
index 2d22e8159d..0a59c33da0 100644
--- a/server/lib/catalogValidation.js
+++ b/server/lib/catalogValidation.js
@@ -154,6 +154,8 @@ export const catalogScrapPatchSchema = catalogScrapCreateSchema.partial();
// A host (bracket-stripped, lowercased) that the URL ingest must refuse:
// loopback, link-local (incl. the 169.254.169.254 cloud-metadata endpoint),
+// the named cloud-metadata endpoints that hide inside allowed private ranges
+// (Alibaba 100.100.100.200, AWS IPv6 IMDS fd00:ec2::254 — see inline note),
// and the unspecified address — in plain IPv4, IPv6, IPv4-mapped-IPv6
// (`::ffff:127.0.0.1` → WHATWG-hex `::ffff:7f00:1`), AND the deprecated
// IPv4-compatible-IPv6 form (`::127.0.0.1` → `::7f00:1`), so the guard can't be
@@ -171,6 +173,17 @@ export const isBlockedIngestHost = (host) => {
const h = host.toLowerCase().replace(/^\[|\]$/g, '').replace(/\.+$/, '');
if (h === 'localhost' || h.endsWith('.localhost') || h === 'metadata.google.internal') return true;
if (h === '::1' || h === '::' || h === '0.0.0.0') return true;
+ // Named cloud-metadata endpoints that live INSIDE otherwise-allowed private
+ // ranges, so the "allow LAN" posture would leak them without an explicit
+ // literal block: Alibaba ECS metadata `100.100.100.200` sits in the CGNAT
+ // 100.64/10 block (which Tailscale also uses), and AWS's IPv6 IMDS
+ // `fd00:ec2::254` sits in IPv6 ULA fd00::/8. Both WHATWG-normalize to these
+ // exact canonical forms (and dns.lookup returns them canonical too), so an
+ // exact match catches both the URL-literal and DNS-resolved paths. Blocking
+ // these two exact IPs does NOT meaningfully shrink the Tailscale/ULA space a
+ // real peer could occupy (a peer landing on exactly 100.100.100.200 is a
+ // 1-in-4M collision), and a PortOS install has no reason to fetch cloud IMDS.
+ if (h === '100.100.100.200' || h === 'fd00:ec2::254') return true;
// IPv6 link-local fe80::/10 (first hextet fe80–febf), e.g. [fe80::1].
if (h.includes(':') && /^fe[89ab][0-9a-f]?:/i.test(h)) return true;
const v4Blocked = (ip) => /^127\./.test(ip) || /^169\.254\./.test(ip) || ip === '0.0.0.0';
diff --git a/server/lib/catalogValidation.test.js b/server/lib/catalogValidation.test.js
index 21d5188fbd..29119d2efb 100644
--- a/server/lib/catalogValidation.test.js
+++ b/server/lib/catalogValidation.test.js
@@ -647,6 +647,15 @@ describe('catalogUrlIngestSchema — SSRF guard', () => {
expect(() => catalogUrlIngestSchema.parse({ url: 'http://metadata.google.internal/x' })).toThrow();
});
+ it('rejects named cloud-metadata endpoints hidden in allowed private ranges', () => {
+ // Alibaba ECS metadata (inside CGNAT 100.64/10) + AWS IPv6 IMDS (inside ULA
+ // fd00::/8) — both would leak under the allow-LAN posture without a literal
+ // block. The expanded IPv6 form normalizes to the same canonical literal.
+ expect(() => catalogUrlIngestSchema.parse({ url: 'http://100.100.100.200/latest/meta-data/' })).toThrow();
+ expect(() => catalogUrlIngestSchema.parse({ url: 'http://[fd00:ec2::254]/latest/meta-data/' })).toThrow();
+ expect(() => catalogUrlIngestSchema.parse({ url: 'http://[fd00:ec2:0:0:0:0:0:254]/x' })).toThrow();
+ });
+
it('rejects IPv4-mapped IPv6 loopback/link-local + unspecified literals (no bypass)', () => {
// WHATWG normalizes [::ffff:127.0.0.1] → [::ffff:7f00:1]; both must reject.
expect(() => catalogUrlIngestSchema.parse({ url: 'http://[::ffff:127.0.0.1]/x' })).toThrow();
diff --git a/server/services/layeredIntelligence.test.js b/server/services/layeredIntelligence.test.js
index 6a8c3e1caf..be4f1c6ada 100644
--- a/server/services/layeredIntelligence.test.js
+++ b/server/services/layeredIntelligence.test.js
@@ -770,6 +770,10 @@ describe('fetchHttpSource', () => {
it('blocks IPv6 loopback ([::1])', async () => {
expect(await fetchHttpSource('http://[::1]/')).toBeNull();
});
+ it('blocks named cloud-metadata endpoints inside allowed private ranges (Alibaba/AWS IMDS)', async () => {
+ expect(await fetchHttpSource('http://100.100.100.200/latest/meta-data/')).toBeNull();
+ expect(await fetchHttpSource('http://[fd00:ec2::254]/latest/meta-data/')).toBeNull();
+ });
it('allows a public URL through the guard (real fetch stubbed at fetchText seam)', async () => {
const fetchText = vi.fn().mockResolvedValue('public body');
expect(await fetchHttpSource('https://example.com/feed', { fetchText })).toBe('public body');