Skip to content
SSRF Write-up Intermediate

From . in regex to SSRF — part 1

An image-converter service accepted a URL embedded in the path and checked the host against a domain whitelist using a regex that treated the dot as a wildcard. An attacker could supply a lookalike domain such as www-example.org to pass the check and make the server fetch an arbitrary URL, giving SSRF.

Niemiec Marcin Follow

Published on xvnpw.github.io

In test of one application I have encountered bug in regex that leaded to Server Side Request Forgery (SSRF). Way of finding it was huge fun and excitement.

Niemiec Marcin (@xvnpw), on xvnpw.github.io

The full write-up lives on its author's site

It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

How it worked

Root cause

Likely the whitelist regex used an unescaped dot, so it matched any character in place of the literal dot in the allowed domain.

Impact

The server could be made to request an attacker-chosen URL, though the text only shows fetching a lookalike domain and does not demonstrate access to internal systems.

What the attacker needed

Access to the image-converter endpoint; attacker controls a lookalike domain

How it was found

  1. Send a request to the image-converter endpoint and observe the JavaScript regex error message.
  2. Try common query parameters and a parameter-discovery tool, which both fail.
  3. Work out that the URL is placed in the path after a width value.
  4. Confirm the service fetches a whitelisted domain.
  5. Try known SSRF bypass payloads, which do not work.
  6. Supply a lookalike domain with a hyphen instead of a dot and see the fetch succeed.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

The service fetches an image from a web address you give it. To stop abuse it only allows addresses on its own domains, but the check used a pattern where a dot matches any character, so a similar-looking domain slipped through. The server then fetched a page the attacker chose, which is called server-side request forgery.

What is SSRF?

The server can be made to fetch an address the attacker chooses, reaching internal services, cloud metadata or other customers' data.

More by Niemiec Marcin

View all

3 more disclosed reports, best first.

Similar reports

View all

Same bug class and techniques, clearest first.

Server-side request forgery (SSRF)

The lesson behind this report.

The server can be made to fetch an address the attacker chooses, reaching internal services, cloud metadata or other customers' data.