fix(security): URLTest 与 fetch 默认拒绝私网目标#24
Open
milangree wants to merge 3 commits into
Open
Conversation
新增 core-outbound net_guard,拦截 loopback/RFC1918/CGNAT/链路本地/云元数据。 URLTest 与订阅/规则集 fetch 在解析前后及 redirect 每跳复查目标。 fetch 日志仅记录 host;单测可通过 allow_private_targets 显式放行本地服。
从 health 中剥离 dial 短期 dead 逻辑,本 PR 只保留目标拦截。
Owner
|
@copilot resolve the merge conflicts in this pull request |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
背景
控制面 URLTest 与订阅/规则集 fetch 可被用作 SSRF:探测 loopback、RFC1918、云元数据等目标。
实现
net_guard
core-outbound::net_guard,统一判断主机名/IP 是否允许作为外部拉取目标fetch
FetchOptions::allow_private_targets默认 false,仅单测可显式放行URLTest
test_node_with在 dial 前拦截私网/元数据目标安全与兼容边界
验证
cargo test -p core-outbound -p core-fetch -p core-runtimeallow_private_targets=true下通过127.0.0.1/169.254.169.254返回 BlockedTarget