Skip to content

[BUG] TOCTOU DNS Rebinding Vulnerability in Webhook Dispatch #3169

Closed

Description

@nyxsky404

Bug Description

The application allows outbound webhooks. To prevent Server-Side Request Forgery (SSRF), it checks isSafeUrl(), which performs a DNS lookup to ensure the IP isn't internal (e.g., 127.0.0.1, AWS Metadata 169.254.169.254). However, after passing the check, fetch(webhook.url) is called. This forces a second DNS resolution.

This introduces a classic Time-of-Check to Time-of-Use (TOCTOU) vulnerability. An attacker can set up a DNS server with an extremely low TTL. The first request (the check) returns a safe, public IP. The second request (the fetch) returns an internal IP (like 169.254.169.254). The attacker can then exfiltrate the serverless container's IAM roles, internal network topology, or hit internal databases.

Steps to Reproduce

  1. Register an outbound webhook with a URL pointing to an attacker-controlled DNS server (e.g., http://rebind.attacker.com).
  2. Configure the DNS server to return 8.8.8.8 on the first resolution, and 169.254.169.254 on the second resolution.
  3. Trigger the webhook dispatch.
  4. Observe that the SSRF check passes, but the subsequent fetch hits the internal AWS Metadata IP or local services.

Affected Area

API Routes

Screenshots

No response

Browser & OS

No response

Environment

Both

Additional Context

Suggested Fix:

  1. Modify isSafeUrl to return the resolved, safe IP address instead of a boolean.
  2. Pass this exact IP address directly to the fetch call.
  3. Override the Host header in the fetch options to match the original URL's hostname so the target server processes it correctly, ensuring the IP used is explicitly pinned.

Activity

  1. nyxsky404 commented on Jul 8, 2026

    @nyxsky404
    ContributorAuthor

    Hi! @Priyanshu-byte-coder
    I would like to work on this issue under gssoc'26. Please /assign this issue to me

  2. github-actions commented on Jul 8, 2026

    @github-actions

    Assigned to @nyxsky404! You have 7 days to open a PR. No PR after 7 days = auto-unassigned so others can pick it up. Good luck!

  3. github-actions commented on Jul 16, 2026

    @github-actions

    Hey @nyxsky404 — this issue was assigned 7 days ago with no PR opened. Unassigning so others can pick it up.

    Still working on it? Drop a comment and request re-assignment.

  4. github-actions commented on Jul 16, 2026

    @github-actions

    ✅ Closed as completed!

    If DevTrack has been useful, a ⭐ star on the repo helps the project grow and reach more developers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions