← PHP / Laravel 목차

PHP-057 / 중급

API 응답에 모델 전체 노출 (민감 속성 포함)

A01:2021 Broken Access Control · CWE-200 Exposure of Sensitive Information

왜 문제가 될까요?

password, remember_token, 내부 플래그가 JSON에 포함된다.

이렇게 수정하세요

php
class User extends Model { protected $hidden = ['password', 'remember_token']; }
return UserResource::collection(User::all());  // API Resource로 필드 명시

더 읽기