
CVE ID: CVE-2025-12758
CVSS スコア: 8.7 (HIGH)
重要度: HIGH
CWE: CWE-792 (Incomplete Filtering of One or More Instances of Special Elements)
公開日: November 26, 2025
開示日: October 19, 2025
この脆弱性は、validator npm パッケージのバージョン < 13.15.22 に影響します。isLength() 関数は、文字列の長さを計算する際に Unicode 変異セレクタ (\uFE0F, \uFE0E) を考慮しないため、不適切な入力検証が発生します。
isLength() を入力検証に使用するアプリケーションは、意図したよりも大幅に長い文字列を受け入れる可能性があり、その結果、以下の問題が発生する可能性があります:
isLength() 関数は、文字列の長さを計算する際に Unicode 変異セレクタを適切にフィルタリングしません。これらの特殊文字 (結合マーク) は文字列の視覚的な長さに寄与すべきではありませんが、JavaScript の String.length プロパティではカウントされます。
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
3 番目の出力はこの脆弱性を示しています: 実際の長さが 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
バージョンが 13.15.22 未満の validator パッケージを探してください。
脆弱性発見者: Karol Wrótniak
ISC