← PHP / Laravel · 目次

PHP-017 / 初級

オープンリダイレクト(redirect($request->input('next')))

A01:2021 Broken Access Control · CWE-601 URL Redirection to Untrusted Site

なぜ問題になるのか?

利用者がフィッシングページへ誘導されます。

修正方法

php
$next = $request->input('next');
return redirect()->intended('/home');  // または内部パスのみ許可
// 検査:parse_url($next, PHP_URL_HOST) が null かつ '/' で始まる場合のみ

参考資料