Skip to content

DNS:特定环境下fakeIP失效问题 #4543

@Meo597

Description

@Meo597

完整性要求

  • 我保证阅读了文档,了解所有我编写的配置文件项的含义,而不是大量堆砌看似有用的选项或默认值。
  • 我提供了完整的配置文件和日志,而不是出于自己的判断只给出截取的部分。
  • 我搜索了 issues, 没有发现已提出的类似问题。
  • 问题在 Release 最新的版本上可以成功复现

描述

细节:
fakeIP原理是Xray污染DNS,给客户端返回特定IP段
若客户端发往xray的IP因各种原因被修改,fakeIP即失效

详见代码

			if err == nil && d.shouldOverride(ctx, result, sniffingRequest, destination) {
				domain := result.Domain()
				errors.LogInfo(ctx, "sniffed domain: ", domain)
				destination.Address = net.ParseAddress(domain)
				protocol := result.Protocol()
				if resComp, ok := result.(SnifferResultComposite); ok {
					protocol = resComp.ProtocolForDomainResult()
				}
                                // fakeIP依赖于客户端发往xray IP`ob.Target.Address`的准确性
				isFakeIP := false
				if fkr0, ok := d.fdns.(dns.FakeDNSEngineRev0); ok && fkr0.IsIPInIPPool(ob.Target.Address) {
					isFakeIP = true
				}
				if sniffingRequest.RouteOnly && protocol != "fakedns" && protocol != "fakedns+others" && !isFakeIP {
					ob.RouteTarget = destination
				} else {
					ob.Target = destination
				}
			}

修复建议
入站时选择不相信客户端带来的ip,强行用xray的dns重解析一次,因为可命中缓存因此无开销
See demo: Meo597@d5b80c7
(此Demo是之前专为realIP修复,若确认fakeIP需要PR,我可再次修改)

重现方式

DNS被污染触发条件:

PC端Chrome系浏览器,电脑网卡配置为知名公共DNS,且他们支持DOH
或 Android系统自动配置了安全DNS
或手机端App接入了天朝特色httpdns SDK

影响到Xray的条件(绕过fakeIP的逻辑):

透明代理 + fakeIP
routeOnly=true

实际不利影响:
因fakeIP失效,若远端xray节点没有sniff+destOverride+routeOnly=false
则目标网站仍被污染,导致访问失败

PS:透明代理+realIP同理

客户端配置

N/A

服务端配置

N/A

客户端日志

N/A

服务端日志

N/A

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions