Skip to content

fix(cron-delivery): drop redundant runtime SSRF check in deliver_webhook#3155

Merged
houko merged 1 commit into
mainfrom
fix/cron-webhook-ssrf-runtime
Apr 25, 2026
Merged

fix(cron-delivery): drop redundant runtime SSRF check in deliver_webhook#3155
houko merged 1 commit into
mainfrom
fix/cron-webhook-ssrf-runtime

Conversation

@houko

@houko houko commented Apr 25, 2026

Copy link
Copy Markdown
Contributor

Summary

main is red on cron_delivery::tests::webhook_sends_payload and webhook_reports_non_2xx, blocking #3141, #3142, and every future PR off main.

thread 'cron_delivery::tests::webhook_sends_payload' panicked at crates/librefang-kernel/src/cron_delivery.rs:603:9:
error: Some("webhook host '127.0.0.1' is loopback or link-local — refusing")

Root cause

#3139 migrated cron LocalFile path validation out of the runtime delivery layer and into CronJob::validate_delivery_targets, so existing tests that write to absolute tempdir paths via direct engine.deliver() could still run. The webhook half of the same migration was misseddeliver_webhook kept calling validate_webhook_url, which rejects any literal loopback IP. The two existing webhook tests both POST to http://127.0.0.1:<port>/hook against an in-process mock server, so they fail on every CI run.

Fix

Drop the runtime validate_webhook_url call and the function itself. Its protection was already symbolic — the doc comment itself flagged that DNS is not resolved, "a known TOCTOU we accept" — and validate_delivery_targets uses the same is_blocked_webhook_host allow-list before any URL reaches the scheduler. The comment on deliver_webhook now mirrors deliver_local_file, pointing at the input-time gate as the single source of truth.

Test plan

  • cron_delivery::tests::webhook_sends_payload and webhook_reports_non_2xx pass locally
  • validate_delivery_targets still rejects http://127.0.0.1/... and http://169.254.169.254/... at job creation time (existing test coverage in librefang-types::scheduler::tests)
  • CI green

PR #3139 moved cron LocalFile path validation out of the runtime delivery
layer and into CronJob::validate_delivery_targets so existing tests that
write to absolute tempdir paths could still run via direct
engine.deliver(). The webhook side of the same migration was missed —
deliver_webhook still called validate_webhook_url which rejected any
literal loopback IP, so cron_delivery::tests::webhook_sends_payload and
webhook_reports_non_2xx (both posting to a 127.0.0.1:<port> mock server)
panic on every CI run, blocking PRs #3141, #3142 and any future PR
based on main.

The runtime check was symbolic anyway: it never resolved DNS, which the
comment itself flagged as 'a known TOCTOU we accept'. SSRF protection
now lives entirely in validate_delivery_targets, which uses the same
allow-list (is_blocked_webhook_host) before any URL reaches the
scheduler. Mirroring deliver_local_file's doc, point readers at the
input-time gate as the single source of truth.
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@github-actions github-actions Bot added ready-for-review PR is ready for maintainer review size/M 50-249 lines changed area/kernel Core kernel (scheduling, RBAC, workflows) labels Apr 25, 2026
@houko
houko merged commit 10ee105 into main Apr 25, 2026
22 checks passed
@houko
houko deleted the fix/cron-webhook-ssrf-runtime branch April 25, 2026 15:04
@github-actions github-actions Bot removed the ready-for-review PR is ready for maintainer review label Apr 25, 2026
@houko houko mentioned this pull request Apr 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/kernel Core kernel (scheduling, RBAC, workflows) size/M 50-249 lines changed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant