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:
1 parent
f848086fd6
commit
c4beb116ad
46 files changed
+1297
-55
No files matched your search
@@ -0,0 +1,232 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature\Security;
|
||||
|
||||
use App\Enums\ScheduleResultStatus;
|
||||
use App\Enums\ScheduleType;
|
||||
use App\Exceptions\LanguagePackOperationException;
|
||||
use App\Models\Schedule;
|
||||
use App\Services\DriverConnectionTester;
|
||||
use App\Services\LanguagePackService;
|
||||
use App\Services\ScheduleService;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Support\Facades\Config;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Illuminate\Validation\ValidationException;
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
* 서버가 대신 보내는 outbound 요청이 내부망을 타격하지 못하는지 검증한다 (SSRF 방어).
|
||||
*
|
||||
* 각 케이스는 `Http::fake()` 로 실제 통신을 가로챈 뒤 `Http::assertNothingSent()` 로
|
||||
* "요청 자체가 나가지 않았음" 을 확인한다 — 게이트 도입 전에는 요청이 실제로 전송된다.
|
||||
*/
|
||||
class OutboundRequestGuardTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
Http::fake(['*' => Http::response('ok', 200)]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 언어팩 설치는 내부 네트워크 주소에서 내려받지 않는다.
|
||||
*
|
||||
* @param string $url 내부망을 가리키는 다운로드 URL
|
||||
*/
|
||||
#[DataProvider('internalUrlProvider')]
|
||||
public function test_language_pack_install_from_url_blocks_internal_addresses(string $url): void
|
||||
{
|
||||
$this->expectException(LanguagePackOperationException::class);
|
||||
|
||||
try {
|
||||
app(LanguagePackService::class)->installFromUrl($url, null);
|
||||
} finally {
|
||||
Http::assertNothingSent();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 언어팩 다운로드는 원격 코드를 가져오므로, 내부 주소 허용 설정을 켜도 계속 차단한다.
|
||||
*/
|
||||
public function test_language_pack_install_stays_blocked_even_when_internal_is_allowed(): void
|
||||
{
|
||||
$this->allowInternalOutboundUrls();
|
||||
|
||||
$this->expectException(LanguagePackOperationException::class);
|
||||
|
||||
try {
|
||||
app(LanguagePackService::class)->installFromUrl('http://127.0.0.1/pack.zip', null);
|
||||
} finally {
|
||||
Http::assertNothingSent();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* URL 호출 스케줄은 내부 네트워크 주소를 호출하지 않는다.
|
||||
*
|
||||
* @param string $url 내부망을 가리키는 스케줄 URL
|
||||
*/
|
||||
#[DataProvider('internalUrlProvider')]
|
||||
public function test_url_schedule_blocks_internal_addresses(string $url): void
|
||||
{
|
||||
$this->assertUrlScheduleIsBlocked($url);
|
||||
}
|
||||
|
||||
/**
|
||||
* 사내 엔드포인트 주기 호출은 내부 주소 허용 설정으로 가능하다 (운영 옵트인).
|
||||
*/
|
||||
public function test_url_schedule_allows_internal_address_when_setting_is_enabled(): void
|
||||
{
|
||||
$this->allowInternalOutboundUrls();
|
||||
|
||||
$history = app(ScheduleService::class)->runSchedule($this->makeUrlSchedule('http://192.168.0.10/cron'));
|
||||
|
||||
$this->assertSame(ScheduleResultStatus::Success, $history->status);
|
||||
Http::assertSentCount(1);
|
||||
}
|
||||
|
||||
/**
|
||||
* 내부 주소를 허용해도 userinfo(@) 로 목적지를 위장한 URL 은 계속 차단한다.
|
||||
*/
|
||||
public function test_url_schedule_blocks_userinfo_disguise_even_when_internal_is_allowed(): void
|
||||
{
|
||||
$this->allowInternalOutboundUrls();
|
||||
|
||||
$this->assertUrlScheduleIsBlocked('http://example.com@169.254.169.254/latest/meta-data/');
|
||||
}
|
||||
|
||||
/**
|
||||
* URL 스케줄 실행이 차단되고 요청이 전송되지 않았음을 단언합니다.
|
||||
*
|
||||
* `runSchedule` 은 실행 실패를 실패 이력으로 기록한 뒤 ValidationException 으로 전파한다
|
||||
* (기존 계약). 차단도 그 경로를 그대로 탄다.
|
||||
*
|
||||
* @param string $url 호출 대상 URL
|
||||
*/
|
||||
private function assertUrlScheduleIsBlocked(string $url): void
|
||||
{
|
||||
$schedule = $this->makeUrlSchedule($url);
|
||||
|
||||
try {
|
||||
app(ScheduleService::class)->runSchedule($schedule);
|
||||
$this->fail("차단되어야 하는 URL 스케줄이 실행됨: {$url}");
|
||||
} catch (ValidationException $e) {
|
||||
// 실행 실패 경로 — 아래에서 요청 미전송 + 실패 이력을 확인한다
|
||||
}
|
||||
|
||||
Http::assertNothingSent();
|
||||
$this->assertSame(
|
||||
ScheduleResultStatus::Failed,
|
||||
$schedule->fresh()->last_result,
|
||||
"차단된 스케줄이 실패로 기록되지 않음: {$url}"
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 웹소켓 연결 테스트는 localhost·사설 IP 를 정상 구성으로 허용한다 (기본 설치 동작).
|
||||
*
|
||||
* @param string $host 드라이버 설정의 websocket_host
|
||||
*/
|
||||
#[DataProvider('legitimateWebsocketHostProvider')]
|
||||
public function test_websocket_test_allows_local_and_private_hosts(string $host): void
|
||||
{
|
||||
$result = app(DriverConnectionTester::class)->testWebsocket([
|
||||
'websocket_host' => $host,
|
||||
'websocket_port' => 8080,
|
||||
'websocket_scheme' => 'http',
|
||||
]);
|
||||
|
||||
$this->assertTrue($result['success']);
|
||||
}
|
||||
|
||||
/**
|
||||
* 웹소켓 연결 테스트는 정상 설정에서 나올 수 없는 위조 host 를 거부한다.
|
||||
*
|
||||
* @param string $host 구조적으로 위조된 websocket_host
|
||||
*/
|
||||
#[DataProvider('forgedWebsocketHostProvider')]
|
||||
public function test_websocket_test_rejects_structurally_forged_hosts(string $host): void
|
||||
{
|
||||
$result = app(DriverConnectionTester::class)->testWebsocket([
|
||||
'websocket_host' => $host,
|
||||
'websocket_port' => 8080,
|
||||
'websocket_scheme' => 'https',
|
||||
]);
|
||||
|
||||
$this->assertFalse($result['success']);
|
||||
Http::assertNothingSent();
|
||||
}
|
||||
|
||||
/**
|
||||
* 내부망 URL 목록.
|
||||
*
|
||||
* @return array<string, array{string}>
|
||||
*/
|
||||
public static function internalUrlProvider(): array
|
||||
{
|
||||
return [
|
||||
'클라우드 메타데이터' => ['http://169.254.169.254/latest/meta-data/'],
|
||||
'루프백' => ['http://127.0.0.1:8080/pack.zip'],
|
||||
'localhost' => ['http://localhost/pack.zip'],
|
||||
'사설 IP' => ['http://10.0.0.5/pack.zip'],
|
||||
'userinfo 위장' => ['https://github.com@127.0.0.1/pack.zip'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* 정상 운영에서 쓰이는 웹소켓 host 목록 (기본값 포함).
|
||||
*
|
||||
* @return array<string, array{string}>
|
||||
*/
|
||||
public static function legitimateWebsocketHostProvider(): array
|
||||
{
|
||||
return [
|
||||
'기본값 localhost' => ['localhost'],
|
||||
'루프백 IP' => ['127.0.0.1'],
|
||||
'사내 사설 IP' => ['192.168.0.10'],
|
||||
'공개 도메인' => ['ws.example.com'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* 구조적으로 위조된 웹소켓 host 목록.
|
||||
*
|
||||
* @return array<string, array{string}>
|
||||
*/
|
||||
public static function forgedWebsocketHostProvider(): array
|
||||
{
|
||||
return [
|
||||
'userinfo 위장' => ['example.com@169.254.169.254'],
|
||||
'제어문자 주입' => ["example.com\r\nX-Injected: 1"],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* URL 호출 스케줄을 생성합니다.
|
||||
*
|
||||
* @param string $url 호출 대상 URL
|
||||
* @return Schedule 생성된 스케줄
|
||||
*/
|
||||
private function makeUrlSchedule(string $url): Schedule
|
||||
{
|
||||
return Schedule::create([
|
||||
'name' => 'outbound 가드 테스트 스케줄',
|
||||
'type' => ScheduleType::Url,
|
||||
'command' => $url,
|
||||
'expression' => '* * * * *',
|
||||
'is_active' => true,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 관리자 환경설정에서 내부 주소 호출 허용을 켭니다.
|
||||
*/
|
||||
private function allowInternalOutboundUrls(): void
|
||||
{
|
||||
Config::set('g7_settings.core.security.allow_internal_outbound_urls', true);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
/**
|
||||
* E2E: 환경설정 > 보안 — "내부 네트워크 주소 호출 허용" 토글 (#466)
|
||||
*
|
||||
* @scenario admin_settings_security_outbound_toggle
|
||||
* @effects toggle_mounted, toggle_persisted
|
||||
*
|
||||
* 배경: 서버가 대신 보내는 outbound 요청(예약 작업 URL 호출, 외부 API 연동)에서 내부
|
||||
* 네트워크 주소를 기본 차단하되, 사내 서버를 호출해야 하는 운영 환경을 위해 이 토글로
|
||||
* 예외를 허용한다. 토글이 실제로 마운트되고 저장까지 되는지 브라우저에서 확인한다.
|
||||
*
|
||||
* 검증:
|
||||
* 1. 보안 탭에 토글이 마운트되고 항목명·설명이 raw 키가 아닌 번역문으로 표시된다
|
||||
* 2. 토글을 켜고 저장하면 422 없이 성공하고, 재진입 시 켜진 상태가 유지된다
|
||||
*/
|
||||
import { test, expect, issueToken, authenticatePage } from '../../fixtures/auth';
|
||||
|
||||
const TOGGLE_ROW = '#toggle_allow_internal_outbound_urls';
|
||||
|
||||
/** 관리자 환경설정 보안 탭 진입 */
|
||||
async function gotoSecurityTab(page: import('@playwright/test').Page): Promise<void> {
|
||||
await page.goto('/admin/settings?tab=security');
|
||||
await page.waitForLoadState('domcontentloaded', { timeout: 30_000 });
|
||||
await expect(page.locator(TOGGLE_ROW)).toBeAttached({ timeout: 20_000 });
|
||||
}
|
||||
|
||||
// @scenario tab=security, permitted=yes
|
||||
// @effects toggle_mounted
|
||||
test('@smoke #466 - 보안 탭에 "내부 네트워크 주소 호출 허용" 토글이 번역문과 함께 마운트된다', async ({ page }) => {
|
||||
const token = issueToken('core.settings.read', 'core.settings.update');
|
||||
await authenticatePage(page, token);
|
||||
|
||||
await gotoSecurityTab(page);
|
||||
expect(page.url()).not.toMatch(/\/admin\/login/);
|
||||
|
||||
const row = page.locator(TOGGLE_ROW);
|
||||
await expect(row).toBeAttached();
|
||||
|
||||
// 다국어 키가 해석되지 않으면 "$t:admin.settings.security..." 원문이 그대로 노출된다 (회귀 가드)
|
||||
const text = (await row.innerText()).trim();
|
||||
expect(text).not.toContain('$t:');
|
||||
expect(text.length).toBeGreaterThan(0);
|
||||
|
||||
// 토글 입력이 행 안에 실제로 존재한다
|
||||
await expect(row.locator('input[type="checkbox"]').first()).toBeAttached();
|
||||
});
|
||||
|
||||
// @scenario tab=security, permitted=yes
|
||||
// @effects toggle_interactive
|
||||
test('#466 - 토글을 클릭하면 상태가 바뀌고 저장 버튼이 활성화된다', async ({ page }) => {
|
||||
const token = issueToken('core.settings.read', 'core.settings.update');
|
||||
await authenticatePage(page, token);
|
||||
|
||||
await gotoSecurityTab(page);
|
||||
|
||||
const wasOn = await isToggleOn(page);
|
||||
|
||||
// Toggle 은 sr-only checkbox 를 감싼 wrapper 가 클릭 대상이다
|
||||
await page.locator(`${TOGGLE_ROW} .toggle-switch-wrapper`).first().click();
|
||||
|
||||
// 클릭이 실제 상태 변경으로 이어진다 (폼 바인딩 회귀 가드)
|
||||
await expect
|
||||
.poll(() => isToggleOn(page), { timeout: 10_000 })
|
||||
.toBe(!wasOn);
|
||||
|
||||
// 변경이 감지되어 저장 버튼이 활성화된다 (_local.hasChanges 바인딩 확인)
|
||||
await expect(page.locator('#save_button')).toBeEnabled({ timeout: 10_000 });
|
||||
});
|
||||
|
||||
/**
|
||||
* 보안 탭 토글의 on/off 상태를 읽는다 (sr-only checkbox 의 checked 기준).
|
||||
*/
|
||||
async function isToggleOn(page: import('@playwright/test').Page): Promise<boolean> {
|
||||
return page
|
||||
.locator(`${TOGGLE_ROW} input[type="checkbox"]`)
|
||||
.first()
|
||||
.evaluate((el) => (el as HTMLInputElement).checked);
|
||||
}
|
||||
@@ -0,0 +1,201 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Unit\Support;
|
||||
|
||||
use App\Support\OutboundUrlValidator;
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
* outbound URL 검증 유틸 테스트.
|
||||
*
|
||||
* 접두사 매칭 우회(userinfo `@`, 접미사 확장)와 내부망 타격(사설/루프백/링크로컬 IP,
|
||||
* 내부 도메인)을 전수 매트릭스로 차단 검증한다.
|
||||
*/
|
||||
class OutboundUrlValidatorTest extends TestCase
|
||||
{
|
||||
/** 본인인증 게이트웨이 화이트리스트 (실사용 값) */
|
||||
private const HOSTS = ['kssa.inicis.com', 'fcsa.inicis.com'];
|
||||
|
||||
/**
|
||||
* 화이트리스트 host 와 완전 일치하는 URL 은 통과한다.
|
||||
*
|
||||
* @param string $url 검증 대상 URL
|
||||
*/
|
||||
#[Test]
|
||||
#[DataProvider('allowedHostUrlProvider')]
|
||||
public function it_allows_urls_whose_host_exactly_matches_the_whitelist(string $url): void
|
||||
{
|
||||
$this->assertTrue(OutboundUrlValidator::isHostAllowed($url, self::HOSTS));
|
||||
}
|
||||
|
||||
/**
|
||||
* 화이트리스트를 우회하려는 URL 은 모두 차단한다.
|
||||
*
|
||||
* @param string $url 검증 대상 URL
|
||||
* @param string $reason 차단 사유 (실패 메시지용)
|
||||
*/
|
||||
#[Test]
|
||||
#[DataProvider('blockedHostUrlProvider')]
|
||||
public function it_blocks_urls_that_do_not_exactly_match_the_whitelist(string $url, string $reason): void
|
||||
{
|
||||
$this->assertFalse(
|
||||
OutboundUrlValidator::isHostAllowed($url, self::HOSTS),
|
||||
"차단되어야 하는 URL 이 통과함 ({$reason}): {$url}"
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 공개 인터넷 URL 은 통과한다.
|
||||
*
|
||||
* @param string $url 검증 대상 URL
|
||||
*/
|
||||
#[Test]
|
||||
#[DataProvider('publicUrlProvider')]
|
||||
public function it_allows_public_internet_urls(string $url): void
|
||||
{
|
||||
$this->assertTrue(
|
||||
OutboundUrlValidator::isPublicHttpUrl($url, ['schemes' => ['http', 'https']]),
|
||||
"공개 URL 이 차단됨: {$url}"
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 내부망을 가리키는 URL 은 모두 차단한다.
|
||||
*
|
||||
* @param string $url 검증 대상 URL
|
||||
* @param string $reason 차단 사유 (실패 메시지용)
|
||||
*/
|
||||
#[Test]
|
||||
#[DataProvider('internalUrlProvider')]
|
||||
public function it_blocks_urls_pointing_at_internal_addresses(string $url, string $reason): void
|
||||
{
|
||||
$this->assertFalse(
|
||||
OutboundUrlValidator::isPublicHttpUrl($url, ['schemes' => ['http', 'https']]),
|
||||
"차단되어야 하는 내부 URL 이 통과함 ({$reason}): {$url}"
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* scheme 기본값은 https 전용 — http 는 옵트인해야 통과한다.
|
||||
*/
|
||||
#[Test]
|
||||
public function it_rejects_http_unless_explicitly_opted_in(): void
|
||||
{
|
||||
$this->assertFalse(OutboundUrlValidator::isPublicHttpUrl('http://example.com/api'));
|
||||
$this->assertTrue(OutboundUrlValidator::isPublicHttpUrl('http://example.com/api', ['schemes' => ['http', 'https']]));
|
||||
}
|
||||
|
||||
/**
|
||||
* 화이트리스트 검증은 기본적으로 명시 포트를 거부한다.
|
||||
*/
|
||||
#[Test]
|
||||
public function it_rejects_explicit_ports_for_whitelisted_hosts_by_default(): void
|
||||
{
|
||||
$this->assertFalse(OutboundUrlValidator::isHostAllowed('https://kssa.inicis.com:8080/auth', self::HOSTS));
|
||||
$this->assertTrue(OutboundUrlValidator::isHostAllowed('https://kssa.inicis.com:8080/auth', self::HOSTS, ['allowPort' => true]));
|
||||
}
|
||||
|
||||
/**
|
||||
* host 단독 판정도 동일한 내부망 차단 규칙을 따른다.
|
||||
*/
|
||||
#[Test]
|
||||
public function it_judges_bare_hosts_with_the_same_internal_rules(): void
|
||||
{
|
||||
$this->assertTrue(OutboundUrlValidator::isPublicHost('example.com'));
|
||||
$this->assertFalse(OutboundUrlValidator::isPublicHost('localhost'));
|
||||
$this->assertFalse(OutboundUrlValidator::isPublicHost('127.0.0.1'));
|
||||
$this->assertFalse(OutboundUrlValidator::isPublicHost('169.254.169.254'));
|
||||
$this->assertFalse(OutboundUrlValidator::isPublicHost(''));
|
||||
}
|
||||
|
||||
/**
|
||||
* 화이트리스트 통과 URL 목록.
|
||||
*
|
||||
* @return array<string, array{string}>
|
||||
*/
|
||||
public static function allowedHostUrlProvider(): array
|
||||
{
|
||||
return [
|
||||
'표준 인증 URL' => ['https://kssa.inicis.com/auth/result'],
|
||||
'두 번째 화이트리스트 host' => ['https://fcsa.inicis.com/auth/result'],
|
||||
'대소문자 혼용 host' => ['https://KSSA.Inicis.COM/auth/result'],
|
||||
'경로 없음' => ['https://kssa.inicis.com'],
|
||||
'쿼리스트링 포함' => ['https://kssa.inicis.com/auth?txId=abc'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* 화이트리스트 차단 URL 목록 (우회 벡터 전수).
|
||||
*
|
||||
* @return array<string, array{string, string}>
|
||||
*/
|
||||
public static function blockedHostUrlProvider(): array
|
||||
{
|
||||
return [
|
||||
'userinfo 로 내부 IP 위장' => ['https://kssa.inicis.com@127.0.0.1/', 'userinfo(@) 뒤가 실제 host'],
|
||||
'userinfo 로 메타데이터 위장' => ['https://kssa.inicis.com@169.254.169.254/latest/meta-data/', 'userinfo(@) 뒤가 실제 host'],
|
||||
'userinfo + 비밀번호' => ['https://kssa.inicis.com:pw@evil.example/', 'user:pass@host'],
|
||||
'접미사 확장 도메인' => ['https://kssa.inicis.com.attacker.com/', '화이트리스트가 접두사일 뿐 host 불일치'],
|
||||
'숫자 접미사 확장' => ['https://kssa.inicis.com.169.254.169.254.nip.io/', '접미사 확장'],
|
||||
'하이픈 접미사' => ['https://kssa.inicis.com-evil.example/', '접미사 확장'],
|
||||
'서브도메인 위장' => ['https://evil.example/kssa.inicis.com', '경로에만 포함'],
|
||||
'http scheme' => ['http://kssa.inicis.com/auth', 'https 아님'],
|
||||
'scheme 없음' => ['//kssa.inicis.com/auth', 'scheme 부재'],
|
||||
'host 없는 상대경로' => ['/auth/result', 'host 부재'],
|
||||
'빈 문자열' => ['', '입력 없음'],
|
||||
'공백' => [' ', '입력 없음'],
|
||||
'file scheme' => ['file:///etc/passwd', '허용 scheme 아님'],
|
||||
'gopher scheme' => ['gopher://kssa.inicis.com/', '허용 scheme 아님'],
|
||||
'CRLF 주입' => ["https://kssa.inicis.com/auth\r\nX-Injected: 1", '제어문자 포함'],
|
||||
'완전 무관 host' => ['https://attacker.example/', '화이트리스트 불일치'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* 공개 인터넷 URL 목록.
|
||||
*
|
||||
* @return array<string, array{string}>
|
||||
*/
|
||||
public static function publicUrlProvider(): array
|
||||
{
|
||||
return [
|
||||
'https 공개 도메인' => ['https://example.com/api/shipping'],
|
||||
'http 공개 도메인' => ['http://api.example.co.kr/fee'],
|
||||
'비표준 포트' => ['https://api.example.com:8443/fee'],
|
||||
'공인 IP' => ['https://8.8.8.8/'],
|
||||
'서브도메인' => ['https://shipping.api.example.com/v1/quote'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* 내부망 차단 URL 목록 (SSRF 표적 전수).
|
||||
*
|
||||
* @return array<string, array{string, string}>
|
||||
*/
|
||||
public static function internalUrlProvider(): array
|
||||
{
|
||||
return [
|
||||
'클라우드 메타데이터' => ['http://169.254.169.254/latest/meta-data/', '링크로컬 메타데이터'],
|
||||
'GCP 메타데이터 호스트' => ['http://metadata.google.internal/computeMetadata/v1/', '.internal 내부 도메인'],
|
||||
'루프백 IPv4' => ['http://127.0.0.1:8080/admin', '루프백'],
|
||||
'루프백 변형' => ['http://127.1/', '루프백 대역'],
|
||||
'루프백 IPv6' => ['http://[::1]/', '루프백'],
|
||||
'localhost' => ['http://localhost:9200/_cat/indices', 'localhost'],
|
||||
'사설 10 대역' => ['http://10.0.0.5/internal', '사설 IP'],
|
||||
'사설 172.16 대역' => ['http://172.16.0.10/internal', '사설 IP'],
|
||||
'사설 192.168 대역' => ['http://192.168.1.1/router', '사설 IP'],
|
||||
'.local 내부 도메인' => ['http://printer.local/', '.local'],
|
||||
'.internal 내부 도메인' => ['http://vault.internal/v1/secret', '.internal'],
|
||||
'.lan 내부 도메인' => ['http://nas.lan/', '.lan'],
|
||||
'10진수 인코딩 IP' => ['http://2130706433/', '127.0.0.1 의 10진수 표기'],
|
||||
'16진수 인코딩 IP' => ['http://0x7f000001/', '127.0.0.1 의 16진수 표기'],
|
||||
'userinfo 위장' => ['https://example.com@127.0.0.1/', 'userinfo 뒤가 실제 host'],
|
||||
'0.0.0.0' => ['http://0.0.0.0:3000/', '예약 대역'],
|
||||
'CRLF 주입' => ["http://example.com/\r\nHost: internal", '제어문자 포함'],
|
||||
'file scheme' => ['file:///etc/passwd', '허용 scheme 아님'],
|
||||
'host 부재' => ['http:///etc/passwd', 'host 부재'],
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user