SSRF URL validation for a webhook or callback address goes wrong in the places that look finished: the host check that strips a trailing dot, the credentials in front of the host, and the path prefix that URL parsing seems to have cleaned. A customer gives your service an address, you store it, and later your service calls it, so the check decides what your own server may be sent to. The textbook faults are well known: private addresses, redirects, DNS rebinding. This guide is about three smaller ones that survive code review because the surrounding code looks careful. We measured each on Node 24.16.0 on 26 November 2026.

They come from the address check of a scheduler service of ours that calls customer URLs. The one-dot trim was a real gap there: the check used to normalize the host on its own and let a host with two trailing dots past our list of own hosts. The encoded path forms we measured while writing its path check, and it has always turned away login details written in front of the host; the Node behaviour behind that refusal we measured for this guide.

Gap 1: one stripped dot leaves the second one in the host

A host name may end in a dot, and https://app.example.com./ points at the same server as the version without it. A check that compares the host against a list of own names, or against a suffix such as .workers.dev, therefore has to remove that dot first. The usual line is hostname.replace(/\.$/, ''), and it takes off a single dot.

In our run, new URL('https://app.example.com../a').hostname came back as app.example.com.., with both dots kept, and app.example.com... kept all three. With the one-dot version, app.example.com. was caught and app.example.com.. was not: it no longer equals the stored name, so a comparison with exact names or an endsWith test lets it through.

An empty label is not something DNS normally resolves, so such an address may never reach your own server in practice. We still do not count that as protection: a fence whose work is done by someone else's resolver stops holding the day the resolver or the platform in between changes.

The fix is to strip every trailing dot, hostname.toLowerCase().replace(/\.+$/, ''), and to put that in a single helper which all comparisons call. Our own code had three different normalisations before we merged them, and each one answered the question "which address is this" slightly differently. Two measures of one identity drift apart; the only open question is when.

Gap 2: credentials in the URL are saved, then every send fails

A URL can carry credentials in front of the host: https://user:pw@hooks.customer.example/h. The URL Standard calls an address that has a non-empty user name or password one that includes credentials (WHATWG URL Standard), and new URL() parses such an address without complaint.

The Fetch Standard then makes the Request constructor throw a TypeError for a string address with credentials (WHATWG Fetch Standard). Node's fetch is built on undici and is documented as browser-compatible (Node.js globals). In our run on Node 24, both fetch and new Request threw TypeError: Request cannot be constructed from a URL that includes credentials for http://user:pw@127.0.0.1:…/h, and also for a user name alone. The same address without credentials returned 200 from a local test server.

So a check that only looks at the host and the path accepts the address, you save it, and every later delivery fails with an error that blames the customer's endpoint although the fault is in the stored string. We did not measure this on Cloudflare Workers, whose fetch is a different implementation; test it there before you rely on either outcome.

There is a second problem in the same address. The form name@host makes a reader name the wrong server. https://good.example.com@evil.example.net/ parses with the host evil.example.net and the user name good.example.com, as we confirmed. An allowlist screenshot, a support ticket or a dashboard that shows the raw string can mislead the person who reads it.

The fix is a refusal with a clear reason: if url.username !== '' || url.password !== '', reject the address at registration. Customers who need a secret put it in a header or a signature, not in the address.

Gap 3: the URL parser collapses some dot segments, not all of them

Many checks tie a stored address to a path prefix: the customer confirmed /hook, so /hook/x is allowed. The standard treats .. as a double-dot segment, and so also .%2e, %2e. and %2e%2e in any letter case (WHATWG URL Standard), and the parser removes them. In our run https://hooks.customer.example/hook/../admin and /hook/%2e%2e/admin both became /admin, so a prefix test on pathname refused them. A backslash form, /hook\..\admin, was collapsed as well.

The parser does not touch the forms where the dot and the slash are glued with a percent sign. These stayed in pathname unchanged:

  • /hook/..%2fadmin and /hook/..%5cadmin
  • /hook/%252e%252e/admin, a doubly encoded dot
  • /hook/..;/admin

For each of them pathname.startsWith('/hook') is true. A receiving server that decodes the path ahead of routing sees /hook/../admin and leaves the prefix. In our test, a single decode turned ..%2f into ../ and %252e%252e into %2e%2e, which is why one pass of decoding is not enough either.

The fix has two parts. Decode the path one segment at a time, so that a single broken sequence such as /50%-off does not hide the others, and refuse the address if a decoded segment is a dot segment or contains a slash, a backslash or a control character such as %00. Then compare the prefix on a segment boundary, so /hook does not cover /hookother; in our run the plain startsWith said yes to that address.

The refusal needs one exception, and a blanket "no %2F" breaks it. GitLab's trigger endpoint uses https://gitlab.com/api/v4/projects/group%2Fproject/trigger/pipeline, where the encoded slash is part of the project path and a legitimate customer may register exactly that. The rule to keep is "no encoded separator that turns into a dot segment", not "no encoded separator at all". Our test cases check both directions: the hostile forms are refused and the GitLab form is accepted.

The known rules these gaps sit next to

Fixing the three gaps does not finish the job. The rules below are standard, and we mention them only so that you do not stop after the gaps:

  • Default port. When the port equals the default of the scheme, the parser stores none, so for https://x:443/ url.port is an empty string. A check that allows only 80 and 443 has to treat the empty string as allowed, and a check that wants to forbid port 80 cannot do it by testing url.port, because http://x/ also has an empty port (WHATWG URL Standard). Forbid the scheme if you want to forbid plain HTTP.
  • Check again at send time. A rule added next month must apply to the addresses stored last month, so the same check runs before every delivery and not only at registration.
  • Private addresses and redirects. OWASP advises an allowlist for the host, a request that you assemble yourself, and a client that does not follow redirects (OWASP SSRF Prevention Cheat Sheet); deny-lists it describes as easy to get around. The parser rewrites 0x7f.1, 2130706433 and 127.1 to 127.0.0.1 in our run, which helps a deny-list but is no reason to prefer one.
  • DNS rebinding. The same cheat sheet warns that a domain allowlist alone does not stop it and asks you to validate the addresses the name resolves to.

A check that can fail

Write each test so that it turns red when the fix is removed, and run it once against the broken version.

  • Two dots. Feed https://your-own-host../a. It must be refused. Replace /\.+$/ with /\.$/ and the test must fail.
  • Credentials. Feed https://user:pw@customer.example/h and https://tok@customer.example/h. Both are refused at registration. Remove the credentials check and the test must fail.
  • Encoded dots. Feed /hook/..%2fadmin, /hook/..%5cadmin and /hook/%252e%252e/admin to a check that covers /hook. All three are refused; /hook/x?y=1 is covered and /hookother is not.
  • The legitimate case. Feed a path with group%2Fproject. It must still pass, otherwise the fix is too broad.
  • A stray percent sign. Feed /hook/50%-off/..%2fadmin. A broken segment must not hide the dot segment next to it.

A test that never failed against the broken version measures nothing. Our scripts ran each variant next to its fixed twin, and the defective one let the hostile address through in each of the three gaps.

When this does not apply

  • No stored addresses. If your service never calls an address that a client gave it, there is nothing to check. A fixed list of partner hosts needs an exact match on the host, and the gaps above matter much less.
  • One runtime, one day. The numbers come from Node 24.16.0 on Windows, run on 26 November 2026. Another Node version, a browser or Cloudflare Workers may treat credentials, dots or encoded segments differently, and we did not measure them.
  • Not measured. We did not test DNS rebinding, redirects from a live server or IPv6 forms. Their entries above come from the OWASP page, not from our runs.
  • A server that does not decode. The path trick needs a receiving server that decodes %2f or %5c before it routes. Many do not, some do, and you rarely know which one the customer runs.
  • A proxy that does the work. If every outgoing call goes through an egress proxy that enforces the network rules, the check in your code is a second layer, not the only one. It still has to refuse what it can refuse, because its answers are what you tell the customer. Response headers are another layer of the same kind; see our piece on headers that stay safe on a live page.

Our skills for this topic

  • URL validation code. Our SSRF URL validation review reads a pasted check for a client-supplied address and points to the places where it passes an address it should refuse or refuses one it should pass, with the cause and the corrected code.

The skills are sold in our store at https://aiskills402.com.

Read this post as Markdown: /blog/ssrf-url-validation-webhook-url-checks-that-fail.md · Atom feed.