IPBUF安全漏洞报告
English
CVE-2025-25298 CVSS 5.3 中危

CVE-2025-25298 Strapi密码截断漏洞导致有效熵降低

披露日期: 2025-10-16

漏洞信息

漏洞编号
CVE-2025-25298
漏洞类型
密码截断/认证缺陷
CVSS评分
5.3 中危
攻击向量
网络 (AV:N)
认证要求
无需认证 (PR:N)
用户交互
无需交互 (UI:N)
影响产品
Strapi (@strapi/core)

相关标签

CVE-2025-25298Strapi@strapi/core密码截断bcryptjs认证缺陷中危漏洞CMS安全密码哈希信息泄露

漏洞概述

CVE-2025-25298是Strapi开源无头内容管理系统(Headless CMS)中的一个中危安全漏洞。该漏洞存在于@strapi/core包的密码哈希处理逻辑中,影响5.10.3之前的所有版本。当用户使用bcryptjs进行密码哈希时,系统未强制设置密码的最大长度限制。由于bcryptjs算法本身会忽略超过72字节的输入数据,导致超过72字节的密码在哈希过程中被静默截断。这意味着用户可以创建一个密码超过72字节的账户,但在后续认证时,仅需使用前72字节即可成功登录。此漏洞会降低超长密码的有效熵值,可能误导用户认为超过72字节的字符部分是必需的,从而在实际安全效果上产生偏差。此外,过长的输入还会对服务器造成不必要的处理开销。该漏洞的CVSS 3.1评分为5.3分,攻击向量为网络(AV:N),无需认证(PR:N),无需用户交互(UI:N),对机密性产生低影响(C:L),完整性和可用性不受影响。该问题已在Strapi 5.10.3版本中修复,目前尚无已知的临时缓解方案。Strapi作为广泛使用的开源CMS平台,此漏洞可能影响大量依赖其进行内容管理的Web应用程序。建议所有使用受影响版本的用户尽快升级到修复版本以确保系统安全。

技术细节

该漏洞的核心技术原理在于bcryptjs算法的固有特性和Strapi缺乏输入验证的组合。bcryptjs是基于bcrypt算法的JavaScript实现,其设计初衷是将密码哈希限制在72字节以内。当输入密码超过72字节时,bcryptjs会静默地丢弃超出部分,仅对前72字节进行哈希运算。在Strapi的@strapi/core包中,用户注册和密码更新接口未对密码长度进行上限校验,导致用户可以提交任意长度的密码。攻击利用方式如下:1)攻击者或正常用户注册时设置一个超过72字节的密码(例如'AAAAAA...(72字节有效部分)...BBBB(超长部分)');2)系统使用bcryptjs对完整密码进行哈希,但实际仅哈希前72字节,结果存储在数据库中;3)当用户尝试登录时,仅需输入前72字节部分即可通过认证,因为后端的哈希比较仅基于截断后的72字节;4)这种行为降低了密码的有效熵,因为攻击者只需猜测前72字节即可,无需考虑用户认为有效的全部字符。攻击者无需认证即可通过网络远程利用此漏洞,通过观察系统行为或尝试截断密码即可实现未授权访问的可能性。此外,超长密码输入还会导致bcrypt计算时的CPU开销增加,可能被用于拒绝服务攻击的辅助手段。修复方案是在密码处理流程中加入最大长度校验,确保输入不超过72字节。

攻击链分析

STEP 1
步骤1:识别目标
攻击者通过网络扫描或信息收集,识别运行Strapi CMS(版本低于5.10.3)的目标系统,确认其使用@strapi/core包进行用户认证。
STEP 2
步骤2:分析认证机制
攻击者分析Strapi的注册和登录接口,确认系统使用bcryptjs进行密码哈希处理,且未对密码长度进行限制。
STEP 3
步骤3:利用密码截断
攻击者注册账户时设置超过72字节的密码,系统使用bcryptjs进行哈希但仅处理前72字节,攻击者了解到仅需前72字节即可登录。
STEP 4
步骤4:降低密码熵
通过观察用户行为或社会工程,攻击者可能获取用户设置的长密码的前72字节部分,即可绕过完整密码要求进行认证。
STEP 5
步骤5:未授权访问
攻击者使用截断后的密码(仅前72字节)成功登录系统,获取未授权访问权限,可能导致敏感数据泄露。

PoC / 利用代码

⚠️ 仅供安全研究
以下代码仅用于安全研究和授权测试,未经授权使用属于违法行为。
PoC
// CVE-2025-25298 PoC - Strapi Password Truncation Vulnerability // Demonstrates how bcryptjs silently truncates passwords beyond 72 bytes const bcrypt = require('bcryptjs'); async function demonstrateTruncation() { // Create a password longer than 72 bytes const longPassword = 'A'.repeat(72) + 'EXTRA_SECRET_SUFFIX_DATA'; // Create the same password but only the first 72 bytes const truncatedPassword = 'A'.repeat(72); console.log('Long password length:', Buffer.byteLength(longPassword)); console.log('Truncated password length:', Buffer.byteLength(truncatedPassword)); // Hash the long password (Strapi's vulnerable behavior) const hash1 = await bcrypt.hash(longPassword, 10); console.log('Hash of long password:', hash1); // Hash the truncated password const hash2 = await bcrypt.hash(truncatedPassword, 10); console.log('Hash of truncated password:', hash2); // Verify: long password matches with truncated version const match1 = await bcrypt.compare(truncatedPassword, hash1); console.log('Truncated password matches hash of long password:', match1); // Expected: true - proving the truncation vulnerability // Simulate Strapi registration with long password console.log('\n--- Simulating Strapi Registration ---'); const userInputPassword = 'MySecureP@ssw0rd' + 'X'.repeat(60); // > 72 bytes const storedHash = await bcrypt.hash(userInputPassword, 10); console.log('User registered with password length:', Buffer.byteLength(userInputPassword)); console.log('Stored hash:', storedHash); // Attacker only needs first 72 bytes to authenticate const attackerPassword = userInputPassword.substring(0, 72); const authResult = await bcrypt.compare(attackerPassword, storedHash); console.log('Attacker authentication with truncated password:', authResult); // Expected: true - vulnerability confirmed } demonstrateTruncation().catch(console.error); // Exploitation steps for CVE-2025-25298: // 1. Identify a Strapi instance running version < 5.10.3 // 2. Register a new account with a password > 72 bytes // 3. The system stores hash based only on first 72 bytes // 4. Authentication only requires the first 72 bytes // 5. Effective password entropy is reduced

影响范围

@strapi/core < 5.10.3
Strapi 5.x < 5.10.3

防御指南

临时缓解措施
由于目前尚无已知的官方临时缓解方案,建议立即升级到Strapi 5.10.3或更高版本以修复此漏洞。在无法立即升级的情况下,可以考虑在应用层面添加中间件来验证密码长度,拒绝超过72字节的密码输入。同时应监控认证日志,识别可能的异常登录行为。建议尽快完成升级以避免安全风险。

参考链接

快速导航: 前沿安全 最新收录域名列表 最新威胁情报列表 最新网站排名列表 最新工具资源列表 最新CVE漏洞列表