← PHP / Laravel · 目次

PHP-007 / 初級

IDOR:リソース所有権の確認欠落

A01:2021 Broken Access Control · CWE-639 Authorization Bypass via User-Controlled Key

なぜ問題になるのか?

ID を変更するだけで他人の注文・文書にアクセスできます。

修正方法

php
public function show(Order $order) {
    $this->authorize('view', $order);  // Policy で user_id を比較
    return $order;
}

参考資料