Skip to content

SSRF: validate user-supplied destinations for webhooks, SMTP and IMAP #97

Open

Description

@JuansesDev

Problem

Three features open outbound connections to hosts chosen by the user, and none of them validates the destination beyond the URL scheme:

  • Outbound webhooks — POST /projects/{id}/webhooks accepts any http/https URL. A webhook pointing at http://169.254.169.254/latest/meta-data/, http://redis:6379/ or http://localhost:8080/api/v1/... makes SendDock issue the request from inside the deployment's network.
  • Project SMTP host and bounce IMAP host — the server dials whatever host:port the project configures, which can be used to probe internal services.

On a self-hosted install the attacker must already be a project member, so the impact is moderate. On a multi-tenant cloud it is critical: any free account can map and poke internal infrastructure, including cloud metadata endpoints.

Proposal

Add a single destination-validation helper and use it everywhere the server connects to a user-supplied host:

  • Resolve the hostname and reject any address in loopback, private (RFC 1918), link-local, unique-local, multicast, unspecified and cloud-metadata ranges, for both IPv4 and IPv6.
  • Re-validate on every connection attempt, not only at save time, and dial the validated IP (or pin the resolved address) so a DNS answer that changes after validation cannot bypass the check.
  • Reject webhook URLs with embedded credentials and non-standard ports outside an allowlist (80/443 by default; make the allowlist configurable for self-hosters who legitimately target internal endpoints).
  • Return a clear 400 on save ("destination resolves to a private or reserved address") and log a WARN with project id on rejected delivery-time attempts.
  • Self-host escape hatch: an explicit instance setting to allow private destinations, off by default, surfaced in the dashboard with a warning — some self-hosters do run their SMTP relay on a private address.

Acceptance

  • Shared validator covering IPv4/IPv6 private, loopback, link-local, ULA, multicast, unspecified and metadata ranges, with unit tests per range
  • Webhook create/update, SMTP settings save and IMAP settings save reject private destinations with a 400
  • Webhook dispatcher, SMTP sender and IMAP poller re-validate at connection time and refuse to dial rejected addresses
  • Instance-level override for private destinations, off by default, audited when toggled
  • Docs: security note on the webhooks, SMTP and bounces pages; configuration page documents the override
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions