fix(security): outbound URL 내부주소·host 검증 전수 강화

서버가 외부 입력으로 목적지가 제어되는 outbound HTTP 요청을 보내는 지점을
전수 조사해, 내부망(사설 IP·루프백·링크로컬·메타데이터)과 host 위조를 차단한다.
KVE-2026-1546(이니시스 인증 URL 접두사 매칭 우회)과 동일 클래스의
지점(언어팩 URL 설치, 스케줄 URL 호출, 배송비 계산 API, GitHub URL 판정)을
코어 공용 유틸 App\Support\OutboundUrlValidator 로 수렴시켰다.

- 접두사 매칭을 host 완전일치로 교체 — userinfo(@) 위장과 접미사 확장 도메인
 우회 벡터 차단.
- 사내 서버 호출이 정당한 관리자 지점(스케줄·외부 API)은 신규 설정
 security.allow_internal_outbound_urls(기본 off)로 옵트인.
- 언어팩 URL 설치는 원격 코드 다운로드라 옵트인과 무관하게 내부 주소 항상 차단.
- 웹소켓 연결 테스트는 localhost·사설 IP 가 정상 구성이므로 구조적 위조만 차단.

각 지점에 red 재현 → 수정 → green 회귀 테스트 + 실브라우저 E2E 로 검증.
수기 API 문서가 자동 재생성으로 소실되는 사고를 막는 PreToolUse 훅을 함께 추가한다.
This commit is contained in:
HeuJung committed 2026-07-14 09:17:00 +09:00
1 parent f848086fd6
commit c4beb116ad
46 files changed
+1297 -55

No files matched your search

+24 -8
View File
@@ -2,8 +2,13 @@
namespace App\Services;
use App\Support\OutboundUrlValidator;
use Aws\S3\Exception\S3Exception;
use Aws\S3\S3Client;
use Illuminate\Http\Client\ConnectionException;
use Illuminate\Support\Facades\Http;
use Illuminate\Support\Facades\Log;
use Predis\Client;
/**
* 드라이버 연결 테스트 서비스
@@ -89,7 +94,7 @@ class DriverConnectionTester
}
// AWS SDK가 설치되어 있는지 확인
if (! class_exists(\Aws\S3\S3Client::class)) {
if (! class_exists(S3Client::class)) {
return [
'success' => false,
'message' => __('settings.s3_sdk_missing'),
@@ -98,7 +103,7 @@ class DriverConnectionTester
$startTime = microtime(true);
$client = new \Aws\S3\S3Client([
$client = new S3Client([
'version' => 'latest',
'region' => $region,
'credentials' => [
@@ -121,7 +126,7 @@ class DriverConnectionTester
'message' => __('settings.s3_test_success'),
'latency' => $latency.'ms',
];
} catch (\Aws\S3\Exception\S3Exception $e) {
} catch (S3Exception $e) {
$errorMessage = match ($e->getAwsErrorCode()) {
'NoSuchBucket' => __('settings.s3_bucket_not_found'),
'AccessDenied' => __('settings.s3_access_denied'),
@@ -165,7 +170,7 @@ class DriverConnectionTester
// PHP Redis 확장 확인
if (! extension_loaded('redis')) {
// Predis 사용 시도
if (! class_exists(\Predis\Client::class)) {
if (! class_exists(Client::class)) {
return [
'success' => false,
'message' => __('settings.redis_extension_missing'),
@@ -177,7 +182,7 @@ class DriverConnectionTester
$startTime = microtime(true);
$redis = new \Redis();
$redis = new \Redis;
$connected = @$redis->connect($host, $port, 3.0);
if (! $connected) {
@@ -259,7 +264,7 @@ class DriverConnectionTester
$options['password'] = $password;
}
$client = new \Predis\Client($options);
$client = new Client($options);
$pong = $client->ping();
if ($pong->getPayload() !== 'PONG') {
@@ -307,7 +312,7 @@ class DriverConnectionTester
$startTime = microtime(true);
$memcached = new \Memcached();
$memcached = new \Memcached;
$memcached->setOption(\Memcached::OPT_CONNECT_TIMEOUT, 3000);
$memcached->addServer($host, $port);
@@ -376,6 +381,17 @@ class DriverConnectionTester
// Reverb 서버 상태 확인 (기본 HTTP 엔드포인트)
$url = sprintf('%s://%s:%d', $scheme, $host, $port);
// Reverb 는 통상 localhost·사내 IP 에서 동작하므로 사설 주소 자체는 정상 구성이다.
// 다만 이 진단 요청을 임의 목적지 탐색에 전용하지 못하도록, 정상 설정에서는 나올 수
// 없는 값(userinfo 위장, http/https 이외 scheme, 제어문자 주입)은 거부한다.
if (! OutboundUrlValidator::isStructurallySafeUrl($url, ['schemes' => ['http', 'https']])) {
return [
'success' => false,
'message' => __('settings.websocket_test_failed'),
'error' => __('settings.websocket_invalid_host'),
];
}
$startTime = microtime(true);
// HTTP 요청으로 서버 응답 확인
@@ -402,7 +418,7 @@ class DriverConnectionTester
'message' => __('settings.websocket_test_failed'),
'error' => "HTTP {$response->status()}",
];
} catch (\Illuminate\Http\Client\ConnectionException $e) {
} catch (ConnectionException $e) {
return [
'success' => false,
'message' => __('settings.websocket_connection_refused'),