
معرّف CVE: CVE-2025-12758
درجة CVSS: 8.7 (HIGH)
الحرجية: HIGH
CWE: CWE-792 (تصفية غير مكتملة لمثيل واحد أو أكثر من العناصر الخاصة)
تاريخ النشر: 26 نوفمبر 2025
تاريخ الإفصاح: 19 أكتوبر 2025
تؤثر هذه الثغرة على إصدارات حزمة validator npm الأصغر من 13.15.22. لا تراعي دالة isLength() محددات التنويع الموحّد في Unicode (\uFE0F, \uFE0E) عند حساب طول السلسلة النصية، مما يؤدي إلى تحقق غير سليم من المدخلات.
يمكن لأي تطبيق يستخدم isLength() للتحقق من المدخلات قبول سلاسل نصية أطول بكثير من المقصود، مما قد يؤدي إلى:
لا تقوم دالة isLength() بتصفية محددات التنويع الموحّد في Unicode بشكل صحيح عند حساب طول السلسلة النصية. لا ينبغي لهذه الأحرف الخاصة (علامات الدمج) أن تساهم في الطول المرئي للسلسلة، ولكنها تُحتسب ضمن خاصية String.length في JavaScript.
npm install [email protected]
node poc.js
يوضح إثبات المفهوم (POC) الثغرة من خلال اختبار دالة isLength():
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!
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.
قد يقوم أحد التطبيقات بتنفيذ التحقق من تعليقات المستخدمين:
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 ⚠️
npm install [email protected]
يتعامل الإصدار المصحح مع محددات التنويع الموحّد في Unicode بشكل صحيح من خلال استبعادها من حسابات الطول.
إذا تعذّر عليك الترقية فورًا، فنفّذ تحققًا مخصصًا من الطول:
function safeIsLength(str, options = {}) {
// Remove Unicode variation selectors before validation
const cleanStr = str.replace(/[\uFE0E\uFE0F]/g, '');
return validator.isLength(cleanStr, options);
}
تحقق مما إذا كان تطبيقك معرضًا للخطر:
npm audit --audit-level=high
ابحث عن حزمة validator بإصدار أقل من 13.15.22.
اكتشف الثغرة: Karol Wrótniak
ISC