-
Notifications
You must be signed in to change notification settings - Fork 440
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SOCKS 5 的认证在使用 UDP 时可被绕过 #104
Comments
👀 |
The proposed new behavior that randomly allocates UDP ports should be opt-in. Otherwise it would be a huge breaking change to existing setups. |
Just refrain from using password authentication for SOCKS5, for now. |
Attempting to fix the issue directly could easily break existing use scenarios of SOCKS5 inbounds. Instead of doing that and breaking things, what about just dropping SOCKS5 authentication support, and asking those who need authentication to use Shadowsocks instead? With Shadowsocks they get extra protections with reliable authentication and secure encryption. |
这个问题我也发现了,事实上 v2ray 的整个 Socks5 实现都是相当不规范的,比如出站的密码认证行为和 UDP Associate 请求 回到这个问题,本质是 VR 当初可能没有理解 UDP Associate 请求是在做什么,我简单说一下 RFC 1928 的规范:
然后各代理软件的实现大多是简单粗暴地监听固定的 UDP 端口,并且完全不管上面这些流程的限制,无论带不带密码认证 |
As a temporary measure, I will warn in the docs need to use the firewall, If the sharing socks5 proxy on a public network. |
Hi, @kslr |
Yes |
got, have a good day. |
Author: @studentmain
Send Date: 2021-01-08
v2ray 等代理软件的内置 SOCKS 服务器对所有客户端共用同一 UDP 端口,导致其 SOCKS 5 UDP 服务无需认证即可使用。
复现
为代理软件的 SOCKS 入站配置密码,对于 v2ray 可参考以下配置文件:
验证密码是否已起效:
向 v2ray 设定的 UDP 端口直接发送一个 SOCKS 5 UDP 包(以 DNS 查询为例),用 Wireshark 等监视,若服务端有任何响应,则漏洞存在
分析
SOCKS 5 要求 UDP 客户端先通过 SOCKS 5 TCP 协议请求服务端分配用于通信的 UDP 端口。SOCKS 5 TCP 协议允许多种认证方式,而 SOCKS 5 UDP 协议自身没有任何区分客户端的机制,需通过报文源端口来区分不同的客户端。
当 SOCKS 5 服务端对所有客户端分配同一 UDP 端口时,因为无法预测客户端使用的 UDP 源端口,服务端必须始终接受来自任意源地址的 UDP 报文。在此种情况下,服务端没有措施保证 UDP 客户端已经认证。
解决方案
对每一个 SOCKS 5 UDP ASSOCIATE 请求分配独立的 UDP 端口,此 UDP 端口在收到第一个数据报后忽略来自其他源地址的数据报。
虽 SOCKS 5 UDP 协议自身仍然没有认证,但不固定端口使得攻击者需要进行扫描才能找到 SOCKS 5 UDP 端口。而已经开始监听的 UDP 端口有很大可能在监听开始后极短时间(1RTT)即已收到来自客户端的首个数据报,进而忽略来自端口扫描器的数据报。
未实现任何认证的服务端因为本就没有认证,可忽略该漏洞,仍然对所有客户端分配同一 UDP 端口。显然地,已经实现认证的
SOCKS 服务端也可通过移除认证机能来忽略该漏洞。
The text was updated successfully, but these errors were encountered: