Menu

1 / 2

Why 'contains our hostname' fails as an open redirect check

DEV Community: appsec·Rocky·4 days ago
#P3rMkwDf
#devtoappsec#devto#dev#example#evil
Long article (500 words) — no AI summary yet.
Reading 0:00
15s threshold

The first fix for an open redirect is nearly always the wrong one. Someone sees that a login page sends users wherever the next parameter says, adds a check that the URL contains the trusted hostname, and closes the ticket.

A scenario

Picture a login page at app.example.com. After sign-in it redirects to the value of next . The guard reads: the URL must contain app.example.com . All of these pass:

https://app.example.com.evil.example/ https://evil.example/?app.example.com https://[email protected]/

Enter fullscreen mode

Exit fullscreen mode

The first one puts the trusted name inside a domain the attacker owns. The second hides it in the query string. The third relies on the URL userinfo syntax: text before the @ is a username, so the browser connects to evil.example and treats app.example.com as a login name.

Why "starts with" does not rescue it

Changing the test to "starts with https://app.example.com " kills the second payload and leaves the first and third.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.