fix(core,extensions): 보안 결함 3건과 이중저장소·레이아웃 중복키 결함군 폐쇄

KISA 제보 3건(KVE-2026-2010/2011/2018)과 그 동일 계열 형제 결함을 전수 조치하고,
그 과정에서 드러난 두 결함군을 함께 닫는다.

- 검증 시점과 연결 시점이 host 를 다르게 읽던 SSRF 통로를 정규화 SSoT 한 곳으로 모았다
- 세션을 여는 지점(2FA 완료·토큰 재발급)이 잠금 검사를 거치지 않아 계정 잠금이 우회됐다
- 인증도 서명도 없는 브라우저 리턴 콜백이 주문 상태를 바꾸던 통로를 4 PG 전부에서 닫고,
 소유권을 대조하는 close-report 를 토스에도 신설했다. 그 결과 정리 주체를 잃는
 결제창 미완료 주문은 만료 자동취소가 거둔다
- 저장소 A(_local)에만 쓰는 경로가 B 의 값을 조용히 덮던 회귀를 정본 writer 로 닫았다
 (engine-v1.63.5). 한 방향만 보던 정적 검사에 반대 방향 축과 양방향 계약 테스트를 더했다
- 레이아웃 JSON 의 같은 객체 중복 키가 앞선 선언을 오류 없이 삼키던 결함군을 닫았다
This commit is contained in:
HeuJung committed 2026-09-02 17:36:11 +09:00
1 parent d4439ea30a
commit 21fc114f37
137 files changed
+6470 -829

No files matched your search

+45 -14
View File
@@ -100,20 +100,7 @@ class AuthService
// 사전 잠금 체크 — 잠긴 계정은 Auth::attempt 자체를 시도하지 않는다.
// (실패 카운트가 0 으로 리셋된 잠금 상태에서 Failed 이벤트가 다시
// 카운트를 올려 재잠금 시각을 갱신하는 부작용 방지)
if ((bool) g7_core_settings('security.login_attempt_enabled', true)) {
$candidate = $this->userRepository->findByEmail($email);
if ($candidate !== null && $this->userRepository->isLocked($candidate)) {
// 영구 잠금은 해제 시각이 없다 — diffInSeconds(null) 로 폭발하지 않도록 분기.
$remaining = $candidate->locked_until === null
? null
: max(1, (int) ceil(now()->diffInSeconds($candidate->locked_until, false) / 60));
throw new AccountLockedException(
lockedUntil: $candidate->locked_until,
remainingMinutes: $remaining,
);
}
}
$this->assertNotLocked($this->userRepository->findByEmail($email));
if (! Auth::attempt(['email' => $email, 'password' => $password])) {
// 실패 카운트 증가/잠금 처리는 HandleFailedLoginListener 에서 담당
@@ -158,6 +145,40 @@ class AuthService
return $this->issueLoginSession($user, $email);
}
/**
* 계정이 잠겨 있으면 예외를 던집니다.
*
* 세션(토큰)을 발급하는 지점은 전부 이 검사를 거쳐야 합니다. 2단계 인증이 켜져 있으면
* 비밀번호 확인(`login`)은 challenge 만 돌려주고 실제 세션은 `completeTwoFactor()` 가
* 발급하므로, 한쪽에만 검사가 있으면 잠기기 전에 받아 둔 challenge 를 잠긴 뒤 완료하는
* 것만으로 잠금이 통째로 우회됩니다. 그 뒤 로그인 완료 훅이 실패 횟수·잠금 시각까지
* 초기화해 흔적도 남지 않습니다.
*
* @param User|null $user 검사 대상 사용자 (없으면 검사 대상 아님)
*
* @throws AccountLockedException 계정이 잠겨 있을 때
*/
private function assertNotLocked(?User $user): void
{
if (! (bool) g7_core_settings('security.login_attempt_enabled', true)) {
return;
}
if ($user === null || ! $this->userRepository->isLocked($user)) {
return;
}
// 영구 잠금은 해제 시각이 없다 — diffInSeconds(null) 로 폭발하지 않도록 분기.
$remaining = $user->locked_until === null
? null
: max(1, (int) ceil(now()->diffInSeconds($user->locked_until, false) / 60));
throw new AccountLockedException(
lockedUntil: $user->locked_until,
remainingMinutes: $remaining,
);
}
/**
* 이 사용자에게 2단계 인증을 요구해야 하는지 판정합니다.
*
@@ -268,6 +289,10 @@ class AuthService
]);
}
// 세션을 여는 것은 이 지점이다 — challenge 발급 이후에 잠겼을 수 있으므로 재검사한다.
// Auth::login() 앞에 두어야 로그인 완료 훅이 잠금 필드를 초기화하지 못한다.
$this->assertNotLocked($user);
Auth::login($user);
return $this->issueLoginSession($user, (string) $user->email);
@@ -446,9 +471,15 @@ class AuthService
*
* @param User $user 토큰을 갱신할 사용자
* @return array 새로운 토큰 정보
*
* @throws AccountLockedException 계정이 잠겨 있을 때
*/
public function refreshToken(User $user): array
{
// 재발급도 세션을 여는 지점이다. 유효한 기존 세션이 전제라 신규 로그인 우회는
// 아니지만, 관리자가 계정을 잠근 뒤에도 그 세션이 무기한 연장되면 잠금이 실효를 잃는다.
$this->assertNotLocked($user);
// 현재 토큰 삭제 (다른 디바이스는 유지)
$currentToken = $user->currentAccessToken();