$_REQUEST php vulnerability



这是一个关于网络安全的问题

大家好,我正在用tryhackme.com研究logical flaw(身份验证绕过(室我在php中发现了$_REQUEST方法。

在继续之前,请明确。。。在这里,我们要让网站将reset password发送到我们自己的电子邮件

我们使用的命令curl http://MACHINE_IP/customers/reset?email=robert%40acmeitsupport.thm' -H 'Content-Type: application/x-www-form-urlencoded' -d 'username=robert&email=attacker@hacker.com'

首先,为什么我们需要POST中的username??为什么我们没有在query string中使用它?

第二

我不明白这应该如何将密码重定向到attacker@hacker.com

THM称

The PHP $_REQUEST variable is an array that contains data received from the query string and POST data. If the same key name is used for both the query string and POST data, the application logic for this variable favours POST data fields rather than the query string, so if we add another parameter to the POST form, we can control where the password reset email gets delivered

这意味着$_REQUESTphp方法将选择POST而不是查询字符串。我对此没有意见。但如果它真的选择了POST,那么它应该在电子邮件字段中输入:attacker@hacker.com(因为它选择了POST方式(但是那封电子邮件根本不存在!所以应该说Account not found from supplied email address,而不是。。。它将密码重定向到我们的电子邮件!?

感谢阅读。房间链接,以备不时之需https://tryhackme.com/room/authenticationbypass

假设您尚未共享的代码会执行以下操作:

$reset_token = make_reset_token_for($_GET['email');
send_reset_token_to($reset_token, $_REQUEST['email']);

因此,它从查询字符串中读取电子邮件地址以生成重置令牌(并更新数据库中该电子邮件地址的帐户信息(,但随后将重置令牌发送到请求正文中的电子邮件地址(这是攻击者的地址,而不是帐户所有者的地址(。

然后,攻击者可以使用重置令牌更改帐户所有者的密码,然后登录到他们的帐户。

最新更新