Skip to content

fix(notifications): enforce blocked destinations in private mode - #2746

Merged
Quick104 merged 2 commits into
mainfrom
fix/webhook-private-netguard-blocked
Oct 20, 2026
Merged

Quick104 merged 2 commits into
mainfrom
fix/webhook-private-netguard-blocked

Conversation

@Quick104

@Quick104 Quick104 commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Problem

Enabling private webhook destinations currently skips the shared address policy at registration and connection time. This change preserves intended LAN access while keeping the policy's Blocked class refused for personal webhooks and server channels.

Closes #2744
Related issue: N/A
Validation tasks: changes #1234 C1 and #1235 C1/C2; board-wide regression query unavailable (missing read:project scope).

Approach

Both guards use netguard.CheckAddr with the current private-access setting. Registration resolves hostnames within two seconds and rejects failed, empty or disallowed answers in either mode. Public-only notification clients also enforce the shared restriction on the server's own interface addresses. HTTPS, URL credential rejection, TLS verification, redirect limits, timeouts, response-body bounds and existing delivery diagnostics remain enforced.

The API and settings keep their existing shapes. Apple, Android and Jellyfin compatibility need no client change. The manual already describes private access as reaching LAN and localhost addresses, which remain supported.

Validation

  • Live registration check, local builds of main (387c497fc) and this branch (7f04f922c) against a throwaway database with private destinations allowed: main created server channels for 169.254.169.254, 0.0.0.0, and fe80::1%eth0; this branch refuses all three with 400 and still creates a loopback channel. No delivery was triggered.
  • TestWebhookClientDialPolicy drives the production delivery client against a loopback TLS server: Private refused by default, Private delivered in private mode, and a redirect hop to 0.0.0.0 refused in private mode without reaching the server. On main that redirect case fails with a TLS error because the hop is dialed.
  • Injected resolver answers and direct connect-guard calls cover the remaining address classes. No outbound connection to a real destination was made.
  • Passed: full Go build and vet, changed-line and router-recovery lint, focused race tests, formatting and documentation checks, and selected generated settings/playback/route/OpenAPI checks. ci / Go test fails only on TestAdminDefaultChangeReachesEveryViewer, which fails on main too ([bug] Administrator default changes no longer reach any events socket #2748).
  • Excluded: the full network-using Go suite, DB/integration tests, deployments and devices. The frontend gate was not run; no frontend code changed.
  • Direct notification validation records currently say Not run. No human validation or board-wide clean result is claimed.

Evidence

Live registration results and focused test results for 7f04f922c; delivery to a real public destination and live TLS behavior remain unverified.

Evidence: https://evidence.siloserver.org/r/silo-server/c32-webhook-private-policy/

Risks

Registration in both modes, including web push subscription, now has a two-second lookup deadline. Private mode newly requires successful resolution. Public-only delivery clients, including web push and the push relay, refuse destinations on the server's own interfaces under the existing shared policy. No migration is required.

Follow-up: turning the setting off does not close keep-alive connections opened while it was on, so a Private destination can keep receiving deliveries until its pooled connection closes. That predates this change and is tracked in #2794, to follow this PR.

Checklist

  • I read and can explain the complete diff.
  • This pull request addresses one concern.
  • The Evidence section describes the changed behavior and its verification limits.

AI Disclosure

  • Harness: Codex through T3 Code; T3 Code claudeAgent provider for independent review
  • Tools: Codex, T3 Code orchestration, T3 Code claudeAgent
  • Models: gpt-6.1-sol (implementation), claude-opus-5-5 (independent review)
  • Involvement: AI-generated implementation and source/test verification; human runtime verification pending
  • Adversarial review: claude-opus-5-5 reviewed the approach on 387c497fc7b00a451a9c8ea7c5dffefcc5a032d4. Bounded resolution, address parsing and documentation amendments were adopted; existing diagnostic mapping was retained and tested. Independent source review by claude-opus-5-5 completed on 179832af15e9a985bb222f78451e774dc51fcf9d with no verified code findings and nothing posted. Required context was read in the completed replacement round. Review used source and offline logs; no runtime proof is claimed. High effort was requested; effective effort could not be independently confirmed.
  • Follow-up review: claude-opus-5-5 in Claude Code reviewed 179832af1, with a Codex gpt-6.1-sol cross-check. It found one test gap (the redirect test could not fail if the production dialer stopped guarding connections), fixed in 7f04f922c, and one pre-existing defect, filed as [bug] Turning off private webhook destinations leaves pooled connections usable #2794.

Note

Enforce blocked webhook destinations in private mode

  • Previously, enabling WebhooksAllowPrivateDestinations bypassed all address checks. Now private mode permits Private addresses but still rejects Blocked ones, using the shared netguard.CheckAddr policy
  • Registration resolves hostnames with a two-second timeout and rejects the URL if any resolved address is disallowed; IP literals are checked directly (webhook_guard.go)
  • Delivery connections now go through newNotificationDialer, which reads the private setting at connection time and rechecks each address, including on redirect hops (webhook_http.go)
  • Extensive tests cover literal, resolved, dial-time, and end-to-end client address enforcement; docs updated to match (webhook_policy_test.go)
  • Behavioral Change: ValidateWebhookURL now always resolves hostnames and validates credentials even in private mode; registrations with hostnames that fail or resolve slowly (2s limit) are rejected

Macroscope summarized 7f04f92.

@silo-triage silo-triage Bot added the size/L 200–499 added + deleted lines (all files); change volume, not priority. label Oct 20, 2026
@silo-kody

silo-kody Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

Silo Kody — review complete

Review finished. Check the inline comments for findings and verify each suggestion against the code and tests.

Reviewing changes in Silo
  • Include the related issue, expected behavior, and validation steps in the PR description.
  • For API changes, describe the effect on Apple and Android clients and Jellyfin compatibility.
  • For plugin changes, identify the affected SDK contract, plugin, and catalog entry.
  • Follow this repository's AGENTS.md and CONTRIBUTING.md.
  • Request another review with @kody start-review in a PR comment.
  • React with 👍 or 👎 to give feedback on individual suggestions.
Review settings
Review Options

The following review options are enabled or disabled:

Options Enabled
Bug ✅
Performance ✅
Security ✅
Business Logic ❌

@coderabbitai

coderabbitai Bot commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: a38ff7b9-fa2f-4801-82dc-782e7e3d4419
📥 Commits

Reviewing files that changed from the base of the PR and between dd3f7a6 and 7f04f92.

📒 Files selected for processing: 8
  • docs/architecture/notifications.md
  • docs/architecture/outbound-address-guard.md
  • docs/notifications-api.md
  • internal/notifications/settings.go
  • internal/notifications/webhook_guard.go
  • internal/notifications/webhook_http.go
  • internal/notifications/webhook_logic_test.go
  • internal/notifications/webhook_policy_test.go

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 2 remain after this review.

📝 Walkthrough

Webhook registration and delivery now use the shared address policy. Private destinations require the administrator setting, blocked destinations remain refused, and hostname resolution has a two-second deadline.

Changes: Webhook destination policy

Layer / File(s) Summary
Registration address validation
docs/architecture/notifications.md, docs/notifications-api.md, internal/notifications/settings.go, internal/notifications/webhook_guard.go, internal/notifications/webhook_logic_test.go, internal/notifications/webhook_policy_test.go
URL validation checks literal and resolved addresses. Private addresses require the setting; blocked, unresolved, empty, or timed-out results are rejected. Tests cover address classes and DNS outcomes.
Connection and redirect enforcement
docs/architecture/outbound-address-guard.md, internal/notifications/webhook_http.go, internal/notifications/webhook_policy_test.go
The HTTP dialer checks connection addresses against the shared policy, including redirect hops. Tests cover private-destination settings, delivery refusals, and transport limits.

Priority: ➖ Normal

Estimated code review effort: 3 (Moderate) | ~25 minutes

Change: Bug fix

Merge Risk: ⚪ Minimal · up to 7f04f

Blocked destinations are refused during registration and connection, including redirects. No actionable merge-blocking risk remains after normal checks.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 46.15% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 13 functions across 5 files. (3 skipped: … Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title clearly and concisely identifies the main change: enforcing blocked-destination checks when private webhook mode is enabled.
Linked Issues check Passed Issue #2744 requires shared netguard.CheckAddr enforcement during registration and each connection, including redirects, while allowing Public and configured Private addresses and refusing Blocked a…
Out of Scope Changes check Passed The changes stay within issue #2744. Production changes are limited to webhook registration validation and notification delivery connection guards. The added tests verify the required address classes,…
Description check Passed The pull request description clearly describes the webhook destination policy changes, validation behavior, tests, documentation updates, and known verification limits. It matches the changeset.
Full details: Linked Issues check

Explanation

Issue #2744 requires shared netguard.CheckAddr enforcement during registration and each connection, including redirects, while allowing Public and configured Private addresses and refusing Blocked addresses. webhook_guard.go now applies netguard.CheckAddr for IP literals and resolved hostnames, with a two-second lookup deadline and rejection of lookup errors or empty results. webhook_http.go now applies the same policy through newNotificationDialer at connection time. The policy tests cover private-mode acceptance, blocked-address rejection, dynamic settings, and redirect-hop enforcement. Existing HTTPS, credential, TLS, timeout, response, redirect, and diagnostic protections remain covered. The documentation and setting comment match the behavior.

Full details: Out of Scope Changes check

Explanation

The changes stay within issue #2744. Production changes are limited to webhook registration validation and notification delivery connection guards. The added tests verify the required address classes, lookup bounds, redirects, and retained transport protections. Documentation and the setting comment explain the changed policy. No API or settings shape change, unrelated feature, or unrelated client change is present in the supplied change summary and focused diff.

Full details: Docstring Coverage

Explanation

Docstring coverage is 46.15% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 13 functions across 5 files. (3 skipped: 3 unsupported.)

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

  • Fix all pre-merge checks with AI
✨ Finishing Touches: 💡 2
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
🛠️ Fix failing CI checks: 💡
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@silo-triage silo-triage Bot added bug Something isn't working go Pull requests that update go code impact: security Auth, privacy, or permission boundary priority: P0 Fix/merge first: data-loss, security, or widespread breakage labels Oct 20, 2026
@macroscopeapp

macroscopeapp Bot commented Oct 20, 2026

Copy link
Copy Markdown

The change affects notification outcomes users see, but the linked evidence is described as source and synthetic-test evidence rather than before-and-after captures of those outcomes.

  • internal/notifications/webhook_guard.go: destination registration or URL updates can now fail where they previously succeeded, showing an error in the profile webhook and admin channel forms. The evidence page should show before-and-after captures of the same registration outcome on both affected web surfaces, including mobile where the error is visible at phone width.
  • internal/notifications/webhook_http.go: blocked connection or redirect targets can change the existing test-send and delivery results. The evidence page should show before-and-after captures of the same test-send or delivery outcome.

Suggested fix: No diff; add the requested captures to the linked evidence page.

Automated check: Macroscope check run agent (gpt-6-luna). Evidence was not reviewed for correctness.

Posted via Macroscope — Visible change evidence

@Quick104

Copy link
Copy Markdown
Contributor Author

For the visible-change evidence request: destination acceptance changes, while the forms and diagnostic strings remain unchanged. This remediation is authorized for source assessment and finite offline tests only, so I have not captured runtime form errors or test-send results. The linked evidence shows the same policy assertion failing before the fix and passing afterward, plus injected resolver, connect-guard and redirect fixtures. It does not establish UI or live delivery behavior; maintainer acceptance of that evidence limit remains outstanding.

AI-assisted follow-up: gpt-6.1-sol, Codex through T3 Code.

@macroscopeapp

macroscopeapp Bot commented Oct 20, 2026

Copy link
Copy Markdown

The Validation tasks: line lists cases that are all Not run: #1234 C1 and #1235 C1/C2. The Notifications parent also lists Silo-Server/silo-apple#336 and Silo-Server/silo-android#346, whose cases are Not run. No Passed, Failed, or Blocked result is available to invalidate or unblock. Please replace the line with:

Validation tasks: none

Automated check: Macroscope check run agent (gpt-6-luna). No validation was performed.

Posted via Macroscope — v1 validation impact

@Quick104 Quick104 left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review of 179832af1. The fix is correct: both guards now use netguard.CheckAddr, so private mode admits the Private class and still refuses Blocked addresses at registration and on every dial, redirect hops included. The dialer checks the address it actually connects to, the transport has no proxy, and IPv4-mapped, NAT64, zoned, and IPv4-compatible forms all classify through the shared policy. I found one test gap, which I'm fixing on this branch.

One defect predates this PR: turning the setting off doesn't affect keep-alive connections opened while it was on, so a LAN destination keeps receiving deliveries until its pooled connection closes. Blocked addresses aren't affected. The fix touches newNotificationHTTPClient, which this PR also changes, so I filed it as #2794 to follow this PR.

AI-generated review: Claude Code (claude-opus-5-5), cross-checked with Codex (gpt-6.1-sol).

The redirect test swapped out the transport and called Control itself, so
it could not fail if the production dialer stopped guarding connections.
Drive the real client against a loopback TLS server instead, including a
redirect hop to 0.0.0.0 that main dials in private mode.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@silo-kody

silo-kody Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

Silo Kody — review complete

Review finished. Check the inline comments for findings and verify each suggestion against the code and tests.

Reviewing changes in Silo
  • Include the related issue, expected behavior, and validation steps in the PR description.
  • For API changes, describe the effect on Apple and Android clients and Jellyfin compatibility.
  • For plugin changes, identify the affected SDK contract, plugin, and catalog entry.
  • Follow this repository's AGENTS.md and CONTRIBUTING.md.
  • Request another review with @kody start-review in a PR comment.
  • React with 👍 or 👎 to give feedback on individual suggestions.
Review settings
Review Options

The following review options are enabled or disabled:

Options Enabled
Bug ✅
Performance ✅
Security ✅
Business Logic ❌

@Quick104

Copy link
Copy Markdown
Contributor Author

Review summary

Reviewed head: 7f04f922c (my review covered 179832af1; the only change since is my test commit).

Fit: 9/10 · Readiness: 9/10 — ready (assuming CI is green)

Fit. This closes a real gap in the outbound address policy: the development switch for private webhook destinations also let webhooks reach cloud metadata, link-local, and other addresses that no caller may reach under docs/architecture/outbound-address-guard.md. The fix reuses netguard.CheckAddr instead of adding a second policy, and changes no API, setting, or client.

Readiness. Both guards now refuse the Blocked class in private mode, on registration and on every dial, including redirect hops. The dialer checks the address it connects to, so a DNS answer that changes after registration is still caught, and IPv4-mapped, NAT64, zoned, and IPv4-compatible forms all go through the shared classifier. I checked it live on local builds of main and this branch against a throwaway database with private destinations allowed: main created server channels for 169.254.169.254, 0.0.0.0, and fe80::1%eth0; this branch refuses all three with 400 and still accepts a loopback channel.

Addressed

  • Low, test gap, fixed in 7f04f922c: the redirect test replaced the transport and called the guard itself, so it couldn't fail if the production client stopped guarding connections. TestWebhookClientDialPolicy now drives the real client against a loopback TLS server, including a redirect hop to 0.0.0.0. That case fails on main (the hop is dialed) and passes here.

Remaining

  • Pre-existing, filed as [bug] Turning off private webhook destinations leaves pooled connections usable #2794: turning the setting off doesn't close keep-alive connections opened while it was on, so a LAN destination can keep receiving deliveries until its pooled connection closes. Blocked addresses aren't affected. The fix changes newNotificationHTTPClient, so it should follow this PR.
  • Disclosed behavior changes I agree with: private-mode registration now has to resolve the host (two-second deadline), and public-only delivery, including web push and the push relay, also refuses the server's own interface addresses, as the shared policy already does for other untrusted callers.

Validated features

No passed case is affected. The cases this reaches, #1234 C1 and #1235 C1/C2, are all recorded as Not run. The body's Validation tasks: line says changes for them; since none has passed, nothing validated changes.

Other checks

Evidence: https://evidence.siloserver.org/r/silo-server/c32-webhook-private-policy/

AI-generated review: Claude Code (claude-opus-5-5), cross-checked with Codex (gpt-6.1-sol).

@Quick104
Quick104 merged commit 114575a into main Oct 20, 2026
16 of 18 checks passed
@Quick104
Quick104 deleted the fix/webhook-private-netguard-blocked branch October 20, 2026 14:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working go Pull requests that update go code impact: security Auth, privacy, or permission boundary priority: P0 Fix/merge first: data-loss, security, or widespread breakage size/L 200–499 added + deleted lines (all files); change volume, not priority.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[bug] Private webhook mode skips permanent destination restrictions

1 participant