fix(security): KVE-2026-1914/1915/1919 remediation 전건
위임 관리자(부관리자)가 권한·역할·표현식·비밀 콘텐츠 경계를 우회하던 결함군을 계층 대칭성 원칙으로 전건 차단한다. 약한 경로가 정상 응답을 내보내는 것이 유일한 증상이라, 게이트를 생산 지점 한 곳(SSoT)에 두고 같은 데이터를 내보내는 소비 경로 전부가 그 게이트를 경유하도록 맞췄다. - 등급 상한(rank ceiling): 슈퍼관리자 보호·역할/사용자 역할 배정(추가·제거 대칭)·일괄 상태변경·순서변경을 상세 경로와 동일 강도로 재적용. 가드는 DB 쓰기에 선행하여 거부 시 상태 불변. - 레이아웃 표현식: new Function/with 실행을 AST 화이트리스트 평가기로 교체. 비-문자열 computed 키 정규화(normalizeKey)·Object facade(리플렉션 static 제거)·legacy 접근자 차단. 저장측 검증·정적 검사와 3계층 동형. - secret 게이트: 비밀글의 댓글·첨부·문의 독립 경로 재적용, hash 파일서빙 소유권·비밀·발행 상태 검사 통일. - 신뢰 스크립트 호스트: 확장 선언 기반 + same-origin 브라우저 정규화를 런타임·저장측·정적검사 3층 동형화. - 회귀 감지: 단위·Feature·E2E·시나리오 매니페스트 전축 + audit 룰 4종 신설.
This commit is contained in:
1 parent
cd84b63d2b
commit
71abdeaf60
249 files changed
+14354
-1134
No files matched your search
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature\Security;
|
||||
|
||||
use App\Exceptions\CannotModifyProtectedRoleException;
|
||||
use App\Exceptions\CannotModifySuperAdminException;
|
||||
use App\Exceptions\PermissionEscalationException;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
* 등급 상한 예외 3종의 전역 렌더러(bootstrap/app.php) 계약 테스트
|
||||
*
|
||||
* KVE-2026-1919 가 도입한 렌더러는 심층 방어다 — 현재 호출부(UserController /
|
||||
* RoleController)는 전부 로컬 catch 로 403 을 만들기 때문에, 렌더러 블록을 통째로
|
||||
* 지워도 기존 스위트는 전부 green 이 된다. 그러면 "새 호출부가 로컬 catch 없이
|
||||
* 던져도 조용한 500 대신 403" 이라는 렌더러의 존재 이유가 검증되지 않은 채 남는다.
|
||||
*
|
||||
* 그래서 로컬 catch 가 없는 경로를 테스트 안에서 만들어 렌더러 자신을 직접 건다.
|
||||
*/
|
||||
class SecurityExceptionRendererTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* 로컬 catch 없이 던져진 등급 상한 예외 3종이 500 이 아닌 403 으로 렌더된다.
|
||||
*
|
||||
* @param string $exceptionClass 던질 예외 클래스
|
||||
* @param string $langKey 기대 메시지의 lang 키
|
||||
*
|
||||
* @effects ceiling_exceptions_render_as_403_without_local_catch
|
||||
*/
|
||||
#[DataProvider('ceilingExceptionProvider')]
|
||||
public function test_ceiling_exceptions_render_as_403_without_local_catch(string $exceptionClass, string $langKey): void
|
||||
{
|
||||
Route::middleware('api')->get('/api/_test/ceiling-render', function () use ($exceptionClass) {
|
||||
throw new $exceptionClass;
|
||||
});
|
||||
|
||||
$response = $this->getJson('/api/_test/ceiling-render');
|
||||
|
||||
$response->assertStatus(403);
|
||||
$response->assertJson([
|
||||
'success' => false,
|
||||
'message' => __($langKey),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 예외 3종 × 대응 lang 키
|
||||
*
|
||||
* @return array<string, array{0: class-string, 1: string}>
|
||||
*/
|
||||
public static function ceilingExceptionProvider(): array
|
||||
{
|
||||
return [
|
||||
'super admin 보호' => [CannotModifySuperAdminException::class, 'exceptions.cannot_modify_super_admin'],
|
||||
'보호 역할' => [CannotModifyProtectedRoleException::class, 'exceptions.cannot_modify_protected_role'],
|
||||
'권한 상승' => [PermissionEscalationException::class, 'exceptions.cannot_grant_unheld_permission'],
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user