Harden products batch return_url: reject quotes and nested back
This commit is contained in:
@@ -621,7 +621,23 @@ class ProductController extends Controller
|
||||
return $default;
|
||||
}
|
||||
|
||||
return str_starts_with($candidate, '/merchant-admin/products') ? $candidate : $default;
|
||||
// 作为“批量操作返回地址”,只允许站内相对路径,并且需要稳定可控:
|
||||
// - 限定前缀(避免跳出 merchant-admin/products 语义域)
|
||||
// - 拒绝引号/尖括号(降低注入风险)
|
||||
// - 拒绝 nested back=(避免 URL 膨胀/绕过)
|
||||
if (! str_starts_with($candidate, '/merchant-admin/products')) {
|
||||
return $default;
|
||||
}
|
||||
|
||||
if (preg_match('/["\'<>]/', $candidate)) {
|
||||
return $default;
|
||||
}
|
||||
|
||||
if (preg_match('/(?:^|[?&])back=/', $candidate)) {
|
||||
return $default;
|
||||
}
|
||||
|
||||
return $candidate;
|
||||
}
|
||||
|
||||
protected function filters(Request $request): array
|
||||
|
||||
Reference in New Issue
Block a user