참고 자료 · 72
URL 가져오기의 SSRF 방지
URL 가져오기가 내부 자원 접근을 뜻하지 않게 허용할 수 있습니다.
업데이트됨 · 14 min
이 가이드가 달성하는 목표
- 허용 대상 정의
- 연결마다 검사
- 격리 서비스에서 시험
빠른 확인
- 대상과 리디렉션을 검증하고 허가된 격리 환경에서 네트워크 제한을 시험하세요.
- 첫 URL만 검사하면 우회 경로가 남습니다.
단계별 방법
- 1
허용 대상 정의
가져오기에 필요한 출처, 포트와 프로토콜을 정합니다. 라이브러리로 URL을 분석하세요. 이름에 허용 문자열이 있어도 실제 대상이 허용되었다는 뜻은 아닙니다.
대상 목록과 예외 근거를 보관합니다.
- 2
연결마다 검사
해석된 주소와 각 리디렉션을 확인합니다. 공개 URL이 사설 주소로 이어지면 연결 전에 거부하고 시간과 응답 크기도 제한합니다.
초기 대상, 경유 단계와 결정을 기록합니다.
- 3
격리 서비스에서 시험
테스트 서버에서 리디렉션, 느린 응답과 큰 파일을 재현합니다. 실제 메타데이터 서비스나 사설망에 접근하지 않고 거부 대상에 연결되지 않는지 확인합니다.
거부와 제한 시험표를 보관합니다.
재현 가능한 수락 사례
가상 예시입니다. 고객이나 실제 관측 결과를 나타내지 않습니다.
사례 입력 보기
{
"initial_host": "public.example",
"redirect_host": "internal.example",
"resolved_ip": "127.0.0.1",
"network": "isolated-test"
}예상 판단
리디렉션이 루프백으로 향합니다. 격리된 시험 환경에서 이 경로를 차단합니다. 최초 호스트 이름 검사는 리디렉션 목적지를 검증하지 않습니다. 격리 환경에서 자동 추적을 끄고 루프백에 연결되지 않는지 확인합니다. 차단을 증명하려고 내부 콘텐츠를 가져오지 말고 추적 가능한 거부를 기대 결과로 둡니다.
검증 절차
- 허용된 가져오기 대상과 네트워크를 나열합니다.
- 격리하여 루프백 리디렉션을 시험합니다.
- 확인된 주소와 차단 증거를 보존합니다.
가상 예시
예시 상황
대상과 리디렉션을 검증하고 허가된 격리 환경에서 네트워크 제한을 시험하세요.
결정 및 예상 증거
아닙니다. 이름 해석과 리디렉션으로 대상이 바뀔 수 있으므로 전체 경로와 외부 통신 제한을 검사하세요.
관리 지표
| 지표 | 측정 대상 | 첫 번째 조치 |
|---|---|---|
| 허용되지 않은 연결 | 거부 대상에 실제로 이루어진 연결 | 가져오기를 중단하고 출구 통제 확인 |
| 한도 초과 | 시간 또는 바이트 예산을 넘긴 응답 | 읽기를 중단하고 이유 보관 |
일반적인 실수
- 첫 URL만 검사하면 우회 경로가 남습니다.
자주 묻는 질문
첫 URL만 확인하면 충분한가요?
아닙니다. 이름 해석과 리디렉션으로 대상이 바뀔 수 있으므로 전체 경로와 외부 통신 제한을 검사하세요.
SSRF: URL과 연결
이 언어판의 상세 참고 설명은 영어로 제공됩니다.
SSRF: read the URL, then control the connection
Server-Side Request Forgery (SSRF) occurs when an application is induced to send a server request to a destination it should not reach. A report importer, link preview or AI agent tool may have network access unavailable to its user. The control must cover the destination actually reached, beyond the displayed string.
Fictional offline exercise: the 12 strings below are processed only by the maintenance Node runtime’s WHATWG URL parser. No DNS lookup or connection is performed. The .example domains are teaching fixtures; 2001:db8::10 belongs to RFC 3849’s IPv6 documentation prefix. These results are not a production SSRF validator.
The exercise’s local contract
The fictional connector accepts only an absolute HTTPS URL, without credentials, with hostname exactly reports.partner.example, effective port 443 and a normalized path starting with /reports/. Comparison uses parsed fields. This contract rejects a trailing dot and assumes no DNS equivalence. It does not cover query parameters, their interpretation by the remote service or business authorization.
For a known service, prefer a report identifier and reconstruct the URL on the server from a controlled origin and path. This exercise explains user-supplied URL pitfalls; it does not recommend exposing arbitrary URLs. Access to the whole Web needs a separate egress architecture and cannot be secured by copying this small allowlist.
- 1 · Contract and parser — Origin, port, path and credentials
- 2 · Resolution and connection — Validated address actually used
- 3 · Each redirect — New target, same destination policy
- 4 · Response and resources — Timeouts, size and expected type
12 fictional URLs: observed result and limits
Each disclosure shows the original string, computed fields and the decision of the local contract alone. “Continue to resolution” means network checks remain outstanding. A hostname matching the contract is neither resolved nor declared safe.
U01 · Expected name, unknown network
Original stringhttps://reports.partner.example/reports/daily.json
- Serialized URL
https://reports.partner.example/reports/daily.json- Scheme
https:- Hostname
reports.partner.example- Effective port
443- Username
Absent- Password present
No- Normalized path
/reports/daily.json
Continue to resolution — network unchecked
The string meets the contract, but no address is known. DNS validation, enforcement of the validated address at connection time and a network policy remain necessary.
U02 · Uppercase host and explicit HTTPS port
Original stringhttps://REPORTS.PARTNER.EXAMPLE:443/reports/daily.json
- Serialized URL
https://reports.partner.example/reports/daily.json- Scheme
https:- Hostname
reports.partner.example- Effective port
443- Username
Absent- Password present
No- Normalized path
/reports/daily.json
Continue to resolution — network unchecked
The parser lowercases the hostname and removes the default HTTPS port from serialization. The effective port remains 443; comparing parsed fields separates presentation from destination.
U03 · The reassuring name is before @
Original stringhttps://reports.partner.example@untrusted.example/reports/daily.json
- Serialized URL
https://reports.partner.example@untrusted.example/reports/daily.json- Scheme
https:- Hostname
untrusted.example- Effective port
443- Username
reports.partner.example- Password present
No- Normalized path
/reports/daily.json
Reject under the local contract
Contract reasons:
- Hostname differs from the exact allowlist
- Embedded credentials are forbidden
The parser places reports.partner.example in username. The actual hostname is untrusted.example: finding an allowed substring in the whole URL does not control its destination.
U04 · An added suffix changes the host
Original stringhttps://reports.partner.example.untrusted.example/reports/daily.json
- Serialized URL
https://reports.partner.example.untrusted.example/reports/daily.json- Scheme
https:- Hostname
reports.partner.example.untrusted.example- Effective port
443- Username
Absent- Password present
No- Normalized path
/reports/daily.json
Reject under the local contract
Contract reasons:
- Hostname differs from the exact allowlist
This hostname ends in untrusted.example. Exact comparison fails even though the expected name appears at the beginning. The contract uses neither substring matching nor a permissive expression.
U05 · Same host, different port
Original stringhttps://reports.partner.example:8443/reports/daily.json
- Serialized URL
https://reports.partner.example:8443/reports/daily.json- Scheme
https:- Hostname
reports.partner.example- Effective port
8443- Username
Absent- Password present
No- Normalized path
/reports/daily.json
Reject under the local contract
Contract reasons:
- Effective port is not 443
The effective port is 8443. Allowing a hostname must not open every service available on its other ports.
U06 · HTTP does not meet HTTPS
Original stringhttp://reports.partner.example/reports/daily.json
- Serialized URL
http://reports.partner.example/reports/daily.json- Scheme
http:- Hostname
reports.partner.example- Effective port
80- Username
Absent- Password present
No- Normalized path
/reports/daily.json
Reject under the local contract
Contract reasons:
- Scheme is not HTTPS
- Effective port is not 443
The HTTP scheme and default port 80 differ from the HTTPS/443 contract. Silently rewriting the string would hide the original request; keep the decision explicit.
U07 · The .. segment changes the path
Original stringhttps://reports.partner.example/reports/../admin/status
- Serialized URL
https://reports.partner.example/admin/status- Scheme
https:- Hostname
reports.partner.example- Effective port
443- Username
Absent- Password present
No- Normalized path
/admin/status
Reject under the local contract
Contract reasons:
- Path is outside the /reports/ prefix
The parser resolves /reports/../admin/status to /admin/status. A prefix test on the raw string would decide differently. Even after normalization, the service’s path interpretation must remain controlled.
U08 · An encoded host character is normalized
Original stringhttps://%72eports.partner.example/reports/daily.json
- Serialized URL
https://reports.partner.example/reports/daily.json- Scheme
https:- Hostname
reports.partner.example- Effective port
443- Username
Absent- Password present
No- Normalized path
/reports/daily.json
Continue to resolution — network unchecked
The initial %72 becomes r in the computed hostname for this special HTTPS URL. The result matches U01; this provides no evidence about DNS, TLS or business authorization.
U09 · Trailing dot: an exact contract
Original stringhttps://reports.partner.example./reports/daily.json
- Serialized URL
https://reports.partner.example./reports/daily.json- Scheme
https:- Hostname
reports.partner.example.- Effective port
443- Username
Absent- Password present
No- Normalized path
/reports/daily.json
Reject under the local contract
Contract reasons:
- Hostname differs from the exact allowlist
The hostname retains its final dot in this WHATWG result. The teaching profile requires exact equality and rejects it. A production policy must document its normalization and apply it consistently.
U10 · Relative reference without a base URL
Original string//reports.partner.example/reports/daily.json
Cannot parse an absolute URL without a base
Reject: parser failure
Without a base, new URL rejects this reference beginning with //. Adding a base elsewhere could change the result: the validator and client must use the same parsing model.
U11 · Expected host with embedded username
Original stringhttps://training@reports.partner.example/reports/daily.json
- Serialized URL
https://training@reports.partner.example/reports/daily.json- Scheme
https:- Hostname
reports.partner.example- Effective port
443- Username
training- Password present
No- Normalized path
/reports/daily.json
Reject under the local contract
Contract reasons:
- Embedded credentials are forbidden
The expected hostname is insufficient: username contains training. The profile forbids all embedded credentials. This fictional value is neither an account nor a secret.
U12 · Documentation IPv6 address
Original stringhttps://[2001:db8::10]/reports/daily.json
- Serialized URL
https://[2001:db8::10]/reports/daily.json- Scheme
https:- Hostname
[2001:db8::10]- Effective port
443- Username
Absent- Password present
No- Normalized path
/reports/daily.json
Reject under the local contract
Contract reasons:
- Hostname differs from the exact allowlist
The parser accepts bracketed IPv6 syntax, but the contract allows no IP literal. This prefix is reserved for documentation and must not be described as an operational Internet destination.
From the checked name to the actual destination
| Fictional situation | Missing evidence or change | Expected decision |
|---|---|---|
| N01 · Repeated lookup | The application validates one answer; the client resolves again and receives an internal address. | Block the unchecked second lookup. Connect only to an address validated against the destination policy. |
| N02 · 302 response | Location names a different host, port or path. | Disable automatic redirect following. If controlled redirects are a product requirement, parse and validate every new target before connecting. |
| N03 · Egress proxy | The proxy resolves the name and chooses the destination; its rules are unknown to the application. | Do not claim a verified destination. Document enforcement and evidence at the component that actually establishes the connection. |
| N04 · Failure fallback | A new A/AAAA address, retry or fallback is attempted. | Apply the same policy to every address and attempt; no fallback path may bypass enforcement. |
| N05 · Excessive response | The allowed destination returns a large stream or unexpected content. | Enforce client timeouts and size limits, check the expected type and handle content separately. No universal threshold is invented here. |
Binding a connection to the validated address does not mean disabling TLS: preserve the original hostname for HTTP Host, SNI and certificate verification. The component opening the connection must enforce the binding; an earlier DNS observation does not prove it. Network rules complement application checks, including local, private, loopback and link-local destinations in both IPv4 and IPv6.
Cloud metadata: a separate control
In EC2, “token required” enforces IMDSv2; “token optional” permits IMDSv1 or IMDSv2. Enabling the IPv6 endpoint is an explicit option. Check these settings on the relevant instances: merely naming IMDSv2 in documentation does not prove their configuration. Protecting metadata replaces neither egress isolation nor controls on other internal services.
Six records for an SSRF acceptance review
- The business need and the services, ports and operations actually required.
- Parser and HTTP client versions, with expected negative-case results.
- The IPv4/IPv6 address policy and where it is enforced before connection.
- Evidence linking the validated destination to the connection, including proxies, retries and fallback.
- The redirect decision and response bounds, tested in an authorized environment.
- Minimized logs: decision, necessary target information and correlation, without copying passwords, tokens or sensitive parameters.
The 12 cases, four controls and six records are a local editorial method, not OWASP certification. The parser supplies fields; the sources describe risks and controls. “Reject” and “continue” labels do not predict the behavior of your HTTP stack.
Primary sources and scope
- OWASP · SSRF Prevention Cheat Sheet · Living documentation · checked 2026-10-22
Case 1: application/network layers · DNS rebinding · validated connection · retries/fallbacks · redirects - WHATWG · URL Living Standard · Updated 2026-10-19 · checked 2026-10-22
§2 Security considerations · §3 Hosts · §4 URLs · basic URL parser - AWS EC2 · Instance metadata options · Living documentation · checked 2026-10-22
Metadata access · IPv6 endpoint · IMDSv2 token requirements - IETF · RFC 3849 · Informational · July 2004
§2 Documentation IPv6 address prefix: 2001:DB8::/32
Sources reviewed on
파일: 격리와 접근 철회
이 언어판의 상세 참고 설명은 영어로 제공됩니다.
Retrieved content still needs checks before release
Uploading a document or fetching it by URL does not decide its availability. Originals and derivatives need to retain version, checks and access state through every read.
- Isolate received files before processing and release.
- Reject results targeting an older content version or control decision.
- Check permissions and withdrawal for previews and originals alike.
View the three journeys and late task results →
Sources reviewed on · OWASP · File Upload Cheat Sheet · OWASP · Authorization Cheat Sheet · WHATWG · HTML input accept · PostgreSQL 18 · Transaction isolation
공식 참조
참조는 방법을 뒷받침합니다. 상황에 맞게 검사를 조정하십시오. 이는 인증이 아닙니다. 원본 참조 제목 및 소스 문서는 다른 언어로 작성되었을 수 있습니다.
참고 자료 확인일 .
