Repository navigation
fix(historyimport): keep user-supplied server addresses off the server's network - #1492
Conversation
…r's network History import and Plex webhook sync fetched whatever server address a user supplied with a plain HTTP client, so any signed-in account could make the server send requests to its own LAN, cluster services, or cloud metadata. Add internal/netguard: address classes shared with the notification webhook guard, and a transport that checks every dialed address (redirects included) with separate connection pools for trusted and untrusted requests. Server addresses from non-admin accounts must be public unless an admin turns on media_servers.allow_private_destinations; admin-configured sources stay trusted, and metadata and other special addresses are refused for everyone. Queued runs read the policy again when they start. v1 run responses and realtime history-import events now carry the same safe summaries as the v2 monitors instead of stored upstream error text. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
::a.b.c.d is deprecated and has no legitimate use; classify it as blocked instead of relying on the network stack never routing it. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (43)
Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 0 remain after this review. 📝 WalkthroughWalkthroughThis change adds shared outbound address checks and policy-controlled private-network access for media-server requests. It applies the policy to history imports and webhook sync, adds an administrator setting, and sanitizes public history-import run summaries. ChangesOutbound address protection
Priority: ➖ Normal Estimated code review effort: 4 (Complex) | ~60 minutes Change: Bug fix Sequence Diagram(s)sequenceDiagram
participant User
participant LocalNetworkAccess
participant netguard
participant GuardedHTTPClient
participant MediaServer
User->>LocalNetworkAccess: Submit server URL
LocalNetworkAccess->>netguard: CheckServerURL
netguard-->>LocalNetworkAccess: Allow or address refusal
LocalNetworkAccess->>GuardedHTTPClient: Pass policy context
GuardedHTTPClient->>netguard: Check destination at dial time
netguard-->>GuardedHTTPClient: Allow or refuse connection
GuardedHTTPClient->>MediaServer: Send allowed request
Merge Risk: ⚪ Minimal · up to No identified issue remains that should prevent merging after normal checks. Security Architecture ReviewSecurity architecture risk: 🟡 Moderate · up to The change substantially restricts previously unrestricted media-server requests, but the new administrator-controlled exception grants every account local-network access when enabled. That shared permission and its rollout merit architecture review; no introduced or worsened security vulnerability was confirmed. Retained concerns Security review detailsSecurity Blast Radius
Security Findings and Attack Paths
Trust Boundaries and Controls
Resilience and Maintainability Implications
Hardening Proposals
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Full details: Docstring CoverageExplanation Docstring coverage is 45.10% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 102 functions across 39 files. (4 skipped: 4 unsupported.)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
ApprovabilityVerdict: Not approved Macroscope's review found this PR not approvable — This PR introduces a new outbound network security boundary and admin-controlled trust policy across history import, webhook sync, and notification transports, changing existing server-originated behavior and API/event diagnostics. Its cross-component security impact warrants human review. You can add or adjust custom eligibility rules. Learn more. |
fec0::/10 is deprecated (RFC 3879) but can still be routed inside a site, so an untrusted request to a site-local address must be refused like ULA. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
A NAT64 gateway translates 64:ff9b::/96 to the IPv4 address in its last 32 bits, so 64:ff9b::a9fe:a9fe reached cloud metadata for trusted callers. Block a well-known NAT64 address whose embedded IPv4 address is blocked, keep the rest private, and block local-use NAT64 outright because its embedding varies by network. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Problem
Related issue: N/A
Validation tasks: changes #1240 C1–C3, #1241 C1–C3, #1242 C1–C3, #1243 C1–C2, #1237 C1–C2 (none run yet: a non-admin account that imports from or syncs with a server on Silo's own network now needs the new admin setting)
Any signed-in account could make Silo send requests to addresses on its own network. History import and Plex webhook sync fetch whatever server address the user supplies. That can be a typed Jellyfin or Plex URL, or a server address that Emby Connect or plex.tv lists for the user's account. The HTTP client followed redirects and checked nothing. So on a shared server, any account could point Silo at its database, cache, transcode nodes, the Kubernetes API, or a cloud metadata endpoint, and read the result of each attempt from the response status and timing. Error bodies could leak too:
Reported privately by @hackchang.
With this change, server addresses from non-admin accounts must be on the public internet by default. An admin setting lets every account use local network servers. Metadata and other special addresses are refused for everyone.
Approach
internal/netguardpackage classifies addresses as public, private, or blocked.media_servers.allow_private_destinationsis on. Servers an admin configured as import sources are always allowed. A queued run reads the policy again when it starts, so turning the setting off also stops runs already accepted.Applying the webhook rule, which refuses every private address, would have been simpler. It would also break the main use: importing from a Plex, Jellyfin, or Emby server on the same LAN.
Validation
make test-gopasses, andgo vet,gofmt, andmake lint-changedare clean. With a migrated test database attached, the touched packages pass, except two v1 handler tests (TestAdminSubtitleListPageDB,TestCatalogTransferPersistsJobsAndSignedLink). Those two test code this PR does not change and fail the same way on currentmain.make test-webpass.verify-*target in the gate andTestCommittedArtifactMatchesRouterpass.0.0.0.0), RFC 1918, and CGNAT addresses. This held on v1 and v2, for a Plex custom URL, and for webhook sync, and the fake server received no requests.Risks
Checklist
AI Disclosure
feature-dev:code-reviewer,sonnetmodel alias) traced every path from a user- or admin-supplied address to an outbound request. It checked the trust decision on each path, connection-pool separation, address encodings, the notification webhook guard, the redaction surfaces, and whether the tests could pass vacuously. It found no bypass. It flagged IPv4-compatible IPv6 literals (::a.b.c.d) as classified public; they are now blocked. It also noted that the v1 admin run endpoints and the admin websocket snapshot still return unredacted diagnostics. These are left as they are because only admins receive them.Note
Guard user-supplied history-import server addresses against private networks via
netguardinternal/netguardpackage: a shared outbound address policy that blocks private, blocked (metadata, multicast, NAT64, etc.), and local-interface destinations, with aWithPrivateAccesscontext marker and guarded HTTP clients used by the Emby, Jellyfin, and Plex clientsLocalNetworkAccesspolicy in local_network.go: private destinations are allowed only when themedia_servers.allow_private_destinationssetting is on, or for enabled admin accounts. Personal-run admission, queued execution, and admin user discovery all apply it, with rechecks when queued runs startPublicRunsanitizer in public_messages.go that replaces stored error, warning, and unmatched-sample diagnostics with an approved message set. v1, v2, and websocket history-import responses now use this projectionmedia_servers.allow_private_destinationsis enabled or the user is an enabled admin; guarded transports disable proxy environment variables, and errors previously reported as unreachable upstream are now mapped to the new server-address messagesMacroscope summarized baf2944.