DVWA靶场之十五:授权绕过(Authorisation Bypass)
DVWA靶场之十五:授权绕过(Authorisation Bypass)
当开发人员必须在复杂的系统中构建授权矩阵时,他们很容易忽略在每个地方添加正确的检查,尤其是那些无法通过浏览器直接访问的地方,例如 API 调用。
作为一名测试人员,您需要查看系统进行的每个调用,然后使用各个级别的用户进行测试,以确保检查正确执行。这通常是一项漫长而枯燥的任务,尤其是在矩阵庞大且包含大量不同用户类型的情况下。但测试至关重要,因为一次检查失误就可能导致攻击者获得机密数据或功能的访问权限。
目标
这关里提供了一个用户管理列表,但是只有管理员用户 admin 可以访问。
攻击者的目标是:作为非管理员用户,实现用户管理的功能。
完成这关时,必须以非管理员用户登录 DVWA,例如名为 gordonb(密码 abc123)的用户。
1. Low:无防护
通过 gordonb 用户登录后,会发现左侧菜单中的 “Authorisation Bypass” 这一关卡消失了。
不过,我们不难注意到每个安全漏洞关卡实际上对应一个子路径。因此,我们仍然可以通过直接访问以下 URL 进入用户管理页面:
http://127.0.0.1/vulnerabilities/authbypass/
该页面未实施任何访问控制机制,只要进入页面,即可直接获得修改和编辑用户信息的权限。
2. Medium:网页进不去
<?php
/*Only the admin user is allowed to access this page.Have a look at these two files for possible vulnerabilities: * vulnerabilities/authbypass/get_user_data.php
* vulnerabilities/authbypass/change_user_details.php*/if (dvwaCurrentUser() != "admin") {print "Unauthorised";http_response_code(403);exit;
}
?>
只有当前登录用户是 admin 时 才能访问这个页面。普通用户会看到 Unauthorised,不能通过正常的网页界面(User Interface)进入。
提示里说,可以查看这两个文件:
vulnerabilities/authbypass/get_user_data.php
[{"user_id":"1","first_name":"admin","surname":"admin"},{"user_id":"2","first_name":"Gordon","surname":"Brown"},{"user_id":"3","first_name":"Hack","surname":"Me"},{"user_id":"4","first_name":"Pablo","surname":"Picasso"},{"user_id":"5","first_name":"Bob","surname":"Smith"}]
vulnerabilities/authbypass/change_user_details.php
{"result":"fail","error":"Only POST requests are accepted"}
这两个网页没有检查当前用户是否是 admin,而是直接根据传入的参数(比如 id)来操作数据。
例如:
访问 get_user_data.php
返回所有用户的 JSON 数据,包括 admin 的敏感信息。
调用 change_user_details.php
可以修改任意用户的信息。
3. High:修改接口可用
<?php
/*Only the admin user is allowed to access this page.Have a look at this file for possible vulnerabilities: * vulnerabilities/authbypass/change_user_details.php*/if (dvwaCurrentUser() != "admin") {print "Unauthorised";http_response_code(403);exit;
}
?>
这次访问http://127.0.0.1/vulnerabilities/authbypass/get_user_data.php
返回{"result":"fail","error":"Access denied"}
了
访问vulnerabilities/authbypass/change_user_details.php
和之前一样
使用burp构造数据用POST发送就能成功
http://127.0.0.1/vulnerabilities/open_redirect/
返回
{"result":"ok"}
4. impossible 所有都有访问权限
访问http://127.0.0.1/vulnerabilities/authbypass/change_user_details.php
返回{"result":"fail","error":"Access denied"}
已为 change_user_details.php
文件添加访问权限控制。现在,整个系统的所有页面和接口都已进入受保护状态,必须登录后才能使用。