Fix open redirect in tag.php + language.php: reject protocol-relative URLs (//evil.com) by also checking for // prefix

This commit is contained in:
Pontoporeia
2026-06-24 14:15:14 +02:00
parent 6ecd3d4540
commit 84869ad968
3 changed files with 13 additions and 7 deletions

View File

@@ -74,9 +74,10 @@ try {
}
$redirect = '/admin/contenus.php';
// Allow the caller to override the redirect
if (!empty($_POST['return']) && str_starts_with($_POST['return'], '/')) {
$redirect = $_POST['return'];
// Allow the caller to override the redirect (same-origin only, no protocol-relative)
$return = $_POST['return'] ?? '';
if ($return !== '' && str_starts_with($return, '/') && !str_starts_with($return, '//')) {
$redirect = $return;
}
header('Location: ' . $redirect);
exit();