fix(installer): 설치 상태 파일에 관리자 비밀번호가 평문으로 잔존하는 문제

비밀을 state.json(0664, 실패 시 무기한 잔존)에 기록하지 않고
runtime.php(0600, finalize 시 삭제)로 채널을 일원화한다.

정상 완료 경로에서는 finalize 가 state.json 을 삭제하지만, finalize
미호출 / unlink 실패 / 설치 중단 시에는 평문이 영구히 남았고, finalize
가드가 재호출을 410 차단해 자가 회복도 불가능했다. 삭제라는 단일 경로에
의존해 평문을 보호하던 구조 자체를 제거한다.

SSE 워커는 세션에 접근할 수 없어 파일 경유가 불가피한데, 그 파일이 0664 의
state.json 이었던 것이 구조적 원인이다. 세션을 보유한 유일한 공통 시작점인
install-process.php 를 비밀 이송 지점으로 삼고, db_seed 가 소비한 즉시
제거한다. 레거시 / 실패 경로는 완료·중단·초기화·finalize 시점 redact 로 방어.

동반 수정:
- 세션 config 재병합으로 무력화되던 기존 DB 비밀번호 마스킹 복구
- db_seed 후 putenv 미해제로 모든 exec 자식에 평문이 ENV 상속되던 누출 차단
- runtime read 비밀번호 폴백이 write 값으로 잘못 대체되던 문제 ( 인접)

이미 설치된 사이트는 7.0.4 업그레이드 스텝이 잔존 파일을 정리한다.
완료 증거가 있으면 삭제하고, 설치 진행 중일 수 있으면 비밀만 제거한다.
This commit is contained in:
HeuJung committed 2026-07-13 17:00:59 +09:00
1 parent ae447c9cc4
commit 9be8faaea2
16 files changed
+1534 -119

No files matched your search

+27 -20
View File
@@ -5,18 +5,18 @@
* @author sirsoft
*/
require_once __DIR__ . '/includes/config.php';
require_once __DIR__ . '/includes/functions.php';
require_once __DIR__ . '/includes/session.php';
require_once __DIR__ . '/includes/installer-state.php';
require_once __DIR__ . '/includes/request-handler.php';
require_once __DIR__ . '/api/_guard.php';
require_once __DIR__.'/includes/config.php';
require_once __DIR__.'/includes/functions.php';
require_once __DIR__.'/includes/session.php';
require_once __DIR__.'/includes/installer-state.php';
require_once __DIR__.'/includes/request-handler.php';
require_once __DIR__.'/api/_guard.php';
installer_guard_or_410();
$currentLang = getCurrentLanguage();
// 세션 기반 단계 관리 (URL 파라미터 무시)
if (!isset($_SESSION['installer_current_step'])) {
if (! isset($_SESSION['installer_current_step'])) {
// 세션이 없으면 state.json에서 현재 step 가져오기
$state = getInstallationState();
@@ -33,10 +33,10 @@ $currentStep = $_SESSION['installer_current_step'];
// URL 파라미터로 step 접근 시 알림 후 리다이렉트
if (isset($_GET['step'])) {
$urlStep = (int)$_GET['step'];
$urlStep = (int) $_GET['step'];
// 번역 로드
if (!isset($translations)) {
if (! isset($translations)) {
$translations = loadTranslations($currentLang);
}
@@ -46,14 +46,14 @@ if (isset($_GET['step'])) {
lang('url_parameter_not_supported'),
lang('url_parameter_redirect_message', [
'requested' => $urlStep,
'current' => $currentStep
'current' => $currentStep,
]),
INSTALLER_BASE_URL . '/'
INSTALLER_BASE_URL.'/'
);
}
// 같은 경우에도 깔끔한 URL로 리다이렉트
header('Location: ' . INSTALLER_BASE_URL . '/');
header('Location: '.INSTALLER_BASE_URL.'/');
exit;
}
@@ -65,11 +65,18 @@ $error = null;
// Step 3 기본값 설정
if ($currentStep === 3) {
$defaults = DEFAULT_INSTALL_CONFIG;
$defaults['app_url'] = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? 'https' : 'http') . '://' . $_SERVER['HTTP_HOST'];
$defaults['app_url'] = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? 'https' : 'http').'://'.$_SERVER['HTTP_HOST'];
$defaults['admin_language'] = getCurrentLanguage();
// state.json에서 비밀번호 제외된 config 복원 (세션에서 비밀번호를 사전 입력하지 않음)
// state.json에서 비밀번호 제외된 config 복원 (폼에 비밀번호를 사전 입력하지 않음).
// state 에는 이미 비밀이 기록되지 않지만(이슈 #465), 레거시 state.json 이 남아 있는
// 환경에서도 평문이 HTML 로 렌더되지 않도록 프리필 단계에서 다시 제거한다.
$savedConfig = $state['config'] ?? $defaults;
unset($savedConfig['db_write_password'], $savedConfig['db_read_password']);
unset(
$savedConfig['db_write_password'],
$savedConfig['db_read_password'],
$savedConfig['admin_password'],
$savedConfig['admin_password_confirm']
);
$formData = array_merge($defaults, $savedConfig);
}
@@ -82,7 +89,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
}
// 번역 로드
if (!isset($translations)) {
if (! isset($translations)) {
$translations = loadTranslations($currentLang);
}
@@ -91,7 +98,7 @@ if ($currentStep < 0 || $currentStep > 6) {
$currentStep = 0;
}
$stepFile = __DIR__ . '/views/' . $currentStep . '-' . (STEP_FILE_MAP[$currentStep] ?? 'welcome') . '.php';
$stepFile = __DIR__.'/views/'.$currentStep.'-'.(STEP_FILE_MAP[$currentStep] ?? 'welcome').'.php';
?>
<!DOCTYPE html>
<html lang="<?= $currentLang ?>">
@@ -119,7 +126,7 @@ $stepFile = __DIR__ . '/views/' . $currentStep . '-' . (STEP_FILE_MAP[$currentSt
<link rel="stylesheet" href="<?= INSTALLER_BASE_URL ?>/assets/css/installer.css?v=<?= time() ?>">
</head>
<body>
<?php if ($currentStep > 0): ?>
<?php if ($currentStep > 0) { ?>
<!-- Installer Header Bar -->
<div class="installer-header-bar">
<div class="installer-header-content">
@@ -142,7 +149,7 @@ $stepFile = __DIR__ . '/views/' . $currentStep . '-' . (STEP_FILE_MAP[$currentSt
</div>
</div>
</div>
<?php endif; ?>
<?php } ?>
<!-- Main Content -->
<?php
@@ -151,7 +158,7 @@ $stepFile = __DIR__ . '/views/' . $currentStep . '-' . (STEP_FILE_MAP[$currentSt
} else {
showStepFileNotFoundError($currentStep);
}
?>
?>
<!-- Installer Footer -->
<footer class="installer-footer">