Files
Gnuboard7/config/schedule_security.php
T
HeuJung febffb173e fix(core,admin-template): GC 스케줄 허용목록 동기 + 스토리지 잔존물 GC 신설 + 스케줄 모달 저장 회귀 수정
공개 후속 전수 조사의 실작업:
- attachments:prune-orphans 관리자 예약 허용목록 등재 + 가드 테스트 도출 규칙을
 런타임 validator 와 일치 (옵션 포함 키는 영원히 매칭되지 않는 죽은 항목)
- layout-previews:cleanup 을 gc-schedules 가드 구간으로 편입 (+onOneServer)
- storage:prune-leftovers 신설: 중단된 업데이트/설치의 _pending 스테이징·코어 임시·
 vendor 스테이징(3일)과 오래된 백업(30일, 최신 1개 상시 보존), 레거시 browser.log 회수
 — 산출물 누적 + 회수 경로 부재( 동형) 7건 해소
- 언어팩 설치 임시 디렉토리 정리를 finally 로 이동 (설치 성공 시 100% 누수)
- 브라우저 콘솔 로그를 daily(7일) 로테이션으로 전환 (단일 파일 989MB 실측)
- 검수 중 발견한 스케줄 등록/수정 모달 저장 불능 수정 (Form id 부재 + 커스텀
 Select/Toggle 값 미전송) + 동형 재발 차단 audit 룰 2종 신설
2026-08-17 15:17:20 +09:00

140 lines
6.5 KiB
PHP

<?php
// 스케줄러 Shell/Artisan 실행 보안 정책.
// 관리자 환경설정에 노출하지 않는 코드 소유 정책 — command 실행 능력은 신뢰 경계 안에서만 넓힌다.
// (스케줄 권한만 위임받은 관리자가 화이트리스트를 넓혀 임의 명령 실행을 복구하는 것을 막는다.)
return [
'shell' => [
// Shell 타입 스케줄 실행 자체를 켜는 opt-in 게이트 (기본 차단).
'enabled' => env('SCHEDULE_SHELL_ENABLED', false),
// 허용 실행 파일 basename 목록. 빈 배열이면 모든 shell 명령을 거부한다.
'allowed_binaries' => array_values(array_filter(array_map(
'trim',
explode(',', (string) env('SCHEDULE_SHELL_ALLOWED_BINARIES', '')),
))),
],
'artisan' => [
// 실행을 허용하는 artisan 명령 목록 (허용목록 — 여기 없으면 거부).
//
// 차단목록 방식은 등록 명령 238개 중 9개만 막아 나머지를 무조건 허용했고,
// `migrate:refresh` 가 빠져 있는 등 "빠뜨림" 이 구조적으로 반복됐다.
// 코드 생성·스키마 변경·비밀값 접근이 없는 유지보수 명령만 등재한다.
//
// 각 항목의 `options` 는 허용 롱옵션 이름(`--` 없이)이며, 선언되지 않은 옵션은 거부한다.
// 실제 시그니처(`getDefinition()`)를 확인해 채운 값이다 — 경로·클래스·파일을 지정하거나
// 안전장치를 무력화하는 옵션(`--path` `--model` `--force` `--daemon` 등)은 제외했다.
// `max_arguments` 는 허용 위치 인자 개수이며 생략 시 0 이다.
'allowlist' => [
// 캐시·컴파일 산출물 정리
'cache:clear' => ['options' => [], 'max_arguments' => 0],
'config:clear' => ['options' => []],
'route:clear' => ['options' => []],
'view:clear' => ['options' => []],
'event:clear' => ['options' => []],
'optimize:clear' => ['options' => []],
'hooks:clear' => ['options' => []],
'hooks:cache' => ['options' => []],
// 큐
'queue:restart' => ['options' => []],
'queue:prune-failed' => ['options' => ['hours']],
'queue:prune-batches' => ['options' => ['hours', 'unfinished', 'cancelled']],
'queue:work' => ['options' => [
'queue', 'once', 'stop-when-empty', 'stop-when-empty-for',
'delay', 'backoff', 'max-jobs', 'max-time',
'memory', 'sleep', 'rest', 'timeout', 'tries',
]],
// 만료 데이터 정리
'auth:clear-resets' => ['options' => []],
'sanctum:prune-expired' => ['options' => ['hours']],
'model:prune' => ['options' => ['chunk', 'pretend']],
'notification:cleanup' => ['options' => []],
'layout-previews:cleanup' => ['options' => []],
'ext-bundles:cleanup' => ['options' => []],
'seo:prune-stats' => ['options' => ['days']],
'schedules:prune-history' => ['options' => ['days']],
'identity:expire-challenges' => ['options' => []],
'identity:prune-logs' => ['options' => ['days']],
'activity-log:prune' => ['options' => ['days']],
'notification-log:prune' => ['options' => ['days']],
// 실삭제가 기본이나 사용자 파일 파기는 커맨드 자체가 설정 토글·보존기간으로 이중 확인한다.
'attachments:prune-orphans' => ['options' => ['dry-run', 'limit', 'days', 'scheduled']],
// 잔존물 정리 — 최신 백업 1개 상시 보존 가드는 커맨드 내부 소유(옵션으로 무력화 불가).
'storage:prune-leftovers' => ['options' => ['days', 'backup-days', 'dry-run']],
// SEO
'seo:warmup' => ['options' => ['layout']],
'seo:clear' => ['options' => ['layout']],
'seo:generate-sitemap' => ['options' => ['sync', 'rebuild', 'mode']],
// 기타 유지보수
'geoip:update' => ['options' => ['dry-run']],
'search:index' => ['options' => ['filter']],
'inspire' => ['options' => []],
],
// 설치된 확장이 소유한 명령을 자동으로 허용할지 여부.
// 확장 설치는 서버에 코드를 배치하는 행위로 이미 스케줄 권한보다 높은 신뢰를 요구하고,
// 그 확장의 getSchedules() 명령은 이미 무인 실행되고 있다. 필요 시 끌 수 있다.
'allow_extension_commands' => true,
// 확장 소유 판정 기준 — 명령 인스턴스의 클래스 네임스페이스 접두사.
// Symfony 가 실제 실행에 쓰는 레지스트리를 보므로 이름만으로는 위조할 수 없다.
'extension_namespaces' => ['Modules\\', 'Plugins\\'],
// 최종 거부권. 허용목록·확장 자동 허용보다 먼저 평가되어,
// 확장이 코어 명령 이름을 가로채 등록하는 경우도 막는다.
'denylist' => [
// 임의 코드 실행
'tinker',
'invoke-serialized-closure',
// 스키마·데이터 파괴
'db',
'db:wipe',
'db:seed',
'schema:dump',
'migrate',
'migrate:fresh',
'migrate:reset',
'migrate:rollback',
'migrate:refresh',
'migrate:install',
// 비밀값·환경
'env',
'env:encrypt',
'env:decrypt',
'key:generate',
// 서비스 상태 조작
'schedule:run',
'schedule:work',
'serve',
'down',
'up',
'test',
'clear-compiled',
// 파일 배치·코어/확장 변경
'stub:publish',
'vendor:publish',
'package:discover',
'core:update',
'core:build',
'core:execute-upgrade-steps',
'core:execute-bundled-updates',
'extension:composer-install',
'module:install',
'plugin:install',
'template:install',
'module:seed',
'plugin:seed',
'hotfix:rollback-stale-files',
'playwright:issue-token',
],
// 접두사 단위 거부권. `make:*` 41개를 일일이 나열하지 않는다.
'denylist_prefixes' => ['make:'],
],
];