Skip to content

fix: skip SSRF validation for loopback and allowlisted webhook hosts#17910

Closed
Copilot wants to merge 2 commits into
mainfrom
copilot/fix-ssrf-validation-webhook-tests
Closed

fix: skip SSRF validation for loopback and allowlisted webhook hosts#17910
Copilot wants to merge 2 commits into
mainfrom
copilot/fix-ssrf-validation-webhook-tests

Conversation

Copilot AI commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

ssrf.ValidateHost added in #17532 blocked loopback IPs (127.0.0.1, ::1), breaking 7 tests that use httptest.NewServer and causing spurious DNS failures for admin-curated KC_WEBHOOK_ALLOWED_HOSTS entries. SSRF DNS resolution is redundant for both cases — loopbacks are already explicitly allowed for HTTP, and allowlisted hosts are operator-controlled.


📌 Fixes


📝 Summary of Changes

Skip ssrf.ValidateHost in NewWebhookNotifier and CheckRedirect when the host is loopback or explicitly listed in KC_WEBHOOK_ALLOWED_HOSTS:

// Before
if err := ssrf.ValidateHost(u.Hostname()); err != nil {
    return nil, fmt.Errorf("webhook URL blocked: %w", err)
}

// After
if !isLoopbackHost(u.Hostname()) && !isHostAllowlisted(u.Hostname()) {
    if err := ssrf.ValidateHost(u.Hostname()); err != nil {
        return nil, fmt.Errorf("webhook URL blocked: %w", err)
    }
}

The new isHostAllowlisted helper differs from checkWebhookHostAllowed — it returns false when the env var is unset (no allowlist → not listed), enabling the bypass only when the operator has explicitly configured a whitelist.


Changes Made

  • Added isHostAllowlisted(host string) bool helper in pkg/notifications/webhook.go
  • Wrapped ssrf.ValidateHost in NewWebhookNotifier to skip for loopback/allowlisted hosts
  • Applied the same skip logic in the CheckRedirect callback for redirect hops

Checklist

Please ensure the following before submitting your PR:

  • I used a coding agent (Claude Code, Copilot, Gemini, or Codex) to generate/review this code
  • I have reviewed the project's contribution guidelines
  • New cards target console-marketplace, not this repo
  • isDemoData is wired correctly (cards show Demo badge when using demo data)
  • I have written unit tests for the changes (if applicable)
  • I have tested the changes locally and ensured they work as expected
  • All commits are signed with DCO (git commit -s)

Screenshots or Logs (if applicable)

All 7 previously-failing pkg/notifications tests now pass:

--- PASS: TestWebhookNotifier_Send
--- PASS: TestWebhookNotifier_NonSuccessStatus
--- PASS: TestWebhookNotifier_HostAllowlist
--- PASS: TestWebhookNotifier_NewError/loopback_plaintext_http_allowed
--- PASS: TestService_Registration/Webhook
--- PASS: TestNotifications_Integration_Dispatch
ok  github.com/kubestellar/console/pkg/notifications  0.054s

👀 Reviewer Notes

isHostAllowlisted reads the env var on each call, consistent with the existing checkWebhookHostAllowed pattern. The SSRF bypass only applies when the operator has explicitly set KC_WEBHOOK_ALLOWED_HOSTS — an empty env var returns false, preserving full SSRF protection as the default.

@kubestellar-prow kubestellar-prow Bot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. dco-signoff: no Indicates the PR's author has not signed the DCO. labels Jun 12, 2026
@netlify

netlify Bot commented Jun 12, 2026

Copy link
Copy Markdown

Deploy Preview for kubestellarconsole failed. Why did it fail? →

Name Link
🔨 Latest commit 5dbe33d
🔍 Latest deploy log https://app.netlify.com/projects/kubestellarconsole/deploys/6a2b7bbf7fcdff0009e36e4a

@github-actions

Copy link
Copy Markdown
Contributor

👋 Hey @Copilot — thanks for opening this PR!

🤖 This project is developed exclusively using AI coding assistants.

Please do not attempt to code anything for this project manually.
All contributions should be authored using an AI coding tool such as:

This ensures consistency in code style, architecture patterns, test coverage,
and commit quality across the entire codebase.


This is an automated message.

@github-actions github-actions Bot added the ai-generated Pull request generated by AI label Jun 12, 2026
@kubestellar-prow kubestellar-prow Bot added the size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. label Jun 12, 2026
Fixes #17888

The ssrf.ValidateHost call in NewWebhookNotifier was blocking loopback
IPs (127.0.0.1, ::1) breaking all webhook tests that use httptest.NewServer,
and also causing DNS resolution failures for admin-curated hosts listed
in KC_WEBHOOK_ALLOWED_HOSTS.

- Add isHostAllowlisted() helper (returns bool, unlike checkWebhookHostAllowed)
- Wrap ssrf.ValidateHost in NewWebhookNotifier to skip when host is loopback
  or explicitly allowlisted by the operator
- Apply the same skip logic in the CheckRedirect callback for redirect hops

Signed-off-by: copilot <copilot@github.com>
@kubestellar-prow

Copy link
Copy Markdown
Contributor

Thanks for your pull request. Before we can look at it, you'll need to add a 'DCO signoff' to your commits.

📝 Please follow instructions in the contributing guide to update your commits with the DCO

Full details of the Developer Certificate of Origin can be found at developercertificate.org.

The list of commits missing DCO signoff:

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

@kubestellar-prow

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please ask for approval from clubanderson. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@kubestellar-prow kubestellar-prow Bot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Jun 12, 2026
Copilot AI changed the title [WIP] Fix SSRF validation to allow loopback for webhook tests fix: skip SSRF validation for loopback and allowlisted webhook hosts Jun 12, 2026
Copilot AI requested a review from clubanderson June 12, 2026 03:24
@github-actions github-actions Bot added the ai-needs-human AI automation unavailable - needs human intervention label Jun 12, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Status Check

This draft PR appears to be stalled with no activity since creation (~2h20m ago). This check ran outside business hours (05:43 UTC), so human follow-up when the team is online is fine.

Current status:

  • Build: ❌ FAILING (build (ubuntu/mac/win/arm), go test ./..., fullstack-smoke, Verify console starts successfully, pr-check)
  • Netlify: ❌ FAILING (redirect/header/pages checks)
  • DCO signoff: ❌ Missing (dco-signoff: no)
  • Review: Not approved

Known blockers:

  1. DCO signoff missing — commit 02cf878 lacks Signed-off-by. The PR needs amended commits with DCO before it can be merged.
  2. Build/test failuresgo test ./... and multi-platform builds are failing. This may be due to base branch state or conflicts.

Recommended next steps:

  • A human maintainer should review the failing CI logs to determine if the build failures are related to this PR's changes or inherited from the base branch.
  • If the build failures are in unrelated code, a rebase onto a clean main may resolve them.
  • DCO signoff must be added before the PR can proceed.

Generated by Stuck Detection Workflow · 202.2 AIC · ⌖ 12.6 AIC · ⊞ 35.9K ·

@kubestellar-prow kubestellar-prow Bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jun 12, 2026
@kubestellar-prow

Copy link
Copy Markdown
Contributor

PR needs rebase.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@github-actions

Copy link
Copy Markdown
Contributor

Status Check

This draft PR has been stuck for ~8 hours with no new commits and a failing build. A previous status check was posted ~5.5 hours ago with no resolution since.

Current status:

  • Build: ❌ FAILING (Netlify deploy failed at creation)
  • DCO signoff: ❌ Missing (commit 02cf878 — only "Initial plan" commit present, no implementation commits)
  • Base branch: ❌ Needs rebase (needs-rebase label)
  • Review: Not approved

Key concern: This PR appears to have only an "Initial plan" commit with no implementation. The AI agent may have created the PR structure but never pushed the actual fix commits.

Recommended next steps for a human maintainer:

  • Check if this PR has any substantive code changes beyond the initial plan commit.
  • If no implementation was committed, consider closing this PR and re-triggering the fix from the source issue.
  • If implementation exists but is blocked, a rebase and DCO signoff are needed before it can proceed.

Generated by Stuck Detection Workflow · 218.3 AIC · ⌖ 12.7 AIC · ⊞ 35.9K ·

@github-actions

Copy link
Copy Markdown
Contributor

Status Check (Follow-Up)

Item: PR #17910 — fix: skip SSRF validation for loopback and allowlisted webhooks
Last stuck-detection comment: ~2026-06-12T11:28Z (~4h 15m ago)
Last activity: 2026-06-12T11:28Z — no human or commit activity since
Stuck duration: ~12h since PR opened at 03:17 UTC

Current State

Area Status
Netlify deploy ❌ Failed
DCO sign-off ❌ Missing on commit 02cf878
Rebase needs-rebase — branch is behind main
Review / LGTM ❌ None

Recommended Next Steps

A human maintainer should:

  1. Review the Netlify deploy failure to assess if the SSRF allowlist changes are still correct on the current main
  2. Rebase the branch onto main
  3. Add DCO sign-off to the commit (git commit --amend -s)
  4. Resolve the deploy failure, then mark ready for review

Generated by Stuck Detection Workflow · 348.4 AIC · ⌖ 12.7 AIC · ⊞ 35.9K ·

@github-actions

Copy link
Copy Markdown
Contributor

Status Check

This draft PR appears to be stalled and requires human intervention.

Stuck since: 2026-06-12T03:17Z (≈ 14 hours)
Current state: Draft, no recent commits

Blockers identified:

  • needs-rebase — the branch is behind main and must be rebased before CI can pass
  • dco-signoff: no — commits are missing the DCO Signed-off-by trailer

Build/Review:

  • Build: failing (needs rebase first)
  • Review: Not approved

Recommended next steps for a human maintainer:

  1. Rebase the branch on latest main
  2. Amend commits to add DCO sign-off (git commit --amend -s)
  3. Force-push and convert from draft when ready for review

Generated by Stuck Detection Workflow · 309.4 AIC · ⌖ 12.7 AIC · ⊞ 35.9K ·

@github-actions

Copy link
Copy Markdown
Contributor

Status Check — Still Stuck (~16 hours)

This draft PR remains stalled since the previous status check (~13 hours ago).

Current blockers:

  • needs-rebase — branch is behind main
  • dco-signoff: no — commits are missing Signed-off-by trailers (DCO required)
  • Build: ❌ FAILING — Netlify deploy failed on this PR
  • Not approved — awaiting review

State: Draft · Not merged · ai-needs-human already applied

Recommended next steps: A human maintainer should review this PR and either:

  1. Close it if the fix has been superseded or is no longer needed, or
  2. Rebase onto main, add DCO sign-off, and route for review

Note: Current time is outside business hours (UTC). Follow-up when the team is online is fine.

Generated by Stuck Detection Workflow · 195.2 AIC · ⌖ 13 AIC · ⊞ 35.9K ·

@kubestellar-hive

Copy link
Copy Markdown
Contributor

Closing: stale needs-rebase PR with WIP/DCO failures. Per #18190, these have been sitting without progress and should be re-opened with a fresh branch if still needed.

@kubestellar-hive kubestellar-hive Bot closed this Jun 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai-generated Pull request generated by AI ai-needs-human AI automation unavailable - needs human intervention dco-signoff: no Indicates the PR's author has not signed the DCO. do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. tier/2-standard

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants