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
@@ -6,6 +6,7 @@ use App\Contracts\Extension\StorageInterface;
|
||||
use App\Contracts\Repositories\AttachmentRepositoryInterface;
|
||||
use App\Enums\AttachmentSourceType;
|
||||
use App\Extension\HookManager;
|
||||
use App\Helpers\PermissionHelper;
|
||||
use App\Models\Attachment;
|
||||
use App\Models\User;
|
||||
use App\Support\ImageResizer;
|
||||
@@ -231,6 +232,8 @@ class AttachmentService
|
||||
*/
|
||||
public function reorder(array $orderData): void
|
||||
{
|
||||
$this->assertReorderWithinScope($orderData);
|
||||
|
||||
// Before 훅
|
||||
HookManager::doAction('core.attachment.before_reorder', $orderData);
|
||||
|
||||
@@ -240,6 +243,44 @@ class AttachmentService
|
||||
HookManager::doAction('core.attachment.after_reorder', $orderData);
|
||||
}
|
||||
|
||||
/**
|
||||
* 순서 변경 대상이 액터의 스코프 안에 있는지 검사합니다.
|
||||
*
|
||||
* `PATCH admin/attachments/reorder` 는 라우트 모델이 없는 정적 경로다. PermissionMiddleware
|
||||
* 는 `$request->route('attachment')` 가 Model 일 때만 스코프를 검사하고 없으면 목록
|
||||
* 엔드포인트로 보아 건너뛰므로(`PermissionMiddleware`), 상세 경로(`DELETE {attachment}`)가
|
||||
* 미들웨어로 강제하는 스코프 축이 이 경로에서만 비어 있었다. 배포 기본 역할 `manager` 가
|
||||
* `core.attachments.update` 를 `self` 스코프로 보유하므로 이론 구성이 아니라 기본값에서
|
||||
* 성립한다 — 타인 소유 첨부의 순서를 바꿀 수 있었다.
|
||||
*
|
||||
* 대상 일부만 걸러내지 않고 **전체를 거부**한다. 순서는 집합 전체에 대한 하나의 배열이라
|
||||
* 일부만 반영하면 나머지와 어긋난 순서가 저장되기 때문이다(사용자 일괄 상태변경이
|
||||
* "제외" 를 택한 것과 의미론이 다르다).
|
||||
*
|
||||
* @param array<int, array{id: int, order: int}> $orderData 순서 데이터
|
||||
*
|
||||
* @throws AuthorizationException 스코프 밖 첨부가 하나라도 포함된 경우
|
||||
*/
|
||||
private function assertReorderWithinScope(array $orderData): void
|
||||
{
|
||||
$ids = array_values(array_unique(array_filter(
|
||||
array_map(static fn ($item): int => (int) ($item['id'] ?? 0), $orderData)
|
||||
)));
|
||||
|
||||
if (empty($ids)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$attachments = $this->repository->findByIds($ids);
|
||||
|
||||
// 판정은 상세 경로와 같은 SSoT 에 위임한다 — 여기서 재구현하면 두 경로의 강도가 갈린다.
|
||||
$permitted = PermissionHelper::filterByScope($attachments, 'core.attachments.update');
|
||||
|
||||
if (count($permitted) !== $attachments->count()) {
|
||||
throw new AuthorizationException(__('auth.scope_denied'));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 다운로드 응답 생성
|
||||
*
|
||||
|
||||
Reference in new issue
Block a user