I know that:
Redirects that do not validate user input can enable attackers to launch phishing scams, steal user credentials, and perform other malicious actions.
like this :
res.redirect(req.query.url);
but is this redirection UNSAFE too ?
res.redirect(req.header('Referer') || '/');
EDIT
My website is multi-page so when I want to show error messages to user, I send flash message and redirect it to last page :
back(req , res) {
req.flash('formData' , req.body);
return res.redirect(req.header('Referer') || '/');
}
So if header ('Referer') is unsafe, what's the SAFE way ?