Files
Gnuboard7/tests/scenarios/schedule-artisan-command-allowlist.yaml
T
HeuJung 4b6adf4788 fix(security): 예약 작업·언어팩·인스톨러의 차단목록을 허용목록으로 전환
KISA 신고포상제 접수 3건(KVE-2026-1677/1678/1679)의 공통 원인은 하나다 —
"위험한 것을 골라 막았고, 목록 밖으로 우회됐다". 세 지점 모두 판정을 뒤집는다.

예약 작업 Artisan (KVE-2026-1679)
차단 9개 / 허용 229개였던 구조를 허용목록으로 바꾸고 명령마다 허용 옵션을 선언한다.
검증 과정에서 보고서보다 짧은 경로를 추가로 발견했다 — 검증기는 preg_split 의 첫
토큰을 명령명으로 봤지만 실행부는 문자열째 넘겼고, parameters 가 비면 Laravel 이
StringInput 으로 재파싱한다. 따옴표 한 쌍이면 차단목록의 tinker 가 그대로 실행됐다
(마커 파일로 확인). 파서를 엄격 형태 하나로 고정하고 실행은 (명령명, 인자배열)로 넘겨
재해석 지점 자체를 없앴다.

언어팩 (KVE-2026-1678)
위험 함수 11개를 정규식으로 나열하던 검사를 토큰 상태기계로 교체해 "번역 배열만"
통과시킨다. 목록에 없는 함수도, 함수 이름을 아예 쓰지 않는 형태도 원리적으로 막힌다.
파일 형식·PHP 위치·심볼릭 링크도 화이트리스트로 뒤집었다. 활성 승격이 require 배선의
필수 조건이므로 설치와 활성화의 권한 경계를 네 설치 경로 전부에 같은 강도로 건다 —
경로별 면제는 곧 우회로가 되기 때문이다. 화면은 운영자의 활성화 권한을 보고
auto_activate 를 실을지 결정하므로 재설치 흐름은 그대로 동작한다.

인스톨러 (KVE-2026-1677)
실행 바이너리 자리에 인자가 들어가는 것을 형태 규칙으로 차단한다. escapeshellarg 는
"하나의 인자" 임만 보장할 뿐 그 인자가 실행 파일인지 스크립트인지는 보장하지 않는다.
판정을 의존성 0 공용 정책으로 모아 진단 API·설치 워커·저장 시점이 같은 규칙을 쓴다.
stat 은 호출하지 않는다 — 접근이 제한된 서버에서 정상 경로가 거부되던 회귀를
재발시키지 않기 위함이다.

검증: 백엔드 392건 + 프론트 7건 green(skip 1, symlink 미지원 환경). PoC 마커로 red 를
먼저 확보하고, 수정 후 stash 역회귀로 다시 red 가 되는 것까지 확인했다.
2026-08-04 17:48:05 +09:00

95 lines
6.2 KiB
YAML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
feature: 예약 작업 Artisan 명령 허용목록 전환 및 파서 일치
description: |
스케줄의 artisan 타입은 "기본 허용, 차단목록만 거부" 정책이었다. 등록 명령 238개 중
차단은 9개뿐이었고, `migrate:refresh` 가 목록에서 빠져 있는 등 목록 관리 방식이
실패한다는 실증이 코드 안에 이미 있었다. 스케줄 생성·실행 권한을 위임받은 계정이
`make:migration` 으로 임의 경로에 PHP 파일을 만들고 `migrate --path=` 로 실행하는
2단계 체인이 성립했다.
검증 과정에서 보고서보다 짧은 경로를 추가로 발견했다. 검증기는 `preg_split` 의 첫
토큰을 명령명으로 봤지만 실행부는 `Artisan::call($command, [], ...)` 로 문자열째
넘겼고, parameters 가 비면 Laravel 이 문자열 전체를 StringInput 으로 재파싱한다.
그래서 따옴표·백슬래시·선행 옵션 한 쌍이면 차단목록에 있는 `tinker` 가 그대로
실행됐다(`"tinker" --execute=…`). 저장 시점과 실행 시점이 같은 추출기를 공유하므로
이중 검증이 둘 다 뚫렸다.
본 기능은 세 가지를 함께 바꾼다.
- 판정 전환: 3계층(차단목록 최종 거부권 → 코어 정적 허용목록 → 확장 소유 자동 허용)
- 사용법 제한: 허용목록 항목마다 허용 옵션 선언, 위치 인자·단축 옵션 거부
- 파서 일치: 엄격 파서로만 해석하고 실행은 (명령명, 인자배열)로 — 재해석 지점 제거
허용목록으로 바꾸는 것만으로는 해소되지 않는다. 같은 추출기를 쓰면 `"cache:clear"`
로 위장한 뒤 다른 명령이 실행되는 형태로 똑같이 우회되기 때문이다.
axes:
command_class: [core_allowlisted, core_not_allowlisted, denylisted, code_generating, extension_owned, parser_divergent, malformed]
enforcement_point: [validator_unit, store, update, run]
cross_product: |
command_class × enforcement_point 이 핵심이다. 저장 시점과 실행 시점이 같은 판정
함수를 공유해야 하고(한쪽만 고치면 DB 직접 수정이 우회로가 된다), 명령 부류마다
거부 사유가 달라 운영자에게 보이는 메시지가 갈린다.
옵션 형태(허용 옵션 / 미허용 옵션 / 위치 인자 / 단축 옵션)는 별도 axis 로 두지 않는다.
명령명 자체가 거부되는 부류에서는 옵션 형태가 결과를 바꾸지 않고, 허용목록 명령에
대해서만 의미가 있어 축이 비대칭이 된다. 대신 DataProvider 로 전수 전개하고
effects `undeclared_options_and_positional_arguments_are_rejected` 로 대표한다.
파서 분기 4종(큰따옴표 / 작은따옴표 / 백슬래시 / 선행 옵션)도 같은 이유로 축이 아니라
DataProvider 다 — 넷 다 엄격 파서의 같은 규칙 하나에서 걸린다.
exclusions:
- { command_class: extension_owned, enforcement_point: store, reason: "확장 소유 여부는 validator 단일 지점에서 갈린다 — HTTP 계층은 같은 판정 함수를 호출할 뿐 별도 분기가 없다" }
- { command_class: extension_owned, enforcement_point: update, reason: "동일 — 판정 분기 없음" }
- { command_class: extension_owned, enforcement_point: run, reason: "동일 — 판정 분기 없음" }
- { command_class: code_generating, enforcement_point: run, reason: "저장 시점에 거부되어 DB 에 남지 않는다. 실행 시점의 DB 직접 주입 방어는 parser_divergent·core_not_allowlisted 가 대표" }
- { command_class: malformed, enforcement_point: run, reason: "동일 — 실행 시점 대표는 parser_divergent (형식 오류의 대표 사례)" }
- { command_class: core_allowlisted, enforcement_point: update, reason: "update 의 고유 축은 '요청에 type 이 없을 때 저장된 타입으로 폴백' 배선이며 판정 자체는 store 와 같은 Rule — 대표 1건(code_generating)으로 검증" }
- { command_class: core_not_allowlisted, enforcement_point: update, reason: "동일 — 대표 1건으로 검증" }
- { command_class: denylisted, enforcement_point: update, reason: "동일 — 대표 1건으로 검증" }
- { command_class: parser_divergent, enforcement_point: update, reason: "동일 — 대표 1건으로 검증" }
- { command_class: malformed, enforcement_point: update, reason: "동일 — 대표 1건으로 검증" }
effects:
# 판정 계층
- allowlisted_maintenance_commands_still_run
- commands_outside_the_allowlist_are_rejected
- denylist_blocks_destructive_and_code_executing_commands
- denylist_is_evaluated_before_the_allowlist
- make_prefix_blocks_all_code_generating_commands
- extension_owned_commands_are_allowed_by_namespace
- extension_gate_can_be_turned_off
- extension_commands_only_accept_their_own_options
# 사용법 제한
- undeclared_options_and_positional_arguments_are_rejected
- allowed_command_resolves_to_name_and_parameter_array
- rejection_reason_is_reported_per_category
# 파서 일치
- parser_divergent_input_is_rejected
- extracted_name_equals_executed_name
- run_dispatches_artisan_command_as_parsed_parameters
# 설정 불변식
- allowlist_and_denylist_stay_disjoint
- allowlist_matches_real_command_signatures
# 엔드투엔드 차단
- store_rejects_artisan_command_outside_allowlist
- store_rejects_parser_divergent_artisan_command
- store_rejects_allowlisted_command_with_denied_option
- store_allows_allowlisted_command_with_allowed_option
- store_rejects_malformed_artisan_command
- update_falls_back_to_the_stored_type_when_the_request_omits_it
- run_blocks_artisan_schedule_outside_allowlist
- run_blocks_parser_divergent_artisan_schedule
- run_blocks_denylisted_artisan_schedule
- parser_divergent_payload_never_reaches_artisan
- low_privilege_operator_cannot_stage_migration_rce_chain
# E2E axis 없음: 판정은 전부 서버측이고 레이아웃 JSON·컴포넌트 TSX·엔진 TS 변경이 없다.
# 예약 작업 관리 화면은 `config/core.php` 에서 is_active=false 로 비노출 상태라
# 브라우저 경로 자체가 존재하지 않는다 (frontend-change-requires-e2e 룰의 대상이 아님).
test_files:
- tests/Unit/Support/ScheduleCommandValidatorTest.php
- tests/Feature/Security/ScheduleCommandGuardTest.php