Skip to content

Check template installer hosts as parsed IP addresses - #196

Merged
kittendevv merged 1 commit into
kittendevv:mainfrom
Bouni:fix/ssrf-guard-ipv6-ranges
Nov 22, 2026
Merged

kittendevv merged 1 commit into
kittendevv:mainfrom
Bouni:fix/ssrf-guard-ipv6-ranges

Conversation

@Bouni

@Bouni Bouni commented Nov 20, 2026

Copy link
Copy Markdown
Contributor

Summary

The remote template installer's host guard (assertSafeRemoteUrl in backend/src/controllers/templates.ts) checked IP literals with string comparisons and regexes. This replaces them with a small module that parses IPv4 and IPv6 literals into numbers and checks the address ranges numerically, so every spelling of an address is handled the same way.

Changes

  • New backend/src/utils/ipRanges.ts: parseIPv4, parseIPv6 (compressed :: and trailing dotted quads), isInternalIPv4, isInternalIPv6, isInternalAddress.
  • templates.ts uses isInternalAddress for host literals and for addresses returned by DNS resolution. The previous string-based helpers are removed; redirect handling and DNS resolution are unchanged.
  • Range list: loopback/unspecified, private, CGNAT, link-local, unique local, IPv4-mapped/-compatible and other embedded/translated IPv4 forms, deprecated site-local, multicast, and the IPv4 reserved, benchmarking and IETF protocol ranges.

Verification

  • New backend/src/utils/ipRanges_test.ts: IPv6 parsing, internal addresses in various spellings (as normalized by URL), and public addresses that must still pass.
  • Calling installTemplateFromManifest with internal hosts is rejected by the guard; a public URL (raw.githubusercontent.com) still passes the guard.
  • deno check and the existing backend tests pass.

🤖 Generated with Claude Code

The remote template installer's host guard compared IP literals as
strings. Parse IPv4 and IPv6 literals into numbers and check the address
ranges numerically instead (new utils/ipRanges.ts), so every spelling of
an address is handled the same way. Resolved DNS addresses go through
the same check.

The range list now also covers translated and embedded IPv4 forms,
deprecated site-local and multicast IPv6, and the IPv4 multicast,
reserved, benchmarking and IETF protocol ranges.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@kittendevv
kittendevv merged commit 9305640 into kittendevv:main Nov 22, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants