Skip to content
Open redirect Write-up Beginner

How Loose Regex Can Earn You a Bounty for an Open Redirect Filter Bypass Bug

A site used a loose regex to validate redirect URLs, checking only that the string 'examplesite.com/' appeared somewhere and the URL ended with an image extension. An attacker could craft a URL with the trusted domain in the query string to redirect users to a malicious site.

halfcircassian Follow

Published on medium.com

In this blog, discover how a tiny oversight in a regex can lead to a serious open redirect vulnerability — and a sweet bug bounty.

Sıla Ö. H., on medium.com

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 regex used unanchored wildcards and only checked for a substring, so it did not verify the actual host of the URL.

Impact

A user clicking the crafted link could be redirected to an attacker-controlled site, enabling phishing or other attacks.

What the attacker needed

Victim clicks a crafted link

The fix

The regex should be anchored and the URL properly parsed to check the actual domain, not just a substring.

How it was found

  1. The site uses a regex to allow redirects only to examplesite.com and only to image files.
  2. The regex checks that the URL contains 'examplesite.com/' and ends with .jpg, .jpeg, or .png, but does not anchor the domain to the start.
  3. An attacker crafts a URL with the trusted domain in the query string and an image extension at the end.
  4. The regex matches because the trusted domain appears somewhere and the URL ends with an image extension.
  5. The browser interprets the URL as pointing to the attacker's domain, so the user is redirected there.

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.

A website tried to stop open redirects by checking if a link contained its own domain name and ended with an image file extension. But the check was too loose: it only looked for the domain name anywhere in the link, even after a question mark. So an attacker could put the trusted domain in the query part of a link to their own site, and the check would pass, sending victims to the attacker's site.

What is Open redirect?

A trusted site forwards users to any address an attacker picks; rarely paid alone, often the missing link in a chain.

Similar reports

View all

Same bug class and techniques, clearest first.

Open redirect

The lesson behind this report.

A trusted site forwards users to any address an attacker picks; rarely paid alone, often the missing link in a chain.